use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class Jackrabbit2ConfigurationTest method testInvalidSimpleCredentialsWithAttribute.
@Test
public void testInvalidSimpleCredentialsWithAttribute() throws Exception {
ContentSession cs = null;
try {
SimpleCredentials sc = new SimpleCredentials("test", new char[0]);
sc.setAttribute(".token", "");
cs = login(sc);
fail("Invalid simple credentials login should fail");
} catch (LoginException e) {
// success
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class Jackrabbit2ConfigurationTest method testTokenCreationAndLogin.
@Test
public void testTokenCreationAndLogin() throws Exception {
ContentSession cs = null;
try {
SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
sc.setAttribute(".token", "");
cs = login(sc);
Object token = sc.getAttribute(".token").toString();
assertNotNull(token);
TokenCredentials tc = new TokenCredentials(token.toString());
cs.close();
cs = login(tc);
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class PreAuthTest method testSubjectAndCredentials.
@Test
public void testSubjectAndCredentials() throws Exception {
final Subject subject = new Subject(true, principals, Collections.<Object>emptySet(), Collections.<Object>emptySet());
ContentSession cs = Subject.doAsPrivileged(subject, new PrivilegedAction<ContentSession>() {
@Override
public ContentSession run() {
ContentSession cs;
try {
cs = login(new GuestCredentials());
return cs;
} catch (Exception e) {
return null;
}
}
}, null);
assertNull("Login should have failed.", cs);
}
use of org.apache.jackrabbit.oak.api.ContentSession 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.ContentSession 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();
}
}
Aggregations