| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package org.openstreetmap.josm.io.auth;
|
|---|
| 3 |
|
|---|
| 4 | /**
|
|---|
| 5 | * CredentialsAgentResponse represents the response from {@link CredentialsAgent#getCredentials(java.net.Authenticator.RequestorType, String, boolean)}.
|
|---|
| 6 | *
|
|---|
| 7 | * The response consists of the username and the password the requested credentials consists of.
|
|---|
| 8 | * In addition, it provides information whether authentication was canceled by the user, i.e.
|
|---|
| 9 | * because he or she canceled a username/password dialog (see {@link #isCanceled()}.
|
|---|
| 10 | * It also provides information whether authentication should be saved.
|
|---|
| 11 | *
|
|---|
| 12 | */
|
|---|
| 13 | public class CredentialsAgentResponse {
|
|---|
| 14 | private String username;
|
|---|
| 15 | private char[] password;
|
|---|
| 16 | private boolean canceled;
|
|---|
| 17 | private boolean saveCredentials;
|
|---|
| 18 | /**
|
|---|
| 19 | * Replies the user name
|
|---|
| 20 | * @return The user name
|
|---|
| 21 | */
|
|---|
| 22 | public String getUsername() {
|
|---|
| 23 | return username;
|
|---|
| 24 | }
|
|---|
| 25 | /**
|
|---|
| 26 | * Sets the user name
|
|---|
| 27 | * @param username The user name
|
|---|
| 28 | */
|
|---|
| 29 | public void setUsername(String username) {
|
|---|
| 30 | this.username = username;
|
|---|
| 31 | }
|
|---|
| 32 | /**
|
|---|
| 33 | * Replies the password
|
|---|
| 34 | * @return The password in plain text
|
|---|
| 35 | */
|
|---|
| 36 | public char[] getPassword() {
|
|---|
| 37 | return password;
|
|---|
| 38 | }
|
|---|
| 39 | /**
|
|---|
| 40 | * Sets the password
|
|---|
| 41 | * @param password The password in plain text
|
|---|
| 42 | */
|
|---|
| 43 | public void setPassword(char[] password) {
|
|---|
| 44 | this.password = password;
|
|---|
| 45 | }
|
|---|
| 46 | /**
|
|---|
| 47 | * Determines if authentication request has been canceled by user
|
|---|
| 48 | * @return true if authentication request has been canceled by user, false otherwise
|
|---|
| 49 | */
|
|---|
| 50 | public boolean isCanceled() {
|
|---|
| 51 | return canceled;
|
|---|
| 52 | }
|
|---|
| 53 | /**
|
|---|
| 54 | * Sets the cancelation status (authentication request canceled by user)
|
|---|
| 55 | * @param canceled the cancelation status (authentication request canceled by user)
|
|---|
| 56 | */
|
|---|
| 57 | public void setCanceled(boolean canceled) {
|
|---|
| 58 | this.canceled = canceled;
|
|---|
| 59 | }
|
|---|
| 60 | /**
|
|---|
| 61 | * Determines if authentication credentials should be saved
|
|---|
| 62 | * @return true if authentication credentials should be saved, false otherwise
|
|---|
| 63 | */
|
|---|
| 64 | public boolean isSaveCredentials() {
|
|---|
| 65 | return saveCredentials;
|
|---|
| 66 | }
|
|---|
| 67 | /**
|
|---|
| 68 | * Sets the saving status (authentication credentials to save)
|
|---|
| 69 | * @param saveCredentials the saving status (authentication credentials to save)
|
|---|
| 70 | */
|
|---|
| 71 | public void setSaveCredentials(boolean saveCredentials) {
|
|---|
| 72 | this.saveCredentials = saveCredentials;
|
|---|
| 73 | }
|
|---|
| 74 | }
|
|---|