public void validateUserName(String userName,String regEx) throws UserNamePasswordValidationException {
  try {
    AMUserPasswordValidation plugin=getUPValidationInstance();
    if (plugin != null) {
      debug.message("Validating username...");
      Map envMap=new HashMap(2);
      envMap.put(com.sun.identity.shared.Constants.ORGANIZATION_NAME,getRequestOrg());
      plugin.validateUserID(userName,envMap);
    }
 else     if (regEx != null && (regEx.length() != 0)) {
      if (!(ISValidation.validate(userName,regEx,debug))) {
        throw new UserNamePasswordValidationException(bundleName,"invalidChars",null);
      }
    }
  }
 catch (  AMException ame) {
    if (debug.messageEnabled()) {
      debug.message("User Name validation Failed" + ame.getMessage());
    }
    throw new UserNamePasswordValidationException(ame);
  }
catch (  Exception ex) {
    debug.message("unKnown Exception occured during username validation");
    throw new UserNamePasswordValidationException(ex);
  }
}

public void validateUserName ( String userName , String regEx ) throws UserNamePasswordValidationException { try { AMUserPasswordValidation plugin = getUPValidationInstance ( ) ; if ( plugin != null ) { debug . message ( "Validating username..." ) ; Map envMap = new HashMap ( 2 ) ; envMap . put ( com . sun . identity . shared . Constants . ORGANIZATION_NAME , getRequestOrg ( ) ) ; plugin . validateUserID ( userName , envMap ) ; } else if ( regEx != null && ( regEx . length ( ) != 0 ) ) { if ( ! ( ISValidation . validate ( userName , regEx , debug ) ) ) { throw new UserNamePasswordValidationException ( bundleName , "invalidChars" , null ) ; } } } catch ( AMException ame ) { if ( debug . messageEnabled ( ) ) { debug . message ( "User Name validation Failed" + ame . getMessage ( ) ) ; } throw new UserNamePasswordValidationException ( ame ) ; } catch ( Exception ex ) { debug . message ( "unKnown Exception occured during username validation" ) ; throw new UserNamePasswordValidationException ( ex ) ; } }
validates the given user name by using validation plugin if exists else it checks invalid characters in the source string .
