use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class CallbackHandlerImplTest method handlePasswordCallback2.
@Test
public void handlePasswordCallback2() throws Exception {
PasswordCallback cb = new PasswordCallback("prompt", false);
create(new Credentials() {
}).handle(new Callback[] { cb });
assertNull(cb.getPassword());
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class SystemUserImplTest method testGetCredentials.
@Test
public void testGetCredentials() throws Exception {
User user = createUser(null);
Credentials creds = user.getCredentials();
assertTrue(creds instanceof UserIdCredentials);
UserIdCredentials impl = (UserIdCredentials) creds;
assertEquals(uid, impl.getUserId());
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class AuthInfoImplTest method testCreateFromSubjectWithAnyCredentials.
@Test
public void testCreateFromSubjectWithAnyCredentials() {
Subject subject = new Subject();
subject.getPublicCredentials().add(new Credentials() {
});
AuthInfo info = AuthInfoImpl.createFromSubject(subject);
assertNull(info.getUserID());
assertTrue(info.getPrincipals().isEmpty());
assertEquals(0, info.getAttributeNames().length);
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class OpenAuthenticationConfigurationTest method testLoginContextSubject.
@Test
public void testLoginContextSubject() throws LoginException {
Credentials creds = new Credentials() {
};
LoginContext ctx = lcp.getLoginContext(creds, null);
assertNotNull(ctx);
Subject subject = ctx.getSubject();
assertEquals(new Subject(true, ImmutableSet.<Principal>of(), ImmutableSet.of(), ImmutableSet.of(creds)), subject);
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class UserManagerTest method testNewUserCanLogin.
@Test
public void testNewUserCanLogin() throws RepositoryException, NotExecutableException {
String uid = createUserId();
User u = null;
Session s = null;
try {
u = userMgr.createUser(uid, "pw");
superuser.save();
Credentials creds = new SimpleCredentials(uid, "pw".toCharArray());
s = superuser.getRepository().login(creds);
} finally {
if (u != null) {
u.remove();
superuser.save();
}
if (s != null) {
s.logout();
}
}
}
Aggregations