Package org.apache.ofbiz.passport.user
Class GitHubAuthenticator
java.lang.Object
org.apache.ofbiz.passport.user.GitHubAuthenticator
- All Implemented Interfaces:
Authenticator
GitHub OFBiz Authenticator
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
authenticate
(String userLoginId, String password, boolean isServiceAuth) Method to authenticate a user.createUser
(Map<String, Object> userMap) Create user string.getUserInfo
(org.apache.http.client.methods.HttpGet httpGet, String accessToken, String tokenType, Locale locale) float
Weight of this authenticator (lower weights are run first)void
initialize
(LocalDispatcher dispatcher) Method called when authenticator is first initialized (the delegator object can be obtained from the LocalDispatcher)boolean
Flag to test if this Authenticator is enabledboolean
Is this expected to be the only authenticator, if so errors will be thrown when users cannot be foundboolean
Is the user synchronzied back to OFBizvoid
Logs a user outvoid
Reads user information and syncs it to OFBiz (i.e.void
updatePassword
(String username, String password, String newPassword) Updates a user's password.
-
Field Details
-
PROPS
- See Also:
-
-
Constructor Details
-
GitHubAuthenticator
public GitHubAuthenticator()
-
-
Method Details
-
initialize
Method called when authenticator is first initialized (the delegator object can be obtained from the LocalDispatcher)- Specified by:
initialize
in interfaceAuthenticator
- Parameters:
dispatcher
- The ServiceDispatcher to use for this Authenticator
-
authenticate
public boolean authenticate(String userLoginId, String password, boolean isServiceAuth) throws AuthenticatorException Method to authenticate a user. For GitHub users, we only check if the username(userLoginId) exists an externalAuthId, and the externalAuthId has a valid accessToken in GitHubUser entity.- Specified by:
authenticate
in interfaceAuthenticator
- Parameters:
userLoginId
- User's login idpassword
- User's passwordisServiceAuth
- true if authentication is for a service call- Returns:
- true if the user is authenticated
- Throws:
AuthenticatorException
- when a fatal error occurs during authentication
-
logout
Logs a user out- Specified by:
logout
in interfaceAuthenticator
- Parameters:
username
- User's username- Throws:
AuthenticatorException
- when logout fails
-
syncUser
Reads user information and syncs it to OFBiz (i.e. UserLogin, Person, etc)- Specified by:
syncUser
in interfaceAuthenticator
- Parameters:
userLoginId
-- Throws:
AuthenticatorException
- user synchronization fails
-
createUser
Create user string.- Parameters:
userMap
- the user map- Returns:
- the string
- Throws:
AuthenticatorException
- the authenticator exception
-
updatePassword
public void updatePassword(String username, String password, String newPassword) throws AuthenticatorException Updates a user's password.- Specified by:
updatePassword
in interfaceAuthenticator
- Parameters:
username
- User's usernamepassword
- User's current passwordnewPassword
- User's new password- Throws:
AuthenticatorException
- when update password fails
-
getWeight
public float getWeight()Weight of this authenticator (lower weights are run first)- Specified by:
getWeight
in interfaceAuthenticator
- Returns:
- the weight of this Authenicator
-
isUserSynchronized
public boolean isUserSynchronized()Is the user synchronzied back to OFBiz- Specified by:
isUserSynchronized
in interfaceAuthenticator
- Returns:
- true if the user record is copied to the OFB database
-
isSingleAuthenticator
public boolean isSingleAuthenticator()Is this expected to be the only authenticator, if so errors will be thrown when users cannot be found- Specified by:
isSingleAuthenticator
in interfaceAuthenticator
- Returns:
- true if this is expected to be the only Authenticator
-
isEnabled
public boolean isEnabled()Flag to test if this Authenticator is enabled- Specified by:
isEnabled
in interfaceAuthenticator
- Returns:
- true if the Authenticator is enabled
-
getUserInfo
public static Map<String,Object> getUserInfo(org.apache.http.client.methods.HttpGet httpGet, String accessToken, String tokenType, Locale locale) throws AuthenticatorException - Throws:
AuthenticatorException
-