I trying to avoid printing password in log. So in my log formatter class i search for a word "password" and then i trying to replace the value of password by *****'s. But now i m facing a issue like how to find the password when i have no password policy. MY CODE is :
class SecurityEnhancedLogFormatter {
private static final String[] keys= new String[] { "password", "pswrd" }; //No I18N
public String restrictPasswordEntry(String message){
    for(Object object : SENSITIVE_KEY_HASH_SET){
        String str = (String)object;
        while(true){
            if(message.contains(str)){
                int index = message.indexOf(str) - 1;
                message = message.replace(message.substring(index,message.indexOf(",",index)-1),"*****");
            } else {
                break;
            }
        }
    }
    return message;
}
in this how to find my password endindex when these passwords have no policy. That is for String "password" : jkd kjdd, kdjk*;'.,(this is example, the format can b anything)
 
     
     
     
    