use of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials 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 org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials in project jackrabbit-oak by apache.
the class SystemUserImplTest method testImpersonateDisabledSystemUser.
@Test
public void testImpersonateDisabledSystemUser() throws Exception {
User user = createUser(null);
user.disable("disabled");
root.commit();
try {
ContentSession cs = login(new ImpersonationCredentials(new SimpleCredentials(uid, new char[0]), adminSession.getAuthInfo()));
cs.close();
fail();
} catch (LoginException e) {
// success
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials in project jackrabbit-oak by apache.
the class SystemUserImplTest method testImpersonateSystemUser.
@Test
public void testImpersonateSystemUser() throws Exception {
createUser(null);
ContentSession cs = login(new ImpersonationCredentials(new SimpleCredentials(uid, new char[0]), adminSession.getAuthInfo()));
cs.close();
}
use of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials in project jackrabbit-oak by apache.
the class SessionImpl method impersonate.
@Override
@Nonnull
public Session impersonate(Credentials credentials) throws RepositoryException {
checkAlive();
ImpersonationCredentials impCreds = new ImpersonationCredentials(checkNotNull(credentials), sd.getAuthInfo());
return getRepository().login(impCreds, sd.getWorkspaceName());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials in project jackrabbit-oak by apache.
the class LoginModuleImpl method getLoginId.
//--------------------------------------------------------------------------
@CheckForNull
private String getLoginId(@CheckForNull PreAuthenticatedLogin preAuthenticatedLogin) {
if (preAuthenticatedLogin != null) {
return preAuthenticatedLogin.getUserId();
}
String uid = null;
if (credentials != null) {
if (credentials instanceof SimpleCredentials) {
uid = ((SimpleCredentials) credentials).getUserID();
} else if (credentials instanceof GuestCredentials) {
uid = getAnonymousId();
} else if (credentials instanceof ImpersonationCredentials) {
Credentials bc = ((ImpersonationCredentials) credentials).getBaseCredentials();
if (bc instanceof SimpleCredentials) {
uid = ((SimpleCredentials) bc).getUserID();
}
} else {
try {
NameCallback callback = new NameCallback("User-ID: ");
callbackHandler.handle(new Callback[] { callback });
uid = callback.getName();
} catch (UnsupportedCallbackException e) {
log.warn("Credentials- or NameCallback must be supported");
} catch (IOException e) {
log.error("Name-Callback failed: " + e.getMessage());
}
}
}
if (uid == null) {
uid = getSharedLoginName();
}
return uid;
}
Aggregations