Change password validation

Change password validation

This is and example file on how you can implement (Signon Password Custom) Profile Option in Oracle E-Business Suite (using note 393552.1)

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "AppsPasswordValidationCUS" AS
package xxx;
import oracle.apps.fnd.security.PasswordValidation;

/**
* Custom password validation.
*/
public class AppsPasswordValidationCUS implements PasswordValidation
{
/**
* toString.
* @return String classname@hashcode.
*/
public String toString()
{
return getClass().toString()+”@”+hashCode();
}
private java.util.ArrayList errorMessages = new java.util.ArrayList();
/**
* Constructor.
*/
public AppsPasswordValidationCUS()
{
}
/**
* getErrorStackApplicationName.
* @return String “FND”.
*/
public String getErrorStackApplicationName()
{
return “FND”;
}
/**
* getErrorStackMessageName.
* @return String Contains all error messages.
*/
public String getErrorStackMessageName()
{
StringBuffer sb = new StringBuffer();
for(int i=0;(i<this.errorMessages.size() && i<1);i++)
{
sb.append((String) errorMessages.get(i));
sb.append(“;”);
}
return sb.toString();
}
/**
* main.
* @param args String[] arguments.
*/
public static void main(String[] args)
{
args.toString();
AppsPasswordValidationCUS validator = new AppsPasswordValidationCUS();
System.out.println(validator.validate(“USERNAME”, “Password0!”));
System.out.println(validator.getErrorStackMessageName());
}

/**
* validate.
* @param username String username.
* @param password String password.
* @return boolean True if password matches criteria. False otherwise.
*/
public boolean validate(String username, String password)
{
username.toString();
errorMessages = new java.util.ArrayList();
boolean result = false;
boolean containsUpperCase = false;
boolean containsLowerCase = false;
boolean containsNumeric = false;
boolean containsNonAlphaNumeric = false;
//check all characters of the string.
for(int i=0;i<password.length();i++)
{
//get character at position.
char c = password.charAt(i);
if(!Character.isLetterOrDigit(c))
{
if(!containsNonAlphaNumeric)
{
containsNonAlphaNumeric = true;
}
}
else
{
if(!containsUpperCase && Character.isUpperCase(c))
{
containsUpperCase = true;
}
else if(!containsLowerCase && Character.isLowerCase(c))
{
containsLowerCase = true;
}
else if(!containsNumeric && Character.isDigit(c))
{
containsNumeric = true;
}
}
}
if(!containsUpperCase)
{
this.errorMessages.add(“PASSWORD-MISSING-UPPERCASE”);
}
if(!containsLowerCase)
{
this.errorMessages.add(“PASSWORD-MISSING-LOWERCASE”);
}
if(!containsNumeric)
{
this.errorMessages.add(“PASSWORD-MISSING-NUMERIC”);
}
if(!containsNonAlphaNumeric)
{
this.errorMessages.add(“MISSING-NON-ALPHANUMERIC”);
}
if(containsUpperCase && containsLowerCase && containsNumeric && containsNonAlphaNumeric)
{
result = true;
}
return result;
}
}
/
EXIT
Geen reactie's

Geef een reactie