Search in sources :

Example 1 with Secret

use of io.hops.hopsworks.persistence.entity.user.security.secrets.Secret in project hopsworks by logicalclocks.

the class FeaturestoreRedshiftConnectorController method setPassword.

private void setPassword(Users user, FeaturestoreRedshiftConnectorDTO featurestoreRedshiftConnectorDTO, Featurestore featurestore, FeatureStoreRedshiftConnector featurestoreRedshiftConnector) throws UserException, ProjectException {
    if (!Strings.isNullOrEmpty(featurestoreRedshiftConnectorDTO.getDatabasePassword())) {
        Secret secret = secretsController.createSecretForProject(user, storageConnectorUtil.createSecretName(featurestore.getId(), featurestoreRedshiftConnectorDTO.getName(), featurestoreRedshiftConnectorDTO.getStorageConnectorType()), featurestoreRedshiftConnectorDTO.getDatabasePassword(), featurestore.getProject().getId());
        featurestoreRedshiftConnector.setSecret(secret);
    }
}
Also used : Secret(io.hops.hopsworks.persistence.entity.user.security.secrets.Secret)

Example 2 with Secret

use of io.hops.hopsworks.persistence.entity.user.security.secrets.Secret in project hopsworks by logicalclocks.

the class FeaturestoreRedshiftConnectorController method updateFeaturestoreRedshiftConnector.

@TransactionAttribute(TransactionAttributeType.REQUIRED)
@Transactional(rollbackOn = FeaturestoreException.class)
public FeatureStoreRedshiftConnector updateFeaturestoreRedshiftConnector(Users user, Featurestore featurestore, FeaturestoreRedshiftConnectorDTO featurestoreRedshiftConnectorDTO, FeatureStoreRedshiftConnector featureStoreRedshiftConnector) throws FeaturestoreException, UserException, ProjectException {
    verifyCreateDTO(featurestoreRedshiftConnectorDTO);
    setConnector(featureStoreRedshiftConnector, featurestoreRedshiftConnectorDTO);
    Secret secret = null;
    if (storageConnectorUtil.shouldUpdate(storageConnectorUtil.getSecret(featureStoreRedshiftConnector.getSecret(), String.class), featurestoreRedshiftConnectorDTO.getDatabasePassword())) {
        secret = updatePassword(user, featurestoreRedshiftConnectorDTO, featurestore, featureStoreRedshiftConnector);
    }
    featureStoreRedshiftConnector.setArguments(storageConnectorUtil.fromOptions(featurestoreRedshiftConnectorDTO.getArguments()));
    verifyPassword(featureStoreRedshiftConnector.getIamRole(), featureStoreRedshiftConnector.getSecret());
    if (featureStoreRedshiftConnector.getSecret() == null && secret != null) {
        secretsFacade.deleteSecret(secret.getId());
    }
    return featureStoreRedshiftConnector;
}
Also used : Secret(io.hops.hopsworks.persistence.entity.user.security.secrets.Secret) TransactionAttribute(javax.ejb.TransactionAttribute) Transactional(javax.transaction.Transactional)

Example 3 with Secret

use of io.hops.hopsworks.persistence.entity.user.security.secrets.Secret in project hopsworks by logicalclocks.

the class FeaturestoreS3ConnectorController method updateFeaturestoreS3Connector.

