@Override public MailboxSession login(String userid, String passwd) throws MailboxException { if (isValidLogin(userid, passwd)) { return createSession(userid, passwd, SessionType.User); } else { throw new BadCredentialsException(); } }
@Override public MailboxSession loginAsOtherUser(String adminUserid, String passwd, String otherUserId) throws MailboxException { if (! isValidLogin(adminUserid, passwd)) { throw new BadCredentialsException(); } Authorizator.AuthorizationState authorizationState = authorizator.canLoginAsOtherUser(adminUserid, otherUserId); switch (authorizationState) { case ALLOWED: return createSystemSession(otherUserId); case NOT_ADMIN: throw new NotAdminException(); case UNKNOWN_USER: throw new UserDoesNotExistException(otherUserId); default: throw new RuntimeException("Unknown AuthorizationState " + authorizationState); } }