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 encryptPassword(String plainTextPassword) throws CryptoException { if (plainTextPassword != null) { return CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode(plainTextPassword.getBytes()); } return null; }
/** * Util function to encrypt given plain text using given cipher * * @param cipher cipher that used to encrypt * @param plainTextBytes target plain text to encrypt using the cipher * @return Cipher text * @throws BadPaddingException * @throws IllegalBlockSizeException * @throws IOException */ public static byte[] encrypt(Cipher cipher, byte[] plainTextBytes) throws BadPaddingException, IllegalBlockSizeException, UserStoreException, NoSuchAlgorithmException, KeyStoreException, CertificateException { byte[] cipherText = cipher.doFinal(plainTextBytes); // Check whether custom transformation is configured if (System.getProperty(CIPHER_TRANSFORMATION_SYSTEM_PROPERTY) != null) { cipherText = CryptoUtil.getDefaultCryptoUtil().createSelfContainedCiphertext(cipherText, System.getProperty(CIPHER_TRANSFORMATION_SYSTEM_PROPERTY), getCertificate()); } return cipherText; }
if (content instanceof String) { resource.setContent(new String( CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt( ((String) content)))); } else if (content instanceof byte[]) { resource.setContent( CryptoUtil.getDefaultCryptoUtil() .decrypt((byte[]) content)); } else { log.warn(
if (content instanceof String) { resource.setContent( CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode( ((String) content).getBytes())); } else if (content instanceof byte[]) { resource.setContent( CryptoUtil.getDefaultCryptoUtil().encrypt((byte[])content)); } else { log.warn("Unable to encrypt unknown content type for resource path: " +
/** * 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 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)); }
/** * @param plainText Cipher text to be encrypted * @return Returns the encrypted text * @throws IdentityUserStoreMgtException Encryption failed */ public static String encryptPlainText(String plainText) throws IdentityUserStoreMgtException { if (cipher == null) { initializeKeyStore(); } try { byte[] encryptedKey = cipher.doFinal((plainText.getBytes())); if (cipherTransformation != null) { // If cipher transformation is configured via carbon.properties encryptedKey = CryptoUtil.getDefaultCryptoUtil() .createSelfContainedCiphertext(encryptedKey, cipherTransformation, certificate); } return Base64.encode(encryptedKey); } catch (GeneralSecurityException e) { String errMsg = "Failed to generate the cipher text"; throw new IdentityUserStoreMgtException(errMsg, e); } } }
private String decryptPassword(String encryptedPassword) throws CryptoException { String decryptedPassword=null; if(encryptedPassword!=null){ decryptedPassword=new String(CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt(encryptedPassword)); } return decryptedPassword; }
private String encrypt(String plainText) throws CryptoException { return CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode( plainText.getBytes(Charsets.UTF_8)); }
/** * @param plainText Cipher text to be encrypted * @return Returns the encrypted text * @throws IdentityUserStoreMgtException Encryption failed */ public static String encryptPlainText(String plainText) throws IdentityUserStoreMgtException { if (cipher == null) { initializeKeyStore(); } try { byte[] encryptedKey = cipher.doFinal((plainText.getBytes())); if (cipherTransformation != null) { // If cipher transformation is configured via carbon.properties encryptedKey = CryptoUtil.getDefaultCryptoUtil() .createSelfContainedCiphertext(encryptedKey, cipherTransformation, certificate); } return Base64.encode(encryptedKey); } catch (GeneralSecurityException e) { String errMsg = "Failed to generate the cipher text"; throw new IdentityUserStoreMgtException(errMsg, e); } } }
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 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); } }
cipherText = CryptoUtil.getDefaultCryptoUtil() .createSelfContainedCiphertext(cipherText, cipherTransformation, certificate);
private String decrypt(String cipherText) throws CryptoException { return new String(CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt( cipherText), 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 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); } }