Search in sources :

Example 6 with EncryptionProviderImpl

use of com.emc.storageos.db.client.impl.EncryptionProviderImpl 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;
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) EncryptionProvider(com.emc.storageos.db.client.model.EncryptionProvider) EncryptionProviderImpl(com.emc.storageos.db.client.impl.EncryptionProviderImpl) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) ImageServerControllerException(com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException)

Example 7 with EncryptionProviderImpl

use of com.emc.storageos.db.client.impl.EncryptionProviderImpl 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;
}
Also used : EncryptionProvider(com.emc.storageos.db.client.model.EncryptionProvider) EncryptionProviderImpl(com.emc.storageos.db.client.impl.EncryptionProviderImpl)

Aggregations

EncryptionProviderImpl (com.emc.storageos.db.client.impl.EncryptionProviderImpl)7 DbVersionInfo (com.emc.storageos.coordinator.client.model.DbVersionInfo)2 EncryptionProvider (com.emc.storageos.db.client.model.EncryptionProvider)2 URI (java.net.URI)2 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)1 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)1 DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)1 Configuration (com.emc.storageos.coordinator.common.Configuration)1 ServiceImpl (com.emc.storageos.coordinator.common.impl.ServiceImpl)1 DbClientContext (com.emc.storageos.db.client.impl.DbClientContext)1 DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)1 ComputeImage (com.emc.storageos.db.client.model.ComputeImage)1 ComputeImageServer (com.emc.storageos.db.client.model.ComputeImageServer)1 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)1 DataObjectScanner (com.emc.storageos.db.common.DataObjectScanner)1 DbServiceStatusChecker (com.emc.storageos.db.common.DbServiceStatusChecker)1 MigrationHandlerImpl (com.emc.storageos.db.server.impl.MigrationHandlerImpl)1 SchemaUtil (com.emc.storageos.db.server.impl.SchemaUtil)1 InternalDbService (com.emc.storageos.db.server.upgrade.util.InternalDbService)1 StubBeaconImpl (com.emc.storageos.db.server.util.StubBeaconImpl)1