001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.io.auth; 003 004import org.openstreetmap.josm.tools.Utils; 005 006/** 007 * CredentialsAgentResponse represents the response from 008 * {@link CredentialsAgent#getCredentials(java.net.Authenticator.RequestorType, String, boolean)}. 009 * 010 * The response consists of the username and the password the requested credentials consists of. 011 * In addition, it provides information whether authentication was canceled by the user, i.e. 012 * because he or she canceled a username/password dialog (see {@link #isCanceled()}. 013 * It also provides information whether authentication should be saved. 014 * 015 */ 016public class CredentialsAgentResponse { 017 private String username; 018 private char[] password; 019 private boolean canceled; 020 private boolean saveCredentials; 021 /** 022 * Replies the user name 023 * @return The user name 024 */ 025 public String getUsername() { 026 return username; 027 } 028 029 /** 030 * Sets the user name 031 * @param username The user name 032 */ 033 public void setUsername(String username) { 034 this.username = username; 035 } 036 037 /** 038 * Replies the password 039 * @return The password in plain text 040 */ 041 public char[] getPassword() { 042 return password; 043 } 044 045 /** 046 * Sets the password 047 * @param password The password in plain text 048 */ 049 public void setPassword(char[] password) { 050 this.password = Utils.copyArray(password); 051 } 052 053 /** 054 * Determines if authentication request has been canceled by user 055 * @return true if authentication request has been canceled by user, false otherwise 056 */ 057 public boolean isCanceled() { 058 return canceled; 059 } 060 061 /** 062 * Sets the cancelation status (authentication request canceled by user) 063 * @param canceled the cancelation status (authentication request canceled by user) 064 */ 065 public void setCanceled(boolean canceled) { 066 this.canceled = canceled; 067 } 068 069 /** 070 * Determines if authentication credentials should be saved 071 * @return true if authentication credentials should be saved, false otherwise 072 */ 073 public boolean isSaveCredentials() { 074 return saveCredentials; 075 } 076 077 /** 078 * Sets the saving status (authentication credentials to save) 079 * @param saveCredentials the saving status (authentication credentials to save) 080 */ 081 public void setSaveCredentials(boolean saveCredentials) { 082 this.saveCredentials = saveCredentials; 083 } 084}