Search in sources :

Example 1 with IUserAuthentication

use of com.apifest.oauth20.api.IUserAuthentication in project xian by happyyangyuan.

the class Authenticator method authenticateUser.

protected UserDetails authenticateUser(String username, String password, HttpRequest authRequest) throws AuthenticationException {
    UserDetails userDetails;
    IUserAuthentication ua;
    if (OAuthConfig.getUserAuthenticationClass() != null) {
        try {
            ua = OAuthConfig.getUserAuthenticationClass().newInstance();
            userDetails = ua.authenticate(username, password, authRequest);
        } catch (InstantiationException | IllegalAccessException e) {
            LOG.error("cannot instantiate user authentication class", e);
            throw new AuthenticationException(e.getMessage());
        }
    } else {
        // if no specific UserAuthentication used, always returns customerId - 12345
        userDetails = new UserDetails("12345", null);
    }
    return userDetails;
}
Also used : UserDetails(com.apifest.oauth20.api.UserDetails) AuthenticationException(com.apifest.oauth20.api.AuthenticationException) IUserAuthentication(com.apifest.oauth20.api.IUserAuthentication)

Aggregations

AuthenticationException (com.apifest.oauth20.api.AuthenticationException)1 IUserAuthentication (com.apifest.oauth20.api.IUserAuthentication)1 UserDetails (com.apifest.oauth20.api.UserDetails)1