Search in sources :

Example 26 with Credentials

use of javax.jcr.Credentials in project jackrabbit-oak by apache.

the class CallbackHandlerImplTest method handlePasswordCallback2.

@Test
public void handlePasswordCallback2() throws Exception {
    PasswordCallback cb = new PasswordCallback("prompt", false);
    create(new Credentials() {
    }).handle(new Callback[] { cb });
    assertNull(cb.getPassword());
}
Also used : PasswordCallback(javax.security.auth.callback.PasswordCallback) SimpleCredentials(javax.jcr.SimpleCredentials) Credentials(javax.jcr.Credentials) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 27 with Credentials

use of javax.jcr.Credentials in project jackrabbit-oak by apache.

the class SystemUserImplTest method testGetCredentials.

@Test
public void testGetCredentials() throws Exception {
    User user = createUser(null);
    Credentials creds = user.getCredentials();
    assertTrue(creds instanceof UserIdCredentials);
    UserIdCredentials impl = (UserIdCredentials) creds;
    assertEquals(uid, impl.getUserId());
}
Also used : UserIdCredentials(org.apache.jackrabbit.oak.spi.security.user.UserIdCredentials) User(org.apache.jackrabbit.api.security.user.User) UserIdCredentials(org.apache.jackrabbit.oak.spi.security.user.UserIdCredentials) ImpersonationCredentials(org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials) SimpleCredentials(javax.jcr.SimpleCredentials) Credentials(javax.jcr.Credentials) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 28 with Credentials

use of javax.jcr.Credentials in project jackrabbit-oak by apache.

the class AuthInfoImplTest method testCreateFromSubjectWithAnyCredentials.

@Test
public void testCreateFromSubjectWithAnyCredentials() {
    Subject subject = new Subject();
    subject.getPublicCredentials().add(new Credentials() {
    });
    AuthInfo info = AuthInfoImpl.createFromSubject(subject);
    assertNull(info.getUserID());
    assertTrue(info.getPrincipals().isEmpty());
    assertEquals(0, info.getAttributeNames().length);
}
Also used : AuthInfo(org.apache.jackrabbit.oak.api.AuthInfo) Subject(javax.security.auth.Subject) SimpleCredentials(javax.jcr.SimpleCredentials) Credentials(javax.jcr.Credentials) Test(org.junit.Test)

Example 29 with Credentials

use of javax.jcr.Credentials in project jackrabbit-oak by apache.

the class OpenAuthenticationConfigurationTest method testLoginContextSubject.

@Test
public void testLoginContextSubject() throws LoginException {
    Credentials creds = new Credentials() {
    };
    LoginContext ctx = lcp.getLoginContext(creds, null);
    assertNotNull(ctx);
    Subject subject = ctx.getSubject();
    assertEquals(new Subject(true, ImmutableSet.<Principal>of(), ImmutableSet.of(), ImmutableSet.of(creds)), subject);
}
Also used : Credentials(javax.jcr.Credentials) Subject(javax.security.auth.Subject) Principal(java.security.Principal) Test(org.junit.Test)

Example 30 with Credentials

use of javax.jcr.Credentials in project jackrabbit-oak by apache.

the class UserManagerTest method testNewUserCanLogin.

@Test
public void testNewUserCanLogin() throws RepositoryException, NotExecutableException {
    String uid = createUserId();
    User u = null;
    Session s = null;
    try {
        u = userMgr.createUser(uid, "pw");
        superuser.save();
        Credentials creds = new SimpleCredentials(uid, "pw".toCharArray());
        s = superuser.getRepository().login(creds);
    } finally {
        if (u != null) {
            u.remove();
            superuser.save();
        }
        if (s != null) {
            s.logout();
        }
    }
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) User(org.apache.jackrabbit.api.security.user.User) SimpleCredentials(javax.jcr.SimpleCredentials) Credentials(javax.jcr.Credentials) Session(javax.jcr.Session) Test(org.junit.Test)

Aggregations

Credentials (javax.jcr.Credentials)86 SimpleCredentials (javax.jcr.SimpleCredentials)53 Test (org.junit.Test)33 GuestCredentials (javax.jcr.GuestCredentials)26 Session (javax.jcr.Session)17 TokenCredentials (org.apache.jackrabbit.api.security.authentication.token.TokenCredentials)14 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)13 RepositoryException (javax.jcr.RepositoryException)12 User (org.apache.jackrabbit.api.security.user.User)12 ImpersonationCredentials (org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials)12 LoginException (javax.security.auth.login.LoginException)8 ArrayList (java.util.ArrayList)7 LoginException (javax.jcr.LoginException)6 Subject (javax.security.auth.Subject)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Repository (javax.jcr.Repository)5 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)5 Principal (java.security.Principal)4 Map (java.util.Map)4