public static String getPlainToken(String encryptedToken) throws CryptoException { CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); String token = ""; if (encryptedToken != null) { token = new String(cryptoUtil.base64DecodeAndDecrypt(encryptedToken)); } return token; }
private String decrypt(String cipherText) throws CryptoException { return new String(CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt( cipherText), Charsets.UTF_8); } }
private String encryptPassword(String plainTextPassword) throws CryptoException { if (plainTextPassword != null) { return CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode(plainTextPassword.getBytes()); } return null; }
private String decryptPassword(String encryptedPassword) throws CryptoException { String decryptedPassword=null; if(encryptedPassword!=null){ decryptedPassword=new String(CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt(encryptedPassword)); } return decryptedPassword; }
public static String getPlainToken(String encryptedToken) throws CryptoException { CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); String token = ""; if (encryptedToken != null) { token = new String(cryptoUtil.base64DecodeAndDecrypt(encryptedToken)); } return token; }
private String decrypt(String cipherText) throws CryptoException { return new String(CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt( cipherText), Charsets.UTF_8); } }
private String encrypt(String plainText) throws CryptoException { return CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode( plainText.getBytes(Charsets.UTF_8)); }
private String encrypt(String plainText) throws CryptoException { return CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode( plainText.getBytes(Charsets.UTF_8)); }
private String getEncryptedPassword(String password) throws SecurityConfigException { CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); try { return cryptoUtil.encryptAndBase64Encode(password.getBytes()); } catch (CryptoException e) { String msg = "Unable to encrypt and encode password string."; log.error(msg, e); throw new SecurityConfigException(msg, e); } }
private String getDecryptedPassword(String encryptedString) throws SecurityConfigException { CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); try { return new String(cryptoUtil.base64DecodeAndDecrypt(encryptedString)); } catch (CryptoException e) { String msg = "Unable to decode and decrypt password string."; log.error(msg, e); throw new SecurityConfigException(msg, e); } }
private String getDecryptedPassword(String encryptedString) throws SecurityConfigException { CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); try { return new String(cryptoUtil.base64DecodeAndDecrypt(encryptedString)); } catch (CryptoException e) { String msg = "Unable to decode and decrypt password string."; log.error(msg, e); throw new SecurityConfigException(msg, e); } }
private String getEncryptedPassword(String password) throws SecurityConfigException { CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); try { return cryptoUtil.encryptAndBase64Encode(password.getBytes()); } catch (CryptoException e) { String msg = "Unable to encrypt and encode password string."; log.error(msg, e); throw new SecurityConfigException(msg, e); } }
private String getDecryptedPassword(String encryptedString) throws SecurityConfigException { CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); try { return new String(cryptoUtil.base64DecodeAndDecrypt(encryptedString)); } catch (CryptoException e) { String msg = "Unable to decode and decrypt password string."; log.error(msg, e); throw new SecurityConfigException(msg, e); } }
private String getEncryptedPassword(String password) throws SecurityConfigException { CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); try { return cryptoUtil.encryptAndBase64Encode(password.getBytes()); } catch (CryptoException e) { String msg = "Unable to encrypt and encode password string."; log.error(msg, e); throw new SecurityConfigException(msg, e); } }
/** * Decrypts the sensitive data in the Profile. * * @param profile The profile which has the data to be decrypted * @return The profile with the decrypted data */ private Profile decryptData(Profile profile) throws CryptoException { String cipherT = profile.getPass(); //decrypt the jmx server password byte[] decodedBArr = Base64.decodeBase64(cipherT.getBytes()); byte[] passwordBArr = CryptoUtil.getDefaultCryptoUtil().decrypt(decodedBArr); String password = new String(passwordBArr); profile.setPass(password); //decrypt the data publisher password String dpCipherT = profile.getDpPassword(); byte[] decodedDPBArr = Base64.decodeBase64(dpCipherT.getBytes()); byte[] passwordDPBArr = CryptoUtil.getDefaultCryptoUtil().decrypt(decodedDPBArr); String dpPassword = new String(passwordDPBArr); profile.setDpPassword(dpPassword); return profile; }
private void encodeProperty(Resource resource, String propKey) { try { if (resource.getProperty(propKey) != null) { resource.setProperty(propKey, CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode( resource.getProperty(propKey).getBytes())); } } catch (CryptoException e) { log.error("Unable to encrypt property key: " + propKey + " for resource " + "path: " + resource.getPath(), e); } }
private void decodeProperty(Resource resource, String propKey) { try { if(resource.getProperty(propKey)!=null){ resource.setProperty(propKey, new String(CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt( resource.getProperty(propKey)))); } } catch (CryptoException e) { log.error("Unable to decrypt property key: " + propKey + " for resource " + "path: " + resource.getPath(), e); } } }
/** * Encrypts the sensitive data in the Profile. * Currently encrypts only the passwords of the JMX * server and Data publisher. * * @param profile The profile which has the data to be encrypted * @return The profile with the encrypted data */ private Profile encryptData(Profile profile) throws CryptoException { //encrypt the JMX server password String password = profile.getPass(); //encrypt the password String cipherT = CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode(password.getBytes()); profile.setPass(cipherT); //encrypt the data publisher password String dpPassword = profile.getDpPassword(); //encrypt the password String dpCipherT = CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode(dpPassword.getBytes()); profile.setDpPassword(dpCipherT); return profile; }
/** * * @param token * @return */ public static String decryptToken(String token) throws CryptoException { AppManagerConfiguration config = ServiceReferenceHolder.getInstance() .getAPIManagerConfigurationService() .getAPIManagerConfiguration(); if (Boolean.parseBoolean(config.getFirstProperty(AppMConstants.API_KEY_MANAGER_ENCRYPT_TOKENS))) { return new String(CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt(token)); } return token; }
/** * * @param token * @return */ public static String encryptToken(String token) throws CryptoException { AppManagerConfiguration config = ServiceReferenceHolder.getInstance() .getAPIManagerConfigurationService() .getAPIManagerConfiguration(); if (Boolean.parseBoolean(config.getFirstProperty(AppMConstants.API_KEY_MANAGER_ENCRYPT_TOKENS))) { return CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode(token.getBytes()); } return token; }