use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class UserAuthenticationTest method testAuthenticateInvalidImpersonationCredentials.
@Test
public void testAuthenticateInvalidImpersonationCredentials() throws Exception {
List<Credentials> invalid = new ArrayList<Credentials>();
invalid.add(new ImpersonationCredentials(new GuestCredentials(), adminSession.getAuthInfo()));
invalid.add(new ImpersonationCredentials(new SimpleCredentials(adminSession.getAuthInfo().getUserID(), new char[0]), new TestAuthInfo()));
invalid.add(new ImpersonationCredentials(new SimpleCredentials("unknown", new char[0]), adminSession.getAuthInfo()));
invalid.add(new ImpersonationCredentials(new SimpleCredentials("unknown", new char[0]), new TestAuthInfo()));
for (Credentials creds : invalid) {
try {
authentication.authenticate(creds);
fail("LoginException expected");
} catch (LoginException e) {
// success
assertTrue(e instanceof FailedLoginException);
}
}
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class UserImplTest method testGetCredentialsUserWithoutPassword.
@Test
public void testGetCredentialsUserWithoutPassword() throws Exception {
user = userMgr.createUser(uid, null);
root.commit();
Credentials creds = user.getCredentials();
assertTrue(creds instanceof UserIdCredentials);
assertEquals(uid, ((UserIdCredentials) creds).getUserId());
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class AbstractLoginModuleTest method testGetCredentialsFromSharedState.
@Test
public void testGetCredentialsFromSharedState() {
Map<String, Credentials> sharedState = new HashMap();
sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, new TestCredentials());
AbstractLoginModule lm = initLoginModule(TestCredentials.class, sharedState);
assertTrue(lm.getCredentials() instanceof TestCredentials);
SimpleCredentials sc = new SimpleCredentials("test", "test".toCharArray());
sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, sc);
lm = initLoginModule(TestCredentials.class, sharedState);
assertNull(lm.getCredentials());
sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, sc);
lm = initLoginModule(SimpleCredentials.class, sharedState);
assertTrue(lm.getCredentials() instanceof SimpleCredentials);
sharedState.clear();
lm = initLoginModule(TestCredentials.class, sharedState);
assertNull(lm.getCredentials());
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class ImpersonationCredentialsTest method testGetBaseCredentials.
@Test
public void testGetBaseCredentials() {
Credentials creds = new GuestCredentials();
assertSame(creds, new ImpersonationCredentials(creds, info).getBaseCredentials());
Credentials simpleCreds = new SimpleCredentials("userId", new char[0]);
assertSame(simpleCreds, new ImpersonationCredentials(simpleCreds, info).getBaseCredentials());
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class CredentialsCallbackTest method testCallback.
@Test
public void testCallback() {
CredentialsCallback cb = new CredentialsCallback();
Credentials creds = new Credentials() {
};
cb.setCredentials(creds);
assertSame(creds, cb.getCredentials());
}
Aggregations