use of org.apache.jackrabbit.oak.api.AuthInfo in project jackrabbit-oak by apache.
the class CustomCredentialsSupportTest method testLogin.
@Test
public void testLogin() throws Exception {
TestCredentials creds = new TestCredentials("testUser");
ContentSession cs = login(creds);
try {
AuthInfo info = cs.getAuthInfo();
assertEquals("testUser", info.getUserID());
assertAttributes(getCredentialsSupport().getAttributes(creds), info);
} finally {
cs.close();
}
}
use of org.apache.jackrabbit.oak.api.AuthInfo in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testLoginSetsAuthInfo.
@Test
public void testLoginSetsAuthInfo() throws Exception {
ContentSession cs = null;
try {
SimpleCredentials sc = new SimpleCredentials(USER_ID, USER_PWD.toCharArray());
sc.setAttribute("attr", "val");
cs = login(sc);
AuthInfo ai = cs.getAuthInfo();
assertEquals(USER_ID, ai.getUserID());
assertEquals("val", ai.getAttribute("attr"));
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.api.AuthInfo in project jackrabbit-oak by apache.
the class LoginModuleImplTest method testGuestLogin.
@Test
public void testGuestLogin() throws Exception {
try (ContentSession cs = login(new GuestCredentials())) {
AuthInfo authInfo = cs.getAuthInfo();
String anonymousID = UserUtil.getAnonymousId(getUserConfiguration().getParameters());
assertEquals(anonymousID, authInfo.getUserID());
}
}
use of org.apache.jackrabbit.oak.api.AuthInfo in project jackrabbit-oak by apache.
the class LoginModuleImplTest method testUserLoginIsCaseInsensitive.
@Test
public void testUserLoginIsCaseInsensitive() throws Exception {
ContentSession cs = null;
try {
createTestUser();
cs = login(new SimpleCredentials(USER_ID_CASED, USER_PW.toCharArray()));
AuthInfo authInfo = cs.getAuthInfo();
UserManager userMgr = getUserManager(root);
Authorizable auth = userMgr.getAuthorizable(authInfo.getUserID());
assertNotNull(auth);
assertTrue(auth.getID().equalsIgnoreCase(USER_ID_CASED));
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.api.AuthInfo in project jackrabbit-oak by apache.
the class LoginModuleImplTest method testSelfImpersonation.
@Test
public void testSelfImpersonation() throws Exception {
ContentSession cs = null;
try {
createTestUser();
SimpleCredentials sc = new SimpleCredentials(USER_ID, USER_PW.toCharArray());
cs = login(sc);
AuthInfo authInfo = cs.getAuthInfo();
assertEquals(USER_ID, authInfo.getUserID());
cs.close();
sc = new SimpleCredentials(USER_ID, new char[0]);
ImpersonationCredentials ic = new ImpersonationCredentials(sc, authInfo);
cs = login(ic);
authInfo = cs.getAuthInfo();
assertEquals(USER_ID, authInfo.getUserID());
} finally {
if (cs != null) {
cs.close();
}
}
}
Aggregations