org.apache.shiro.authc.pam.UnsupportedTokenException Java Examples

The following examples show how to use org.apache.shiro.authc.pam.UnsupportedTokenException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitlabAuthenticatingRealm.java    From nexus3-gitlabauth-plugin with MIT License 6 votes vote down vote up
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    if (!(token instanceof UsernamePasswordToken)) {
        throw new UnsupportedTokenException(String.format("Token of type %s  is not supported. A %s is required.",
                token.getClass().getName(), UsernamePasswordToken.class.getName()));
    }

    UsernamePasswordToken t = (UsernamePasswordToken) token;
    LOGGER.info("doGetAuthenticationInfo for {}", ((UsernamePasswordToken) token).getUsername());

    GitlabPrincipal authenticatedPrincipal;
    try {
        authenticatedPrincipal = gitlabClient.authz(t.getUsername(), t.getPassword());
        LOGGER.info("Successfully authenticated {}",t.getUsername());
    } catch (GitlabAuthenticationException e) {
        LOGGER.warn("Failed authentication", e);
        return null;
    }

    return createSimpleAuthInfo(authenticatedPrincipal, t);
}
 
Example #2
Source File: GithubOauthAuthenticatingRealm.java    From nexus3-github-oauth-plugin with MIT License 6 votes vote down vote up
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
	if (!(token instanceof UsernamePasswordToken)) {
		throw new UnsupportedTokenException(String.format("Token of type %s  is not supported. A %s is required.",
				token.getClass().getName(), UsernamePasswordToken.class.getName()));
	}

	UsernamePasswordToken t = (UsernamePasswordToken) token;
	LOGGER.info("doGetAuthenticationInfo for {}", ((UsernamePasswordToken) token).getUsername());
	GithubPrincipal authenticatedPrincipal;
	try {
		authenticatedPrincipal = githubClient.authz(t.getUsername(), t.getPassword());
		LOGGER.info("Successfully authenticated {}",t.getUsername());
	} catch (GithubAuthenticationException e) {
		LOGGER.warn("Failed authentication", e);
		return null;
	}

	return createSimpleAuthInfo(authenticatedPrincipal, t);
}
 
Example #3
Source File: ShiroClient.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
public void login(Object credentials) throws AuthenticationException {
   if(!(credentials instanceof AuthenticationToken)) {
      throw new UnsupportedTokenException("Invalid authentication token");
   }
   
   subject.login((AuthenticationToken) credentials);
}