@Override public int authenticate(Context context, String username, String password, String realm, HttpServletRequest request) { return authenticateInternal(context, username, password, realm, request, false); }
@Override public Iterator<AuthenticationMethod> authenticationMethodIterator() { return getAuthenticationMethodStack().iterator(); } }
protected int authenticateInternal(Context context, String username, String password, String realm, HttpServletRequest request, boolean implicitOnly) { // better is lowest, so start with the highest. int bestRet = AuthenticationMethod.BAD_ARGS; // return on first success, otherwise "best" outcome. for (AuthenticationMethod aMethodStack : getAuthenticationMethodStack()) { if (!implicitOnly || aMethodStack.isImplicit()) { int ret = 0; try { ret = aMethodStack.authenticate(context, username, password, realm, request); } catch (SQLException e) { ret = AuthenticationMethod.NO_SUCH_USER; } if (ret == AuthenticationMethod.SUCCESS) { updateLastActiveDate(context); return ret; } if (ret < bestRet) { bestRet = ret; } } } return bestRet; }
@Override public boolean allowSetPassword(Context context, HttpServletRequest request, String username) throws SQLException { for (AuthenticationMethod method : getAuthenticationMethodStack()) { if (method.allowSetPassword(context, request, username)) { return true; } } return false; }
@Override public int authenticateImplicit(Context context, String username, String password, String realm, HttpServletRequest request) { return authenticateInternal(context, username, password, realm, request, true); }
@Override public boolean canSelfRegister(Context context, HttpServletRequest request, String username) throws SQLException { for (AuthenticationMethod method : getAuthenticationMethodStack()) { if (method.canSelfRegister(context, request, username)) { return true; } } return false; }
@Override public void initEPerson(Context context, HttpServletRequest request, EPerson eperson) throws SQLException { for (AuthenticationMethod method : getAuthenticationMethodStack()) { method.initEPerson(context, request, eperson); } }
@Override public List<Group> getSpecialGroups(Context context, HttpServletRequest request) throws SQLException { List<Group> result = new ArrayList<>(); int totalLen = 0; for (AuthenticationMethod method : getAuthenticationMethodStack()) { List<Group> gl = method.getSpecialGroups(context, request); if (gl.size() > 0) { result.addAll(gl); totalLen += gl.size(); } } return result; }