@TransactionAttribute(TransactionAttributeType.REQUIRED)
@Transactional(rollbackOn = { FeaturestoreException.class, UserException.class, ProjectException.class })
public FeaturestoreS3Connector updateFeaturestoreS3Connector(Users user, Featurestore featurestore, FeaturestoreS3ConnectorDTO featurestoreS3ConnectorDTO, FeaturestoreS3Connector featurestoreS3Connector) throws FeaturestoreException, UserException, ProjectException {
    if (storageConnectorUtil.shouldUpdate(featurestoreS3Connector.getBucket(), featurestoreS3ConnectorDTO.getBucket())) {
        verifyS3ConnectorBucket(featurestoreS3ConnectorDTO.getBucket());
        featurestoreS3Connector.setBucket(featurestoreS3ConnectorDTO.getBucket());
    }
    if (storageConnectorUtil.shouldUpdate(featurestoreS3Connector.getIamRole(), featurestoreS3ConnectorDTO.getIamRole())) {
        featurestoreS3Connector.setIamRole(featurestoreS3ConnectorDTO.getIamRole());
    }
    Secret secret = null;
    FeaturestoreS3ConnectorAccessAndSecretKey keys = storageConnectorUtil.getSecret(featurestoreS3Connector.getSecret(), FeaturestoreS3ConnectorAccessAndSecretKey.class);
    if (storageConnectorUtil.shouldUpdate(keys.getAccessKey(), featurestoreS3ConnectorDTO.getAccessKey()) || storageConnectorUtil.shouldUpdate(keys.getSecretKey(), featurestoreS3ConnectorDTO.getSecretKey())) {
        secret = updateSecret(user, featurestoreS3ConnectorDTO, featurestore, featurestoreS3Connector);
    }
    String currentEncryptionAlgorithm = featurestoreS3Connector.getServerEncryptionAlgorithm() != null ? featurestoreS3Connector.getServerEncryptionAlgorithm().getAlgorithm() : null;
    if (storageConnectorUtil.shouldUpdate(currentEncryptionAlgorithm, featurestoreS3ConnectorDTO.getServerEncryptionAlgorithm())) {
        if (featurestoreS3ConnectorDTO.getServerEncryptionAlgorithm() != null) {
            FeaturestoreS3ConnectorEncryptionAlgorithm serverEncryptionAlgorithm = getEncryptionAlgorithm(featurestoreS3ConnectorDTO.getServerEncryptionAlgorithm());
            featurestoreS3Connector.setServerEncryptionAlgorithm(serverEncryptionAlgorithm);
            if (serverEncryptionAlgorithm != null && serverEncryptionAlgorithm.isRequiresKey()) {
                verifyS3ConnectorServerEncryptionKey(featurestoreS3ConnectorDTO.getServerEncryptionKey());
                featurestoreS3Connector.setServerEncryptionKey(featurestoreS3ConnectorDTO.getServerEncryptionKey());
            } else {
                featurestoreS3Connector.setServerEncryptionKey(null);
            }
        } else if (!Strings.isNullOrEmpty(featurestoreS3ConnectorDTO.getServerEncryptionKey())) {
            throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.ILLEGAL_S3_CONNECTOR_SERVER_ENCRYPTION_ALGORITHM, Level.FINE, "Illegal server encryption algorithm, encryption algorithm not provided");
        } else {
            featurestoreS3Connector.setServerEncryptionAlgorithm(null);
            featurestoreS3Connector.setServerEncryptionKey(null);
        }
    }
    // verify if key or iam role is set
    verifyKeyAndIAMRole(featurestoreS3Connector.getIamRole(), featurestoreS3Connector.getSecret());
    if (featurestoreS3Connector.getSecret() == null && secret != null) {
        secretsFacade.deleteSecret(secret.getId());
    }
    return featurestoreS3Connector;
}
Also used : Secret(io.hops.hopsworks.persistence.entity.user.security.secrets.Secret) FeaturestoreS3ConnectorAccessAndSecretKey(io.hops.hopsworks.persistence.entity.featurestore.storageconnector.s3.FeaturestoreS3ConnectorAccessAndSecretKey) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) FeaturestoreS3ConnectorEncryptionAlgorithm(io.hops.hopsworks.persistence.entity.featurestore.storageconnector.s3.FeaturestoreS3ConnectorEncryptionAlgorithm) TransactionAttribute(javax.ejb.TransactionAttribute) Transactional(javax.transaction.Transactional)

Example 4 with Secret

use of io.hops.hopsworks.persistence.entity.user.security.secrets.Secret in project hopsworks by logicalclocks.

the class FeaturestoreS3ConnectorController method setSecret.

