use of com.emc.storageos.db.client.model.EncryptionProvider in project coprhd-controller by CoprHD.
the class StorageOsPlugin method onApplicationStart.
/**
* Called at application start (and at each reloading) Time to start stateful things.
*/
@Override
public void onApplicationStart() {
// NOSONAR
instance = this;
// ("Suppressing Sonar violation of Lazy initialization of static fields should be synchronized for field instance")
if (!isEnabled()) {
return;
}
try {
Logger.info("Connecting to Coordinator Service");
// To using Spring profile feature
context = new GenericXmlApplicationContext();
context.getEnvironment().setActiveProfiles(System.getProperty("buildType"));
context.load(getContextFiles());
context.refresh();
Logger.info("Connected to Coordinator Service");
zkConnection = getBean("zkconn", ZkConnection.class);
coordinatorClient = getBean("coordinator", CoordinatorClient.class);
encryptionProvider = getBean("encryptionProvider", EncryptionProvider.class);
authSvcEndPointLocator = getBean("authSvcEndpointLocator", AuthSvcEndPointLocator.class);
Validator.setAuthSvcEndPointLocator(authSvcEndPointLocator);
Validator.setCoordinator(coordinatorClient);
// need reference to local-security-conf.xml to load this
Validator.setStorageOSUserRepository(null);
coordinatorClient.start();
encryptionProvider.start();
Logger.info("Started ViPR connection, version: %s", version);
KeyStoreExporter keystoreExporter = getBean("keystoreExporter", KeyStoreExporter.class);
keystoreExporter.export();
// register node listener for catalog acl change
coordinatorClient.addNodeListener(new CatalogAclListener());
Logger.info("added CatalogAclListener");
} catch (Exception e) {
Logger.error(e, "Error initializing ViPR Connection");
shutdown();
}
}
use of com.emc.storageos.db.client.model.EncryptionProvider in project coprhd-controller by CoprHD.
the class ImageServerControllerImpl method decryptImageURLPassword.
/**
* Method to decrypt the imageURL password before it can be used.
* This method also takes care of encoding the password before use.
* @param imageUrl {@link String} compute image URL string
* @return {@link String}
*/
private String decryptImageURLPassword(String imageUrl) {
String password = extractPasswordFromImageUrl(imageUrl);
if (StringUtils.isNotBlank(password)) {
String encPwd = null;
try {
EncryptionProviderImpl encryptionProviderImpl = new EncryptionProviderImpl();
encryptionProviderImpl.setCoordinator(_coordinator);
encryptionProviderImpl.start();
EncryptionProvider encryptionProvider = encryptionProviderImpl;
encPwd = URLEncoder.encode(encryptionProvider.decrypt(Base64.decodeBase64(password)), "UTF-8");
return StringUtils.replace(imageUrl, ":" + password + "@", ":" + encPwd + "@");
} catch (UnsupportedEncodingException e) {
log.warn("Unable to encode compute image password '{}'." + "Special characters may cause issues loading compute image.", imageUrl, e.getMessage());
} catch (Exception e) {
log.error("Cannot decrypt compute image password :" + e.getLocalizedMessage());
e.printStackTrace();
throw e;
}
}
return imageUrl;
}
use of com.emc.storageos.db.client.model.EncryptionProvider in project coprhd-controller by CoprHD.
the class ComputeImageService method encryptImageURLPassword.
/**
* Method to mask/encrypt password of the ImageUrl
* @param imageUrl {@link String} compute image URL string
* @param isEncrypted boolean indicating if password is already encrypted.
* @return
*/
private String encryptImageURLPassword(String imageUrl, boolean isEncrypted) {
String password = ImageServerControllerImpl.extractPasswordFromImageUrl(imageUrl);
String encryptedPassword = password;
if (!isEncrypted && StringUtils.isNotBlank(password)) {
EncryptionProviderImpl encryptionProviderImpl = new EncryptionProviderImpl();
encryptionProviderImpl.setCoordinator(_coordinator);
encryptionProviderImpl.start();
EncryptionProvider encryptionProvider = encryptionProviderImpl;
encryptedPassword = encryptionProvider.getEncryptedString(password);
imageUrl = StringUtils.replace(imageUrl, ":" + password + "@", ":" + encryptedPassword + "@");
}
return imageUrl;
}
Aggregations