Search in sources :

Example 1 with AuthInfo

use of org.neo4j.server.security.enterprise.auth.plugin.spi.AuthInfo in project neo4j by neo4j.

the class PluginRealm method doGetAuthenticationInfo.

@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    if (token instanceof ShiroAuthToken) {
        try {
            AuthToken pluginAuthToken = PluginApiAuthToken.createFromMap(((ShiroAuthToken) token).getAuthTokenMap());
            if (authPlugin != null) {
                AuthInfo authInfo = authPlugin.authenticateAndAuthorize(pluginAuthToken);
                if (authInfo != null) {
                    PluginAuthInfo pluginAuthInfo = PluginAuthInfo.createCacheable(authInfo, getName(), secureHasher);
                    cacheAuthorizationInfo(pluginAuthInfo);
                    return pluginAuthInfo;
                }
            } else if (authenticationPlugin != null) {
                org.neo4j.server.security.enterprise.auth.plugin.spi.AuthenticationInfo authenticationInfo = authenticationPlugin.authenticate(pluginAuthToken);
                if (authenticationInfo != null) {
                    return PluginAuthenticationInfo.createCacheable(authenticationInfo, getName(), secureHasher);
                }
            }
        } catch (org.neo4j.server.security.enterprise.auth.plugin.api.AuthenticationException | InvalidAuthTokenException e) {
            throw new AuthenticationException(e.getMessage(), e.getCause());
        }
    }
    return null;
}
Also used : AuthInfo(org.neo4j.server.security.enterprise.auth.plugin.spi.AuthInfo) AuthenticationException(org.apache.shiro.authc.AuthenticationException) ShiroAuthToken(org.neo4j.server.security.enterprise.auth.ShiroAuthToken) ShiroAuthToken(org.neo4j.server.security.enterprise.auth.ShiroAuthToken) AuthToken(org.neo4j.server.security.enterprise.auth.plugin.api.AuthToken) CustomCacheableAuthenticationInfo(org.neo4j.server.security.enterprise.auth.plugin.spi.CustomCacheableAuthenticationInfo) AuthenticationInfo(org.apache.shiro.authc.AuthenticationInfo) InvalidAuthTokenException(org.neo4j.kernel.api.security.exception.InvalidAuthTokenException)

Aggregations

AuthenticationException (org.apache.shiro.authc.AuthenticationException)1 AuthenticationInfo (org.apache.shiro.authc.AuthenticationInfo)1 InvalidAuthTokenException (org.neo4j.kernel.api.security.exception.InvalidAuthTokenException)1 ShiroAuthToken (org.neo4j.server.security.enterprise.auth.ShiroAuthToken)1 AuthToken (org.neo4j.server.security.enterprise.auth.plugin.api.AuthToken)1 AuthInfo (org.neo4j.server.security.enterprise.auth.plugin.spi.AuthInfo)1 CustomCacheableAuthenticationInfo (org.neo4j.server.security.enterprise.auth.plugin.spi.CustomCacheableAuthenticationInfo)1