private void checkInvalidCharForUserData(String data,final char[] invalidChars) throws InvalidArgumentException {
  if (null == data)   return;
  for (  char invalidChar : invalidChars) {
    if (-1 != data.indexOf(invalidChar)) {
      throw new InvalidArgumentException(String.format("Invalid character [%c] detected! please check PrincipalManagement service API",invalidChar));
    }
  }
}

private void checkInvalidCharForUserData ( String data , final char [ ] invalidChars ) throws InvalidArgumentException { if ( null == data ) return ; for ( char invalidChar : invalidChars ) { if ( - 1 != data . indexOf ( invalidChar ) ) { throw new InvalidArgumentException ( String . format ( "Invalid character [%c] detected! please check PrincipalManagement service API" , invalidChar ) ) ; } } }
check the optional data against the set of invalid chars and throw exception if detected
