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