use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class UserAuthenticationTest method testAuthenticateImpersonationCredentials.
@Test
public void testAuthenticateImpersonationCredentials() throws Exception {
SimpleCredentials sc = new SimpleCredentials(userId, new char[0]);
assertTrue(authentication.authenticate(new ImpersonationCredentials(sc, adminSession.getAuthInfo())));
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class AbstractLoginModuleTest method testGetSharedCredentials.
@Test
public void testGetSharedCredentials() {
Map<String, Object> sharedState = new HashMap();
sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, new TestCredentials());
AbstractLoginModule lm = initLoginModule(TestCredentials.class, sharedState);
assertTrue(lm.getSharedCredentials() instanceof TestCredentials);
sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, new SimpleCredentials("test", "test".toCharArray()));
lm = initLoginModule(TestCredentials.class, sharedState);
assertTrue(lm.getSharedCredentials() instanceof SimpleCredentials);
lm = initLoginModule(SimpleCredentials.class, sharedState);
assertTrue(lm.getSharedCredentials() instanceof SimpleCredentials);
sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, "no credentials object");
lm = initLoginModule(TestCredentials.class, sharedState);
assertNull(lm.getSharedCredentials());
sharedState.clear();
lm = initLoginModule(TestCredentials.class, sharedState);
assertNull(lm.getSharedCredentials());
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class AbstractLoginModuleTest method testGetCredentialsFromSubjectWrongClass.
@Test
public void testGetCredentialsFromSubjectWrongClass() {
Subject subject = new Subject();
subject.getPublicCredentials().add(new SimpleCredentials("userid", new char[0]));
AbstractLoginModule lm = new TestLoginModule(TestCredentials.class);
lm.initialize(subject, null, ImmutableMap.<String, Object>of(), null);
assertNull(lm.getCredentials());
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class GuestLoginModuleTest method testSimpleCredentials.
@Test
public void testSimpleCredentials() throws LoginException {
Subject subject = new Subject();
CallbackHandler cbh = new TestCallbackHandler(new SimpleCredentials("test", new char[0]));
Map sharedState = new HashMap();
guestLoginModule.initialize(subject, cbh, sharedState, Collections.<String, Object>emptyMap());
assertFalse(guestLoginModule.login());
assertFalse(sharedState.containsKey(AbstractLoginModule.SHARED_KEY_CREDENTIALS));
assertFalse(guestLoginModule.commit());
assertTrue(subject.getPrincipals().isEmpty());
assertTrue(subject.getPublicCredentials().isEmpty());
assertFalse(guestLoginModule.logout());
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class AuthInfoImplTest method testCreateFromSubjectWithSimpleCredentials.
@Test
public void testCreateFromSubjectWithSimpleCredentials() {
Subject subject = new Subject();
subject.getPublicCredentials().add(new SimpleCredentials(USER_ID, new char[0]));
AuthInfo info = AuthInfoImpl.createFromSubject(subject);
assertEquals(USER_ID, info.getUserID());
assertTrue(info.getPrincipals().isEmpty());
assertEquals(0, info.getAttributeNames().length);
}
Aggregations