use of javax.jcr.GuestCredentials 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 javax.jcr.GuestCredentials in project jackrabbit-oak by apache.
the class TokenAuthenticationTest method testAuthenticateWithInvalidCredentials.
@Test
public void testAuthenticateWithInvalidCredentials() throws Exception {
List<Credentials> invalid = new ArrayList<Credentials>();
invalid.add(new GuestCredentials());
invalid.add(new SimpleCredentials(userId, new char[0]));
for (Credentials creds : invalid) {
assertFalse(authentication.authenticate(creds));
}
}
use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.
the class TokenLoginModuleTest method testGuestLogin.
@Test
public void testGuestLogin() throws Exception {
ContentSession cs = null;
try {
cs = login(new GuestCredentials());
fail("GuestCredentials login should fail");
} catch (LoginException e) {
// success
} finally {
if (cs != null) {
cs.close();
}
}
}
use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.
the class TokenProviderImplReadOnlyTest method before.
@Override
public void before() throws Exception {
super.before();
AccessControlManager acMgr = getAccessControlManager(root);
String userPath = getTestUser().getPath();
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, userPath);
acl.addAccessControlEntry(EveryonePrincipal.getInstance(), privilegesFromNames(PrivilegeConstants.JCR_READ));
acMgr.setPolicy(userPath, acl);
root.commit();
cs = login(new GuestCredentials());
readOnlyRoot = cs.getLatestRoot();
readOnlyTp = new TokenProviderImpl(readOnlyRoot, getTokenConfig(), getUserConfiguration());
}
use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.
the class TokenProviderImplTest method testDoCreateToken.
@Test
public void testDoCreateToken() throws Exception {
assertFalse(tokenProvider.doCreateToken(new GuestCredentials()));
assertFalse(tokenProvider.doCreateToken(new TokenCredentials("token")));
assertFalse(tokenProvider.doCreateToken(getAdminCredentials()));
SimpleCredentials sc = new SimpleCredentials("uid", "pw".toCharArray());
assertFalse(tokenProvider.doCreateToken(sc));
sc.setAttribute("any_attribute", "value");
assertFalse(tokenProvider.doCreateToken(sc));
sc.setAttribute("rep:token_key", "value");
assertFalse(tokenProvider.doCreateToken(sc));
sc.setAttribute(".token", "existing");
assertFalse(tokenProvider.doCreateToken(sc));
sc.setAttribute(".token", "");
assertTrue(tokenProvider.doCreateToken(sc));
}
Aggregations