Search in sources :

Example 16 with ProxyConfig

use of com.sequenceiq.cloudbreak.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyConfigProviderTest method testWithoutAuthPasswordSetProxy.

@Test
public void testWithoutAuthPasswordSetProxy() {
    ProxyConfig proxyConfig = new ProxyConfig();
    proxyConfig.setPassword("test");
    Map<String, Object> properties = testProxyCore(proxyConfig);
    assertFalse(properties.containsKey("user"));
    assertFalse(properties.containsKey("password"));
}
Also used : ProxyConfig(com.sequenceiq.cloudbreak.domain.ProxyConfig) Test(org.junit.Test)

Example 17 with ProxyConfig

use of com.sequenceiq.cloudbreak.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyConfigProvider method decoratePillarWithProxyDataIfNeeded.

@Transactional
public void decoratePillarWithProxyDataIfNeeded(Map<String, SaltPillarProperties> servicePillar, Cluster cluster) {
    ProxyConfig proxyConfig = cluster.getProxyConfig();
    if (proxyConfig != null) {
        Map<String, Object> proxy = new HashMap<>();
        proxy.put("host", proxyConfig.getServerHost());
        proxy.put("port", proxyConfig.getServerPort());
        proxy.put("protocol", proxyConfig.getProtocol());
        if (StringUtils.isNotBlank(proxyConfig.getUserName()) && StringUtils.isNotBlank(proxyConfig.getPassword())) {
            proxy.put("user", proxyConfig.getUserName());
            proxy.put("password", proxyConfig.getPassword());
        }
        servicePillar.put(PROXY_KEY, new SaltPillarProperties(PROXY_SLS_PATH, singletonMap(PROXY_KEY, proxy)));
    }
}
Also used : HashMap(java.util.HashMap) ProxyConfig(com.sequenceiq.cloudbreak.domain.ProxyConfig) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Transactional(javax.transaction.Transactional)

Example 18 with ProxyConfig

use of com.sequenceiq.cloudbreak.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyConfigService method getPrivateProxyConfig.

public ProxyConfig getPrivateProxyConfig(String name, IdentityUser user) {
    ProxyConfig proxyConfig = proxyConfigRepository.findByNameAndOwner(name, user.getUserId());
    if (proxyConfig == null) {
        throw new NotFoundException(String.format("Proxy configuration '%s' not found.", name));
    }
    authorizationService.hasReadPermission(proxyConfig);
    return proxyConfig;
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) ProxyConfig(com.sequenceiq.cloudbreak.domain.ProxyConfig)

Example 19 with ProxyConfig

use of com.sequenceiq.cloudbreak.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyConfigService method getPublicProxyConfig.

public ProxyConfig getPublicProxyConfig(String name, IdentityUser user) {
    ProxyConfig proxyConfig = proxyConfigRepository.findByNameAndAccount(name, user.getAccount());
    if (proxyConfig == null) {
        throw new NotFoundException(String.format("Proxy configuration '%s' not found.", name));
    }
    authorizationService.hasReadPermission(proxyConfig);
    return proxyConfig;
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) ProxyConfig(com.sequenceiq.cloudbreak.domain.ProxyConfig)

Aggregations

ProxyConfig (com.sequenceiq.cloudbreak.domain.ProxyConfig)19 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)5 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)5 Test (org.junit.Test)4 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 ProxyConfigRequest (com.sequenceiq.cloudbreak.api.model.proxy.ProxyConfigRequest)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)1 HashMap (java.util.HashMap)1 Transactional (javax.transaction.Transactional)1 Before (org.junit.Before)1