use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.
the class Cluster method setCloudbreakPassword.
public void setCloudbreakPassword(String cloudbreakAmbariPassword) {
this.cloudbreakAmbariPassword = new Secret(cloudbreakAmbariPassword);
this.cloudbreakClusterManagerPassword = new Secret(cloudbreakAmbariPassword);
}
use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.
the class Cluster method setSecurityMasterKey.
public void setSecurityMasterKey(String ambariSecurityMasterKey) {
this.ambariSecurityMasterKey = new Secret(ambariSecurityMasterKey);
this.clusterManagerSecurityMasterKey = new Secret(ambariSecurityMasterKey);
}
use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.
the class Cluster method setCloudbreakUser.
public void setCloudbreakUser(String cloudbreakAmbariUser) {
this.cloudbreakAmbariUser = new Secret(cloudbreakAmbariUser);
this.cloudbreakClusterManagerUser = new Secret(cloudbreakAmbariUser);
}
use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method testStack.
private Stack testStack() throws JsonProcessingException {
Stack stack = new Stack();
stack.setResourceCrn(STACK_CRN);
stack.setId(STACK_ID);
stack.setCluster(testCluster());
stack.setGatewayPort(9443);
stack.setClusterProxyRegistered(true);
Cluster cluster = new Cluster();
Gateway gateway = new Gateway();
gateway.setPath("test-cluster");
cluster.setGateway(gateway);
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceGroupType(InstanceGroupType.GATEWAY);
InstanceMetaData primaryInstanceMetaData = new InstanceMetaData();
primaryInstanceMetaData.setPrivateIp(PRIMARY_PRIVATE_IP);
primaryInstanceMetaData.setPublicIp(PRIMARY_PUBLIC_IP);
primaryInstanceMetaData.setInstanceId(PRIMARY_INSTANCE_ID);
primaryInstanceMetaData.setInstanceMetadataType(InstanceMetadataType.GATEWAY_PRIMARY);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setPrivateIp(OTHER_PRIVATE_IP);
instanceMetaData.setPublicIp(OTHER_PUBLIC_IP);
instanceMetaData.setInstanceId(OTHER_INSTANCE_ID);
instanceGroup.setInstanceMetaData(Set.of(instanceMetaData, primaryInstanceMetaData));
stack.setInstanceGroups(Set.of(instanceGroup));
ReflectionTestUtils.setField(cluster, "cloudbreakClusterManagerPassword", new Secret("cloudbreak", vaultSecretString("cbpassword")));
ReflectionTestUtils.setField(cluster, "cloudbreakClusterManagerUser", new Secret("cloudbreak", vaultSecretString("cbuser")));
ReflectionTestUtils.setField(cluster, "cloudbreakAmbariPassword", new Secret("cloudbreak", vaultSecretString("cbpassword")));
ReflectionTestUtils.setField(cluster, "cloudbreakAmbariUser", new Secret("cloudbreak", vaultSecretString("cbuser")));
ReflectionTestUtils.setField(cluster, "dpClusterManagerUser", new Secret("cmmgmt", vaultSecretString("dpuser")));
ReflectionTestUtils.setField(cluster, "dpClusterManagerPassword", new Secret("cmmgmt", vaultSecretString("dppassword")));
ReflectionTestUtils.setField(cluster, "cloudbreakAmbariPassword", new Secret("cmmgmt", vaultSecretString("cbpassword")));
ReflectionTestUtils.setField(cluster, "cloudbreakAmbariUser", new Secret("cmmgmt", vaultSecretString("cbuser")));
stack.setCluster(cluster);
stack.getCluster().setId(1L);
return stack;
}
use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.
the class SecretAspects method proceedSave.
private Object proceedSave(ProceedingJoinPoint proceedingJoinPoint) {
Collection<Object> entities = convertFirstArgToCollection(proceedingJoinPoint);
for (Object entity : entities) {
String tenant = null;
try {
for (Field field : entity.getClass().getDeclaredFields()) {
if (field.isAnnotationPresent(SecretValue.class)) {
LOGGER.debug("Found SecretValue annotation on {}", field);
field.setAccessible(true);
Secret value = (Secret) field.get(entity);
if (value != null && value.getRaw() != null && value.getSecret() == null) {
tenant = Optional.ofNullable(tenant).orElseGet(() -> findTenant(entity));
String path = String.format("%s/%s/%s/%s-%s", tenant, entity.getClass().getSimpleName().toLowerCase(), field.getName().toLowerCase(), UUID.randomUUID().toString(), Long.toHexString(clock.getCurrentTimeMillis()));
String secret = secretService.put(path, value.getRaw());
LOGGER.debug("Field: '{}' is saved at path: {}", field.getName(), path);
field.set(entity, new SecretProxy(secretService, secret));
}
}
}
} catch (IllegalArgumentException e) {
LOGGER.error("Given entity isn't instance of TenantAwareResource or AccountIdAwareResource. Secret is not saved!", e);
throw new CloudbreakServiceException(e);
} catch (Exception e) {
LOGGER.warn("Looks like something went wrong with Secret store. Secret is not saved!", e);
throw new CloudbreakServiceException(e);
}
}
Object proceed;
try {
proceed = proceedingJoinPoint.proceed();
} catch (RuntimeException re) {
LOGGER.warn("Failed to invoke repository save", re);
throw re;
} catch (Throwable throwable) {
LOGGER.error("Failed to invoke repository save", throwable);
throw new CloudbreakServiceException(throwable);
}
return proceed;
}
Aggregations