Search in sources :

Example 11 with AuthInfoImpl

use of org.apache.jackrabbit.oak.spi.security.authentication.AuthInfoImpl in project jackrabbit-oak by apache.

the class UserIDTestLoginModule method commit.

@Override
public boolean commit() {
    if (!subject.isReadOnly()) {
        // be defensive: remove all potentially added "AuthInfo' objects.
        Set<AuthInfo> ais = subject.getPublicCredentials(AuthInfo.class);
        if (!ais.isEmpty()) {
            subject.getPublicCredentials().removeAll(ais);
        }
        // and finally add the one that produces the desired result:
        String userID = null;
        subject.getPublicCredentials().add(new AuthInfoImpl(userID, Collections.<String, Object>emptyMap(), Collections.<Principal>emptySet()));
        return true;
    } else {
        return false;
    }
}
Also used : AuthInfo(org.apache.jackrabbit.oak.api.AuthInfo) AuthInfoImpl(org.apache.jackrabbit.oak.spi.security.authentication.AuthInfoImpl) Principal(java.security.Principal)

Aggregations

AuthInfoImpl (org.apache.jackrabbit.oak.spi.security.authentication.AuthInfoImpl)11 AuthInfo (org.apache.jackrabbit.oak.api.AuthInfo)5 Principal (java.security.Principal)4 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)4 ImpersonationCredentials (org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 SimpleCredentials (javax.jcr.SimpleCredentials)3 Subject (javax.security.auth.Subject)3 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)3 PrivilegedActionException (java.security.PrivilegedActionException)2 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)2 Map (java.util.Map)2 Credentials (javax.jcr.Credentials)2 RepositoryException (javax.jcr.RepositoryException)2 Session (javax.jcr.Session)2 AdminPrincipal (org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal)2 Nonnull (javax.annotation.Nonnull)1 GuestCredentials (javax.jcr.GuestCredentials)1 LoginException (javax.security.auth.login.LoginException)1