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