@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 boolean allowSetPassword(Context context, HttpServletRequest request, String username) throws SQLException { for (AuthenticationMethod method : getAuthenticationMethodStack()) { if (method.allowSetPassword(context, request, username)) { return true; } } return false; }
.authenticationMethodIterator(); try if (auth.loginPageURL( ContextUtil.obtainContext(objectModel), httpRequest, httpResponse) != null){
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; }
network = Inet6Address.getByName(parts[0]).getAddress(); } catch (UnknownHostException e) { throw new IPMatcherException( "Malformed IP range specification " + ipSpec, e); maskBits = Integer.parseInt(parts[1]); } catch (NumberFormatException nfe) { throw new IPMatcherException( "Malformed IP range specification " + ipSpec, nfe); throw new IPMatcherException("Mask bits out of range 0-128 " + ipSpec); throw new IPMatcherException("Malformed IP range specification " + ipSpec); x = Integer.parseInt(maskParts[0]); } catch (NumberFormatException nfe) { throw new IPMatcherException( "Malformed IP range specification " + ipSpec, nfe); throw new IPMatcherException(); netmask[2] = (byte) ((fullMask & 0x0000FF00) >>> 8); netmask[3] = (byte) (fullMask & 0x000000FF); ipToBytes(ipPart, network, mustHave4); if (log.isDebugEnabled()) { log.debug("fullMask: " + fullMask);
/** * Does the given username and password authenticate for the * given DSpace Context? * * @param context * @param un * @param pw * @return true if yes, false if not */ public boolean authenticates(Context context, String un, String pw) { int auth = AuthenticationManager.authenticate(context, un, pw, null, null); if (auth == AuthenticationMethod.SUCCESS) { return true; } return false; }
ipToBytes(ipIn, candidate, true); candidate = ip4ToIp6(candidate); } else { try { candidate = Inet6Address.getByName(ipIn).getAddress(); } catch (UnknownHostException e) { throw new IPMatcherException("Malformed IPv6 address ", e);
@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; }
/** * Determine if the EPerson (to be created or already created) has the * ability to set their own password. * * @param objectModel * The Cocoon object model * @param email * The email address of the EPerson. * @return */ public static boolean allowSetPassword(Map objectModel, String email) throws SQLException { final HttpServletRequest request = (HttpServletRequest) objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT); Context context = ContextUtil.obtainContext(objectModel); return AuthenticationManager.allowSetPassword(context, request, email); }
/** * Determine if the email can register itself or needs to be * created by a site administrator first. * * @param objectModel * The Cocoon object model * @param email * The email of the person to be registered. * @return true if the email can register, otherwise false. */ public static boolean canSelfRegister(Map objectModel, String email) throws SQLException { final HttpServletRequest request = (HttpServletRequest) objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT); Context context = ContextUtil.obtainContext(objectModel); if (SystemwideAlerts.canUserStartSession()) { return AuthenticationManager.canSelfRegister(context, request, email); } else { // System wide alerts is preventing new sessions. return false; } }
AuthenticationManager.initEPerson(context, request, eperson);
@Override public int authenticate(Context context, String username, String password, String realm, HttpServletRequest request) { return authenticateInternal(context, username, password, realm, request, false); }
String value = findAttribute(request, name);
@Override public Iterator<AuthenticationMethod> authenticationMethodIterator() { return getAuthenticationMethodStack().iterator(); } }
throw new IPMatcherException("Malformed IP specification " + ip); int p = Integer.parseInt(parts[i]); if (p < 0 || p > 255) { throw new IPMatcherException("Malformed IP specification " + ip); throw new IPMatcherException("Malformed IP specification " + ip, nfe);
/** * Add matchers for the given comma-delimited IP ranges and group. * * @param groupName name of group * @param ipRanges IP ranges */ protected void addMatchers(String groupName, String[] ipRanges) { for (String entry : ipRanges) { try { IPMatcher ipm; if (entry.startsWith("-")) { ipm = new IPMatcher(entry.substring(1)); ipNegativeMatchers.add(ipm); } else { ipm = new IPMatcher(entry); ipMatchers.add(ipm); } ipMatcherGroupNames.put(ipm, groupName); if (log.isDebugEnabled()) { log.debug("Configured " + entry + " for special group " + groupName); } } catch (IPMatcherException ipme) { log.warn("Malformed IP range specified for group " + groupName, ipme); } } }
/** * Does the given username and password authenticate for the * given DSpace Context? * * @param context * @param un * @param pw * @return true if yes, false if not */ public boolean authenticates(Context context, String un, String pw) { int auth = AuthenticationManager.authenticate(context, un, pw, null, null); if (auth == AuthenticationMethod.SUCCESS) { 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); }
String values = findAttribute(request, name);