private void setSecret(Users user, FeaturestoreS3ConnectorDTO featurestoreS3ConnectorDTO, FeaturestoreS3Connector featurestoreS3Connector, Featurestore featurestore) throws UserException, ProjectException {
    if (keysNotNullOrEmpty(featurestoreS3ConnectorDTO)) {
        String jsonSecretString = createS3AccessAndSecretKeysSecret(featurestoreS3ConnectorDTO.getAccessKey(), featurestoreS3ConnectorDTO.getSecretKey());
        String secretName = storageConnectorUtil.createSecretName(featurestore.getId(), featurestoreS3ConnectorDTO.getName(), featurestoreS3ConnectorDTO.getStorageConnectorType());
        Integer projectId = featurestore.getProject().getId();
        Secret secret = secretsController.createSecretForProject(user, secretName, jsonSecretString, projectId);
        featurestoreS3Connector.setSecret(secret);
    }
}
Also used : Secret(io.hops.hopsworks.persistence.entity.user.security.secrets.Secret)

Example 5 with Secret

use of io.hops.hopsworks.persistence.entity.user.security.secrets.Secret in project hopsworks by logicalclocks.

the class FeaturestoreSnowflakeConnectorController method updateConnector.

@TransactionAttribute(TransactionAttributeType.REQUIRED)
@Transactional(rollbackOn = FeaturestoreException.class)
public FeaturestoreSnowflakeConnector updateConnector(Users user, FeaturestoreSnowflakeConnectorDTO featurestoreSnowflakeConnectorDTO, FeaturestoreSnowflakeConnector snowflakeConnector) throws FeaturestoreException, UserException, ProjectException {
    verifyConnectorDTO(featurestoreSnowflakeConnectorDTO);
    Secret secret = updateSecret(user, featurestoreSnowflakeConnectorDTO, snowflakeConnector);
    setConnector(snowflakeConnector, secret, featurestoreSnowflakeConnectorDTO);
    return snowflakeConnector;
}
Also used : Secret(io.hops.hopsworks.persistence.entity.user.security.secrets.Secret) TransactionAttribute(javax.ejb.TransactionAttribute) Transactional(javax.transaction.Transactional)

Aggregations

Secret (io.hops.hopsworks.persistence.entity.user.security.secrets.Secret)17 UserException (io.hops.hopsworks.exceptions.UserException)6 SecretId (io.hops.hopsworks.persistence.entity.user.security.secrets.SecretId)6 IOException (java.io.IOException)4 GeneralSecurityException (java.security.GeneralSecurityException)4 TransactionAttribute (javax.ejb.TransactionAttribute)4 Transactional (javax.transaction.Transactional)3 HashMap (java.util.HashMap)2 MasterPasswordChangeResult (io.hops.hopsworks.common.security.MasterPasswordChangeResult)1 SymmetricEncryptionDescriptor (io.hops.hopsworks.common.security.SymmetricEncryptionDescriptor)1 EncryptionMasterPasswordException (io.hops.hopsworks.exceptions.EncryptionMasterPasswordException)1 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)1 ProjectException (io.hops.hopsworks.exceptions.ProjectException)1 ServiceException (io.hops.hopsworks.exceptions.ServiceException)1 FeaturestoreADLSConnector (io.hops.hopsworks.persistence.entity.featurestore.storageconnector.adls.FeaturestoreADLSConnector)1 FeaturestoreS3ConnectorAccessAndSecretKey (io.hops.hopsworks.persistence.entity.featurestore.storageconnector.s3.FeaturestoreS3ConnectorAccessAndSecretKey)1 FeaturestoreS3ConnectorEncryptionAlgorithm (io.hops.hopsworks.persistence.entity.featurestore.storageconnector.s3.FeaturestoreS3ConnectorEncryptionAlgorithm)1 FeaturestoreSnowflakeConnector (io.hops.hopsworks.persistence.entity.featurestore.storageconnector.snowflake.FeaturestoreSnowflakeConnector)1 Project (io.hops.hopsworks.persistence.entity.project.Project)1 ProjectTeam (io.hops.hopsworks.persistence.entity.project.team.ProjectTeam)1