use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class TokenConfigurationImplOSGiTest method before.
@Override
public void before() throws Exception {
super.before();
tokenConfiguration.setSecurityProvider(getSecurityProvider());
context.registerInjectActivateService(tokenConfiguration, ImmutableMap.<String, Object>of(TokenProvider.PARAM_TOKEN_EXPIRATION, 25, TokenProvider.PARAM_TOKEN_LENGTH, 4));
sc = new SimpleCredentials(getTestUser().getID(), new char[0]);
sc.setAttribute(TokenConstants.TOKEN_ATTRIBUTE, "");
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class Jackrabbit2ConfigurationTest method testSimpleCredentialsWithAttribute.
@Test
public void testSimpleCredentialsWithAttribute() throws Exception {
ContentSession cs = null;
try {
SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
sc.setAttribute(".token", "");
cs = login(sc);
} finally {
if (cs != null) {
cs.close();
}
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class Jackrabbit2ConfigurationTest method testValidTokenCredentials.
@Test
public void testValidTokenCredentials() throws Exception {
Root root = adminSession.getLatestRoot();
TokenConfiguration tc = getSecurityProvider().getConfiguration(TokenConfiguration.class);
TokenProvider tp = tc.getTokenProvider(root);
SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
TokenInfo info = tp.createToken(sc.getUserID(), Collections.<String, Object>emptyMap());
ContentSession cs = login(new TokenCredentials(info.getToken()));
try {
assertEquals(sc.getUserID(), cs.getAuthInfo().getUserID());
} finally {
cs.close();
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class AbstractAddMembersByIdTest method addExistingMemberWithoutAccess.
Set<String> addExistingMemberWithoutAccess() throws Exception {
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, testGroup.getPath());
if (acl != null) {
if (acl.addEntry(getTestUser().getPrincipal(), privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.REP_USER_MANAGEMENT), true)) {
acMgr.setPolicy(testGroup.getPath(), acl);
root.commit();
}
}
String userId = getTestUser().getID();
ContentSession testSession = null;
try {
testSession = login(new SimpleCredentials(userId, userId.toCharArray()));
Root testRoot = testSession.getLatestRoot();
assertFalse(testRoot.getTree(memberGroup.getPath()).exists());
Group gr = getUserManager(testRoot).getAuthorizable(testGroup.getID(), Group.class);
Set<String> failed = gr.addMembers(memberGroup.getID());
testRoot.commit();
return failed;
} finally {
if (testSession != null) {
testSession.close();
}
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class UserAuthenticationTest method testAuthenticateIdMismatch.
@Test
public void testAuthenticateIdMismatch() throws Exception {
try {
authentication.authenticate(new SimpleCredentials("unknownUser", "pw".toCharArray()));
fail("LoginException expected");
} catch (LoginException e) {
// success
assertTrue(e instanceof FailedLoginException);
}
}
Aggregations