%@ page language="java" contentType="text/html; charset=ISO-8859-1"%> <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ page import="java.security.*" %> <%@ page import="java.io.*" %> <%@ page import="java.util.regex.*" %> <%! public static String getHash(String plainText) { try { MessageDigest mdAlgorithm = MessageDigest.getInstance("MD5"); mdAlgorithm.update(plainText.getBytes()); byte[] digest = mdAlgorithm.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < digest.length; i++) { plainText = Integer.toHexString(0xFF & digest[i]); if (plainText.length() < 2) { plainText = "0" + plainText; } hexString.append(plainText); } return(hexString.toString()); } catch(NoSuchAlgorithmException e) { return(null); } } %>
has a cap
"); has_cap = 1; } String lowRegex = "[a-z]"; Pattern lowPatt = Pattern.compile(lowRegex); Matcher lowMatcher = lowPatt.matcher(newPass); if ( lowMatcher.find() ) { has_lower = 1; } String symRegex = "\\p{Punct}"; Pattern symPatt = Pattern.compile(symRegex); Matcher symMatcher = symPatt.matcher(newPass); if ( symMatcher.find() ) { has_symbol = 1; } String numRegex = "\\d"; Pattern numPatt = Pattern.compile(numRegex); Matcher numMatcher = numPatt.matcher(newPass); if ( numMatcher.find() ) { has_number = 1; } if ( newPass.length() >= 12 ) { has_length = 1; } String passRegex = "((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\\p{Punct}).{12,})"; Pattern passPatt = Pattern.compile(passRegex); Matcher passMatcher = passPatt.matcher(newPass); if ( passMatcher.matches() ) { meets_requirements = 1; //out.println("Password meets requirements"); } else { meets_requirements = 0; out.println("The password you entered does not meet requirements");
if (has_number == 0) {
out.println(" You must have at least one number");
}
if (has_symbol == 0) {
out.println(" You must have at least one symbol");
}
if (has_lower == 0) {
out.println(" You must have at least one lowercase letter");
}
if (has_cap == 0) {
out.println(" You must have at least one uppercase letter");
}
if (has_length == 0) {
out.println(" Your password must be at least 12 characters long");
}
out.println("
The old hash is <%= sOldHash %>
The new hash is <%= sNewHash %>
--%>
Succesfully changed password for user ${row.user_name}
count is <%= count %> --%>
<% if (count == 0) {
out.println(" Incorrect password for user " + sUser + "!");
}
%>