add automatic encryption on new ServiceEndpoint
This commit is contained in:
parent
09c6155a45
commit
5d4793210e
|
@ -100,7 +100,7 @@ public class ServiceEndpointResource {
|
||||||
// profile.accessPoints().add(ap);
|
// profile.accessPoints().add(ap);
|
||||||
// registerSE(newResource);
|
// registerSE(newResource);
|
||||||
// return newResource;
|
// return newResource;
|
||||||
registerSE(resourceProfile);
|
registerSE(encryptResource(resourceProfile));
|
||||||
return resourceProfile;
|
return resourceProfile;
|
||||||
}else{
|
}else{
|
||||||
throw new RuntimeException("ServiceEndpoint profile is null or user not enabled");
|
throw new RuntimeException("ServiceEndpoint profile is null or user not enabled");
|
||||||
|
@ -131,6 +131,18 @@ public class ServiceEndpointResource {
|
||||||
}
|
}
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ServiceEndpoint encryptResource(ServiceEndpoint resource) {
|
||||||
|
Group<ServiceEndpoint.AccessPoint> aps=resource.profile().accessPoints();
|
||||||
|
for (ServiceEndpoint.AccessPoint ap : aps){
|
||||||
|
String decrypted =encryptString(ap.password());
|
||||||
|
String user= ap.username();
|
||||||
|
|
||||||
|
ap.credentials(decrypted, user);
|
||||||
|
}
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String decryptString(String toDecrypt){
|
private static String decryptString(String toDecrypt){
|
||||||
try{
|
try{
|
||||||
|
@ -139,6 +151,15 @@ public class ServiceEndpointResource {
|
||||||
throw new RuntimeException("Unable to decrypt : "+toDecrypt,e);
|
throw new RuntimeException("Unable to decrypt : "+toDecrypt,e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String encryptString(String toEncrypt){
|
||||||
|
try{
|
||||||
|
return StringEncrypter.getEncrypter().encrypt(toEncrypt);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException("Unable to encrypt : "+toEncrypt,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<ServiceEndpoint> getServiceEndpoints(boolean isDecrypt, List<ServiceEndpoint> endpoints) {
|
private List<ServiceEndpoint> getServiceEndpoints(boolean isDecrypt, List<ServiceEndpoint> endpoints) {
|
||||||
if (isDecrypt) {
|
if (isDecrypt) {
|
||||||
if (isRoleEnabled()){
|
if (isRoleEnabled()){
|
||||||
|
|
Loading…
Reference in New Issue