use of javax.jcr.GuestCredentials 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.GuestCredentials in project jackrabbit-oak by apache.
the class GuestLoginModuleTest method testNullLogin.
@Test
public void testNullLogin() throws LoginException {
Subject subject = new Subject();
CallbackHandler cbh = new TestCallbackHandler(null);
Map sharedState = new HashMap();
guestLoginModule.initialize(subject, cbh, sharedState, Collections.<String, Object>emptyMap());
assertTrue(guestLoginModule.login());
Object sharedCreds = sharedState.get(AbstractLoginModule.SHARED_KEY_CREDENTIALS);
assertNotNull(sharedCreds);
assertTrue(sharedCreds instanceof GuestCredentials);
assertTrue(guestLoginModule.commit());
assertFalse(subject.getPrincipals(EveryonePrincipal.class).isEmpty());
assertFalse(subject.getPublicCredentials(GuestCredentials.class).isEmpty());
assertTrue(guestLoginModule.logout());
}
use of javax.jcr.GuestCredentials 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.GuestCredentials in project jackrabbit-oak by apache.
the class L9_NullLoginTest method testJr2CompatibleLoginConfiguration.
public void testJr2CompatibleLoginConfiguration() throws RepositoryException {
// EXERCISE: define the JAAS configuration that allows you to have null-login treated as anonymous login.
Configuration configuration = null;
Configuration.setConfiguration(configuration);
try {
testSession = repository.login();
Session guest = repository.login(new GuestCredentials());
String expectedId = guest.getUserID();
guest.logout();
assertEquals(expectedId, testSession.getUserID());
} finally {
Configuration.setConfiguration(null);
}
}
use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.
the class L15_RepositoryWithoutAnonymousTest method testAnonymousLogin.
@Test
public void testAnonymousLogin() throws Exception {
ContentSession oakSession = null;
try {
oakSession = login(new GuestCredentials());
fail("Anonymous login must fail.");
} catch (javax.security.auth.login.LoginException e) {
// success
} finally {
if (oakSession != null) {
oakSession.close();
}
}
}
Aggregations