Search in sources :

Example 1 with EncryptionProvider

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();
    }
}
Also used : AuthSvcEndPointLocator(com.emc.storageos.security.authentication.AuthSvcEndPointLocator) KeyStoreExporter(com.emc.storageos.security.keystore.KeyStoreExporter) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) CatalogAclListener(controllers.util.CatalogAclListener) EncryptionProvider(com.emc.storageos.db.client.model.EncryptionProvider) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection)

Example 2 with EncryptionProvider

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;
}
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 3 with EncryptionProvider

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

Aggregations

EncryptionProvider (com.emc.storageos.db.client.model.EncryptionProvider)3 EncryptionProviderImpl (com.emc.storageos.db.client.impl.EncryptionProviderImpl)2 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)1 ZkConnection (com.emc.storageos.coordinator.common.impl.ZkConnection)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ImageServerControllerException (com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException)1 AuthSvcEndPointLocator (com.emc.storageos.security.authentication.AuthSvcEndPointLocator)1 KeyStoreExporter (com.emc.storageos.security.keystore.KeyStoreExporter)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 CatalogAclListener (controllers.util.CatalogAclListener)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)1