use of org.apache.knox.gateway.services.security.EncryptionResult in project knox by apache.
the class SecureQueryEncryptProcessor method encode.
private String encode(String string) throws UnsupportedEncodingException {
EncryptionResult result = null;
try {
result = encryptor.encrypt(string);
} catch (Exception e) {
log.unableToEncryptValue(e);
}
string = Base64.encodeBase64URLSafeString(result.toByteAray());
return string;
}
use of org.apache.knox.gateway.services.security.EncryptionResult in project knox by apache.
the class ConfigurableEncryptor method encrypt.
public EncryptionResult encrypt(String encrypt) throws Exception {
byte[] bytes = encrypt.getBytes("UTF-8");
EncryptionResult atom = encrypt(bytes);
return atom;
}
use of org.apache.knox.gateway.services.security.EncryptionResult in project knox by apache.
the class DecryptUriProcessor method decode.
private String decode(String string) throws UnsupportedEncodingException {
byte[] bytes = Base64.decodeBase64(string);
EncryptionResult result = EncryptionResult.fromByteArray(bytes);
byte[] clear = cryptoService.decryptForCluster(clusterName, EncryptUriDescriptor.PASSWORD_ALIAS, result.cipher, result.iv, result.salt);
if (clear != null) {
return new String(clear, StandardCharsets.UTF_8);
}
return null;
}
use of org.apache.knox.gateway.services.security.EncryptionResult in project knox by apache.
the class EncryptUriProcessor method encode.
private String encode(String string) throws UnsupportedEncodingException {
EncryptionResult result = cryptoService.encryptForCluster(clusterName, EncryptUriDescriptor.PASSWORD_ALIAS, string.getBytes(StandardCharsets.UTF_8));
string = Base64.encodeBase64URLSafeString(result.toByteAray());
return string;
}
use of org.apache.knox.gateway.services.security.EncryptionResult in project knox by apache.
the class CMFMasterService method persistMaster.
protected void persistMaster(char[] master, File masterFile) {
try {
EncryptionResult atom = encryptMaster(master);
ArrayList<String> lines = new ArrayList<>();
lines.add(MASTER_PERSISTENCE_TAG);
String line = Base64.encodeBase64String((Base64.encodeBase64String(atom.salt) + "::" + Base64.encodeBase64String(atom.iv) + "::" + Base64.encodeBase64String(atom.cipher)).getBytes(StandardCharsets.UTF_8));
lines.add(line);
FileUtils.writeLines(masterFile, StandardCharsets.UTF_8.name(), lines);
// restrict os permissions to only the user running this process
chmod("600", masterFile);
} catch (IOException e) {
LOG.failedToPersistMasterSecret(e);
}
}
Aggregations