use of org.apache.jackrabbit.oak.api.AuthInfo in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testPrincipalsFromAuthInfo.
@Test
public void testPrincipalsFromAuthInfo() 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();
root.refresh();
PrincipalProvider pp = getSecurityProvider().getConfiguration(PrincipalConfiguration.class).getPrincipalProvider(root, NamePathMapper.DEFAULT);
Set<? extends Principal> expected = pp.getPrincipals(USER_ID);
assertEquals(3, expected.size());
assertEquals(expected, ai.getPrincipals());
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.api.AuthInfo in project jackrabbit-oak by apache.
the class PreAuthTest method testValidSubjectWithAuthInfo.
@Test
public void testValidSubjectWithAuthInfo() throws Exception {
AuthInfo info = new AuthInfoImpl("testUserId", Collections.<String, Object>emptyMap(), Collections.<Principal>emptySet());
Set<AuthInfo> publicCreds = Collections.singleton(info);
final Subject subject = new Subject(false, Collections.singleton(new TestPrincipal()), publicCreds, Collections.<Object>emptySet());
ContentSession cs = Subject.doAsPrivileged(subject, new PrivilegedAction<ContentSession>() {
@Override
public ContentSession run() {
try {
return login(null);
} catch (Exception e) {
return null;
}
}
}, null);
try {
assertSame(info, cs.getAuthInfo());
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.api.AuthInfo in project jackrabbit-oak by apache.
the class GuestDefaultLoginModuleTest method testNullLogin.
@Test
public void testNullLogin() throws Exception {
ContentSession cs = login(null);
try {
AuthInfo authInfo = cs.getAuthInfo();
String anonymousID = UserUtil.getAnonymousId(getUserConfiguration().getParameters());
assertEquals(anonymousID, authInfo.getUserID());
} finally {
cs.close();
}
}
use of org.apache.jackrabbit.oak.api.AuthInfo in project jackrabbit-oak by apache.
the class Jackrabbit2ConfigurationTest method testNullLogin.
@Test
public void testNullLogin() throws Exception {
ContentSession cs = login(null);
try {
AuthInfo authInfo = cs.getAuthInfo();
String anonymousID = UserUtil.getAnonymousId(getUserConfiguration().getParameters());
assertEquals(anonymousID, authInfo.getUserID());
} finally {
cs.close();
}
}
use of org.apache.jackrabbit.oak.api.AuthInfo in project jackrabbit-oak by apache.
the class Jackrabbit2ConfigurationTest method testTokenCreationWithImpersonationAttributes.
@Test
public void testTokenCreationWithImpersonationAttributes() throws Exception {
ContentSession cs = null;
try {
SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
sc.setAttribute(".token", "");
sc.setAttribute(".token.mandatory", "something");
sc.setAttribute("attr", "val");
ImpersonationCredentials ic = new ImpersonationCredentials(sc, new AuthInfoImpl(((SimpleCredentials) getAdminCredentials()).getUserID(), Collections.<String, Object>emptyMap(), Collections.<Principal>emptySet()));
cs = login(ic);
AuthInfo ai = cs.getAuthInfo();
Set<String> attrNames = ImmutableSet.copyOf(ai.getAttributeNames());
assertTrue(attrNames.contains("attr"));
assertFalse(attrNames.contains(".token"));
assertFalse(attrNames.contains(".token.mandatory"));
} finally {
if (cs != null) {
cs.close();
}
}
}
Aggregations