use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class GuestLoginModule method login.
@Override
public boolean login() {
if (callbackHandler != null) {
CredentialsCallback ccb = new CredentialsCallback();
try {
callbackHandler.handle(new Callback[] { ccb });
Credentials credentials = ccb.getCredentials();
if (credentials == null) {
guestCredentials = new GuestCredentials();
sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, guestCredentials);
return true;
}
} catch (IOException e) {
log.debug("Login: Failed to retrieve Credentials from CallbackHandler", e);
} catch (UnsupportedCallbackException e) {
log.debug("Login: Failed to retrieve Credentials from CallbackHandler", e);
}
}
// ignore this login module
return false;
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class PreAuthDefaultExternalLoginModuleTest method testSimpleExternal.
@Test
public void testSimpleExternal() throws Exception {
// verify that authentication against the IDP succeeds with the given creds.
Credentials creds = new SimpleCredentials(TestIdentityProvider.ID_TEST_USER, new char[0]);
ExternalUser externalUser = idp.authenticate(creds);
assertNotNull(externalUser);
assertEquals(TestIdentityProvider.ID_TEST_USER, externalUser.getId());
// => repo login must also succeed and the user must be synced.
ContentSession cs = null;
try {
cs = login(creds);
assertEquals(TestIdentityProvider.ID_TEST_USER, cs.getAuthInfo().getUserID());
root.refresh();
User u = getUserManager(root).getAuthorizable(TestIdentityProvider.ID_TEST_USER, User.class);
assertNotNull(u);
} finally {
if (cs != null) {
cs.close();
}
}
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class TokenExternalLoginModuleTest method testTokenLogin.
@Test
public void testTokenLogin() throws Exception {
Credentials creds = createTestCredentials();
assertTrue(credentialsSupport.setAttributes(creds, ImmutableMap.<String, Object>of(".token", "")));
String expectedUserId = credentialsSupport.getUserId(creds);
ContentSession cs = login(creds);
try {
String token = credentialsSupport.getAttributes(creds).get(".token").toString();
cs.close();
cs = login(new TokenCredentials(token));
assertEquals(expectedUserId, cs.getAuthInfo().getUserID());
} finally {
cs.close();
}
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class CugOakTest method beforeSuite.
@Override
protected void beforeSuite() throws Exception {
super.beforeSuite();
Credentials creds = (runAsAdmin) ? getCredentials() : new GuestCredentials();
cs = contentRepository.login(creds, null);
subject = new Subject(true, cs.getAuthInfo().getPrincipals(), Collections.emptySet(), Collections.emptySet());
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class CallbackHandlerImplTest method handleNameCallback2.
@Test
public void handleNameCallback2() throws Exception {
NameCallback cb = new NameCallback("prompt");
create(new Credentials() {
}).handle(new Callback[] { cb });
assertNull(cb.getName());
}
Aggregations