Package org.apache.ofbiz.passport.user
Class LinkedInAuthenticator
- java.lang.Object
-
- org.apache.ofbiz.passport.user.LinkedInAuthenticator
-
- All Implemented Interfaces:
Authenticator
public class LinkedInAuthenticator extends java.lang.Object implements Authenticator
LinkedIn OFBiz Authenticator
-
-
Field Summary
Fields Modifier and Type Field Description protected Delegator
delegator
protected LocalDispatcher
dispatcher
static java.lang.String
props
static java.lang.String
resource
-
Constructor Summary
Constructors Constructor Description LinkedInAuthenticator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
authenticate(java.lang.String userLoginId, java.lang.String password, boolean isServiceAuth)
Method to authenticate a user.java.lang.String
createUser(org.w3c.dom.Document user)
static java.lang.String
getLinkedInUserId(org.w3c.dom.Document userInfo)
static org.w3c.dom.Document
getUserInfo(org.apache.http.client.methods.HttpGet httpGet, java.util.Locale locale)
float
getWeight()
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
isEnabled()
Flag to test if this Authenticator is enabledboolean
isSingleAuthenticator()
Is this expected to be the only authenticator, if so errors will be thrown when users cannot be foundboolean
isUserSynchronized()
Is the user synchronzied back to OFBizvoid
logout(java.lang.String username)
Logs a user outstatic java.util.Map<java.lang.String,java.lang.String>
parseLinkedInUserInfo(org.w3c.dom.Document userInfo)
void
syncUser(java.lang.String userLoginId)
Reads user information and syncs it to OFBiz (i.e.void
updatePassword(java.lang.String username, java.lang.String password, java.lang.String newPassword)
Updates a user's password.
-
-
-
Field Detail
-
props
public static final java.lang.String props
- See Also:
- Constant Field Values
-
resource
public static final java.lang.String resource
- See Also:
- Constant Field Values
-
dispatcher
protected LocalDispatcher dispatcher
-
delegator
protected Delegator delegator
-
-
Method Detail
-
initialize
public void initialize(LocalDispatcher dispatcher)
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(java.lang.String userLoginId, java.lang.String password, boolean isServiceAuth) throws AuthenticatorException
Method to authenticate a user. For LinkedIn users, we only check if the username(userLoginId) exists an externalAuthId, and the externalAuthId has a valid accessToken in LinkedInUser 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
public void logout(java.lang.String username) throws AuthenticatorException
Logs a user out- Specified by:
logout
in interfaceAuthenticator
- Parameters:
username
- User's username- Throws:
AuthenticatorException
- when logout fails
-
syncUser
public void syncUser(java.lang.String userLoginId) throws AuthenticatorException
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
public java.lang.String createUser(org.w3c.dom.Document user) throws AuthenticatorException
- Throws:
AuthenticatorException
-
updatePassword
public void updatePassword(java.lang.String username, java.lang.String password, java.lang.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 org.w3c.dom.Document getUserInfo(org.apache.http.client.methods.HttpGet httpGet, java.util.Locale locale) throws java.io.IOException, AuthenticatorException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
- Throws:
java.io.IOException
AuthenticatorException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
-
getLinkedInUserId
public static java.lang.String getLinkedInUserId(org.w3c.dom.Document userInfo)
-
parseLinkedInUserInfo
public static java.util.Map<java.lang.String,java.lang.String> parseLinkedInUserInfo(org.w3c.dom.Document userInfo)
-
-