1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.io.auth;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.tools.Utils;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * CredentialsAgentResponse represents the response from
|
---|
8 | * {@link CredentialsAgent#getCredentials(java.net.Authenticator.RequestorType, String, boolean)}.
|
---|
9 | *
|
---|
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.
|
---|
12 | * because he or she canceled a username/password dialog (see {@link #isCanceled()}.
|
---|
13 | * It also provides information whether authentication should be saved.
|
---|
14 | *
|
---|
15 | */
|
---|
16 | public class CredentialsAgentResponse {
|
---|
17 | private String username;
|
---|
18 | private char[] password;
|
---|
19 | private boolean canceled;
|
---|
20 | private boolean saveCredentials;
|
---|
21 | /**
|
---|
22 | * Replies the user name
|
---|
23 | * @return The user name
|
---|
24 | */
|
---|
25 | public String getUsername() {
|
---|
26 | return username;
|
---|
27 | }
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Sets the user name
|
---|
31 | * @param username The user name
|
---|
32 | */
|
---|
33 | public void setUsername(String username) {
|
---|
34 | this.username = username;
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Replies the password
|
---|
39 | * @return The password in plain text
|
---|
40 | */
|
---|
41 | public char[] getPassword() {
|
---|
42 | return password;
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Sets the password
|
---|
47 | * @param password The password in plain text
|
---|
48 | */
|
---|
49 | public void setPassword(char[] password) {
|
---|
50 | this.password = Utils.copyArray(password);
|
---|
51 | }
|
---|
52 |
|
---|
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 | */
|
---|
57 | public boolean isCanceled() {
|
---|
58 | return canceled;
|
---|
59 | }
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * Sets the cancelation status (authentication request canceled by user)
|
---|
63 | * @param canceled the cancelation status (authentication request canceled by user)
|
---|
64 | */
|
---|
65 | public void setCanceled(boolean canceled) {
|
---|
66 | this.canceled = canceled;
|
---|
67 | }
|
---|
68 |
|
---|
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 | }
|
---|
76 |
|
---|
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 | }
|
---|
84 | }
|
---|