/** * This method deals with password masking and returns the password in its plain text form. * @param maskPassword : explicit mask flag. If it's true, the password is interpreted as * masked. If it is false, the password is interpreted as plain text. * if it is null, the password will be interpreted as masked if the * password is wrapped in ENC(), or as plain text otherwise. * @param password : the original value of password string * @param codecClass : the codec used to decode the password. Only when the password is interpreted * as masked will this codec be used. Ignored otherwise. * @return */ public static String resolveMask(Boolean maskPassword, String password, String codecClass) throws Exception { String plainText = password; if (maskPassword == null) { if (isEncMasked(password)) { //masked String bareMaskedPassword = unwrap(password); plainText = getCodec(codecClass).decode(bareMaskedPassword); } } else if (maskPassword) { plainText = getCodec(codecClass).decode(password); } return plainText; }
/** * This method deals with password masking and returns the password in its plain text form. * @param maskPassword : explicit mask flag. If it's true, the password is interpreted as * masked. If it is false, the password is interpreted as plain text. * if it is null, the password will be interpreted as masked if the * password is wrapped in ENC(), or as plain text otherwise. * @param password : the original value of password string * @param codecClass : the codec used to decode the password. Only when the password is interpreted * as masked will this codec be used. Ignored otherwise. * @return */ public static String resolveMask(Boolean maskPassword, String password, String codecClass) throws Exception { String plainText = password; if (maskPassword == null) { if (isEncMasked(password)) { //masked String bareMaskedPassword = unwrap(password); plainText = getCodec(codecClass).decode(bareMaskedPassword); } } else if (maskPassword) { plainText = getCodec(codecClass).decode(password); } return plainText; }
/** * This method deals with password masking and returns the password in its plain text form. * @param maskPassword : explicit mask flag. If it's true, the password is interpreted as * masked. If it is false, the password is interpreted as plain text. * if it is null, the password will be interpreted as masked if the * password is wrapped in ENC(), or as plain text otherwise. * @param password : the original value of password string * @param codecClass : the codec used to decode the password. Only when the password is interpreted * as masked will this codec be used. Ignored otherwise. * @return */ public static String resolveMask(Boolean maskPassword, String password, String codecClass) throws Exception { String plainText = password; if (maskPassword == null) { if (isEncMasked(password)) { //masked String bareMaskedPassword = unwrap(password); plainText = getCodec(codecClass).decode(bareMaskedPassword); } } else if (maskPassword) { plainText = getCodec(codecClass).decode(password); } return plainText; }
@Test(expected = IllegalArgumentException.class) public void testGetCodecUsingInvalidCodec() throws Exception { PasswordMaskingUtil.getCodec("codec doesn't exist"); } }
/** * This method deals with password masking and returns the password in its plain text form. * @param maskPassword : explicit mask flag. If it's true, the password is interpreted as * masked. If it is false, the password is interpreted as plain text. * if it is null, the password will be interpreted as masked if the * password is wrapped in ENC(), or as plain text otherwise. * @param password : the original value of password string * @param codecClass : the codec used to decode the password. Only when the password is interpreted * as masked will this codec be used. Ignored otherwise. * @return */ public static String resolveMask(Boolean maskPassword, String password, String codecClass) throws Exception { String plainText = password; if (maskPassword == null) { if (isEncMasked(password)) { //masked String bareMaskedPassword = unwrap(password); plainText = getCodec(codecClass).decode(bareMaskedPassword); } } else if (maskPassword) { plainText = getCodec(codecClass).decode(password); } return plainText; }
/** * This method deals with password masking and returns the password in its plain text form. * @param maskPassword : explicit mask flag. If it's true, the password is interpreted as * masked. If it is false, the password is interpreted as plain text. * if it is null, the password will be interpreted as masked if the * password is wrapped in ENC(), or as plain text otherwise. * @param password : the original value of password string * @param codecClass : the codec used to decode the password. Only when the password is interpreted * as masked will this codec be used. Ignored otherwise. * @return */ public static String resolveMask(Boolean maskPassword, String password, String codecClass) throws Exception { String plainText = password; if (maskPassword == null) { if (isEncMasked(password)) { //masked String bareMaskedPassword = unwrap(password); plainText = getCodec(codecClass).decode(bareMaskedPassword); } } else if (maskPassword) { plainText = getCodec(codecClass).decode(password); } return plainText; }
/** * This method deals with password masking and returns the password in its plain text form. * @param maskPassword : explicit mask flag. If it's true, the password is interpreted as * masked. If it is false, the password is interpreted as plain text. * if it is null, the password will be interpreted as masked if the * password is wrapped in ENC(), or as plain text otherwise. * @param password : the original value of password string * @param codecClass : the codec used to decode the password. Only when the password is interpreted * as masked will this codec be used. Ignored otherwise. * @return */ public static String resolveMask(Boolean maskPassword, String password, String codecClass) throws Exception { String plainText = password; if (maskPassword == null) { if (isEncMasked(password)) { //masked String bareMaskedPassword = unwrap(password); plainText = getCodec(codecClass).decode(bareMaskedPassword); } } else if (maskPassword) { plainText = getCodec(codecClass).decode(password); } return plainText; }
/** * This method deals with password masking and returns the password in its plain text form. * @param maskPassword : explicit mask flag. If it's true, the password is interpreted as * masked. If it is false, the password is interpreted as plain text. * if it is null, the password will be interpreted as masked if the * password is wrapped in ENC(), or as plain text otherwise. * @param password : the original value of password string * @param codecClass : the codec used to decode the password. Only when the password is interpreted * as masked will this codec be used. Ignored otherwise. * @return */ public static String resolveMask(Boolean maskPassword, String password, String codecClass) throws Exception { String plainText = password; if (maskPassword == null) { if (isEncMasked(password)) { //masked String bareMaskedPassword = unwrap(password); plainText = getCodec(codecClass).decode(bareMaskedPassword); } } else if (maskPassword) { plainText = getCodec(codecClass).decode(password); } return plainText; }
@Test public void testGetCodecUsingServiceLoader() throws Exception { SensitiveDataCodec<String> codec = PasswordMaskingUtil.getCodec(PasswordMaskingUtil.getDefaultCodec().getClass().getCanonicalName()); assertTrue(codec instanceof DefaultSensitiveStringCodec); }