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);
}
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations