use of javax.jcr.LoginException in project jackrabbit-oak by apache.
the class UserTest method testLoginWithOldPassword.
@Test
public void testLoginWithOldPassword() throws RepositoryException, NotExecutableException {
try {
user.changePassword("changed");
superuser.save();
Session s = getHelper().getRepository().login(new SimpleCredentials(user.getID(), testPw.toCharArray()));
s.logout();
fail("user pw has changed. login must fail.");
} catch (LoginException e) {
// success
}
}
use of javax.jcr.LoginException in project jackrabbit-oak by apache.
the class UserTest method testLoginDisabledUser.
@Test
public void testLoginDisabledUser() throws Exception {
user.disable("readonly user is disabled!");
superuser.save();
// -> login must fail
try {
Session ss = getHelper().getRepository().login(new SimpleCredentials(user.getID(), "pw".toCharArray()));
ss.logout();
fail("A disabled user must not be allowed to login any more");
} catch (LoginException e) {
// success
}
}
use of javax.jcr.LoginException in project jackrabbit-oak by apache.
the class UserTest method testImpersonateDisabledUser.
@Test
public void testImpersonateDisabledUser() throws Exception {
user.disable("readonly user is disabled!");
superuser.save();
// -> impersonating this user must fail
try {
Session ss = superuser.impersonate(new SimpleCredentials(user.getID(), new char[0]));
ss.logout();
fail("A disabled user cannot be impersonated any more.");
} catch (LoginException e) {
// success
}
}
use of javax.jcr.LoginException in project jackrabbit-oak by apache.
the class UserTest method testLoginWithOldPassword2.
@Test
public void testLoginWithOldPassword2() throws RepositoryException, NotExecutableException {
try {
user.changePassword("changed", testPw);
superuser.save();
Session s = getHelper().getRepository().login(new SimpleCredentials(user.getID(), testPw.toCharArray()));
s.logout();
fail("superuser pw has changed. login must fail.");
} catch (LoginException e) {
// success
} finally {
user.changePassword(testPw);
superuser.save();
}
}
use of javax.jcr.LoginException in project sling by apache.
the class AbstractSlingRepository2 method loginService.
// service login
/**
* Actual implementation of the {@link #loginService(String, String)} method
* taking into account the bundle calling this method.
* <p/>
* This method uses the
* {@link AbstractSlingRepositoryManager#getServiceUserMapper()
* ServiceUserMapper} service to map the named service to a user and then
* calls the {@link #createServiceSession(String, String)} method actually
* create a session for that user.
*
* @param subServiceName An optional subService identifier (may be
* {@code null})
* @param workspace The workspace to access or {@code null} to access the
* {@link #getDefaultWorkspace() default workspace}
* @return A session authenticated with the service user
* @throws LoginException if the service name cannot be derived or if
* logging is as the user to which the service name maps is not
* allowed
* @throws RepositoryException If a general error occurs while creating the
* session
*/
@Override
public final Session loginService(final String subServiceName, final String workspace) throws LoginException, RepositoryException {
final ServiceUserMapper serviceUserMapper = this.getSlingRepositoryManager().getServiceUserMapper();
final String userName = (serviceUserMapper != null) ? serviceUserMapper.getServiceUserID(this.usingBundle, subServiceName) : null;
if (userName == null) {
throw new LoginException("Cannot derive user name for bundle " + usingBundle + " and sub service " + subServiceName);
}
return createServiceSession(userName, workspace);
}
Aggregations