|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.gui.JosmUserIdentityManager
public class JosmUserIdentityManager
JosmUserStateManager is a global object which keeps track of what JOSM knows about
the identity of the current user.
JOSM can be operated anonymously provided the current user never invokes an operation
on the OSM server which required authentication. In this case JOSM neither knows
the user name of the OSM account of the current user nor its unique id. Perhaps the
user doesn't have one.
If the current user supplies a user name and a password in the JOSM preferences JOSM
can partially identify the user.
The current user is fully identified if JOSM knows both the user name and the unique
id of the users OSM account. The latter is retrieved from the OSM server with a
GET /api/0.6/user/details request, submitted with the user name and password
of the current user.
The global JosmUserStateManager listens to Preferences.PreferenceChangeEvent
s and keeps track
of what the current JOSM instance knows about the current user. Other subsystems can
let the global JosmUserStateManager know in case they fully identify the current user, see
setFullyIdentified(java.lang.String, org.openstreetmap.josm.data.osm.UserInfo)
.
The information kept by the JosmUserStateManager can be used to
Field Summary | |
---|---|
private boolean |
accessTokenKeyChanged
|
private boolean |
accessTokenSecretChanged
|
private static JosmUserIdentityManager |
instance
|
private UserInfo |
userInfo
|
private java.lang.String |
userName
|
Constructor Summary | |
---|---|
private |
JosmUserIdentityManager()
|
Method Summary | |
---|---|
static JosmUserIdentityManager |
getInstance()
Replies the unique instance of the JOSM user identity manager |
int |
getUserId()
Replies the user id of the current JOSM user. |
UserInfo |
getUserInfo()
Replies verified additional information about the current user if the user is isFullyIdentified() . |
java.lang.String |
getUserName()
Replies the user name of the current JOSM user. |
void |
initFromOAuth(java.awt.Component parent)
Initializes the user identity manager from OAuth request of user details. |
void |
initFromPreferences()
Initializes the user identity manager from Basic Authentication values in the Preferences
This method should be called if osm-server.auth-method is set to basic . |
boolean |
isAnonymous()
Replies true if the current JOSM user is anonymous. |
boolean |
isCurrentUser(java.lang.String username)
Replies true if the user with name username is the current
user |
boolean |
isFullyIdentified()
Replies true if the current JOSM user is fully identified. |
boolean |
isPartiallyIdentified()
Replies true if the current JOSM user is partially identified. |
void |
preferenceChanged(Preferences.PreferenceChangeEvent evt)
|
void |
setAnonymous()
Remembers the fact that the current JOSM user is anonymous. |
void |
setFullyIdentified(java.lang.String username,
UserInfo userinfo)
Remembers the fact that the current JOSM user is fully identified with a verified pair of user name and user id. |
void |
setPartiallyIdentified(java.lang.String userName)
Remebers the fact that the current JOSM user is partially identified by the user name of its OSM account. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static JosmUserIdentityManager instance
private java.lang.String userName
private UserInfo userInfo
private boolean accessTokenKeyChanged
private boolean accessTokenSecretChanged
Constructor Detail |
---|
private JosmUserIdentityManager()
Method Detail |
---|
public static JosmUserIdentityManager getInstance()
public void setAnonymous()
public void setPartiallyIdentified(java.lang.String userName) throws java.lang.IllegalArgumentException
userName
- the user name. Must not be null. Must not be empty (whitespace only).
java.lang.IllegalArgumentException
- thrown if userName is null
java.lang.IllegalArgumentException
- thrown if userName is emptypublic void setFullyIdentified(java.lang.String username, UserInfo userinfo) throws java.lang.IllegalArgumentException
userName
- the user name. Must not be null. Must not be empty.userinfo
- additional information about the user, retrieved from the OSM server and including the user id
java.lang.IllegalArgumentException
- thrown if userName is null
java.lang.IllegalArgumentException
- thrown if userName is empty
java.lang.IllegalArgumentException
- thrown if userinfo is nullpublic boolean isAnonymous()
public boolean isPartiallyIdentified()
public boolean isFullyIdentified()
public java.lang.String getUserName()
isAnonymous()
is true.
public int getUserId()
isAnonymous()
or
isPartiallyIdentified()
is true.
public UserInfo getUserInfo()
isFullyIdentified()
.
public void initFromPreferences()
Preferences
This method should be called if osm-server.auth-method
is set to basic
.
initFromOAuth(java.awt.Component)
public void initFromOAuth(java.awt.Component parent)
osm-server.auth-method
is set to oauth
.
parent
- component relative to which the PleaseWaitDialog
is displayed.initFromPreferences()
public boolean isCurrentUser(java.lang.String username)
username
is the current
user
username
- the user name
username
is the current
userpublic void preferenceChanged(Preferences.PreferenceChangeEvent evt)
preferenceChanged
in interface Preferences.PreferenceChangedListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |