Search in sources :

Example 1 with KeyCertificatePairGenerator

use of com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator in project coprhd-controller by CoprHD.

the class KeyCertificatePairGeneratorTest method testVerifyKeyCertificateEntry.

@Test
public void testVerifyKeyCertificateEntry() {
    KeyCertificatePairGenerator gen = new KeyCertificatePairGenerator();
    gen.setKeyCertificateAlgorithmValuesHolder(defaultValues);
    // test a generated entry
    KeyCertificateEntry entry1 = gen.generateKeyCertificatePair();
    try {
        new KeyCertificatePairGenerator().verifyKeyCertificateEntry(entry1);
    } catch (SecurityException e) {
        System.err.println(e.getMessage());
        System.err.println(e);
        Assert.fail();
    } catch (BadRequestException e) {
        System.err.println(e.getMessage());
        System.err.println(e);
        Assert.fail();
    }
    // test values from 2 different generated entries
    KeyCertificateEntry entry2 = gen.generateKeyCertificatePair();
    KeyCertificateEntry hybridEntry = new KeyCertificateEntry(entry1.getKey(), entry2.getCertificateChain());
    boolean exceptionThrown = false;
    try {
        new KeyCertificatePairGenerator().verifyKeyCertificateEntry(hybridEntry);
    } catch (SecurityException e) {
        Assert.fail();
    } catch (BadRequestException e) {
        exceptionThrown = true;
    }
    Assert.assertTrue(exceptionThrown);
}
Also used : KeyCertificatePairGenerator(com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) GeneralSecurityException(java.security.GeneralSecurityException) SecurityException(com.emc.storageos.security.exceptions.SecurityException) KeyCertificateEntry(com.emc.storageos.security.keystore.impl.KeyCertificateEntry) Test(org.junit.Test)

Example 2 with KeyCertificatePairGenerator

use of com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator in project coprhd-controller by CoprHD.

the class KeystoreTest method setup.

@Before
public void setup() throws URISyntaxException, IOException {
    ApplicationContextUtil.initContext(System.getProperty("buildType"), ApplicationContextUtil.SECURITY_CONTEXTS);
    List<URI> uri = new ArrayList<URI>();
    uri.add(URI.create(coordinatorServer));
    ZkConnection connection = new ZkConnection();
    connection.setServer(uri);
    connection.build();
    coordinatorClient.setZkConnection(connection);
    CoordinatorClientInetAddressMap map = new CoordinatorClientInetAddressMap();
    map.setNodeId("standalone");
    DualInetAddress localAddress = DualInetAddress.fromAddresses("127.0.0.1", "::1");
    map.setDualInetAddress(localAddress);
    Map<String, DualInetAddress> controllerNodeIPLookupMap = new HashMap<String, DualInetAddress>();
    controllerNodeIPLookupMap.put("localhost", localAddress);
    map.setControllerNodeIPLookupMap(controllerNodeIPLookupMap);
    coordinatorClient.setInetAddessLookupMap(map);
    coordinatorClient.start();
    FileInputStream is = new FileInputStream(defaultOvfPropsLocation);
    Properties defaultProp = new Properties();
    defaultProp.load(is);
    is.close();
    is = new FileInputStream(ovfPropsLocation);
    Properties ovfProps = new Properties();
    ovfProps.load(is);
    is.close();
    CoordinatorClientImpl.setDefaultProperties(defaultProp);
    CoordinatorClientImpl.setOvfProperties(ovfProps);
    loadStoreParam = new DistributedLoadKeyStoreParam();
    loadStoreParam.setCoordinator(coordinatorClient);
    invalidLoadStoreParam = new LoadStoreParameter() {

        @Override
        public ProtectionParameter getProtectionParameter() {
            return null;
        }
    };
    gen = new KeyCertificatePairGenerator();
    KeyCertificateAlgorithmValuesHolder values = new KeyCertificateAlgorithmValuesHolder(coordinatorClient);
    gen.setKeyCertificateAlgorithmValuesHolder(values);
}
Also used : HashMap(java.util.HashMap) DistributedLoadKeyStoreParam(com.emc.storageos.security.keystore.impl.DistributedLoadKeyStoreParam) ArrayList(java.util.ArrayList) Properties(java.util.Properties) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) FileInputStream(java.io.FileInputStream) LoadStoreParameter(java.security.KeyStore.LoadStoreParameter) KeyCertificateAlgorithmValuesHolder(com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder) KeyCertificatePairGenerator(com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) ProtectionParameter(java.security.KeyStore.ProtectionParameter) Before(org.junit.Before)

Example 3 with KeyCertificatePairGenerator

use of com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator in project coprhd-controller by CoprHD.

the class ProtocolSocketFactoryTest method setup.

@Before
public void setup() throws Exception {
    ApplicationContextUtil.initContext(System.getProperty("buildType"), ApplicationContextUtil.SECURITY_CONTEXTS);
    List<URI> uri = new ArrayList<URI>();
    uri.add(URI.create(coordinatorServer));
    ZkConnection connection = new ZkConnection();
    connection.setServer(uri);
    connection.build();
    coordinatorClient.setZkConnection(connection);
    CoordinatorClientInetAddressMap map = new CoordinatorClientInetAddressMap();
    map.setNodeId("standalone");
    DualInetAddress localAddress = DualInetAddress.fromAddresses("127.0.0.1", "::1");
    map.setDualInetAddress(localAddress);
    Map<String, DualInetAddress> controllerNodeIPLookupMap = new HashMap<String, DualInetAddress>();
    controllerNodeIPLookupMap.put("localhost", localAddress);
    map.setControllerNodeIPLookupMap(controllerNodeIPLookupMap);
    coordinatorClient.setInetAddessLookupMap(map);
    coordinatorClient.start();
    FileInputStream is = new FileInputStream(defaultOvfPropsLocation);
    Properties defaultProp = new Properties();
    defaultProp.load(is);
    is.close();
    is = new FileInputStream(ovfPropsLocation);
    Properties ovfProps = new Properties();
    ovfProps.load(is);
    is.close();
    CoordinatorClientImpl.setDefaultProperties(defaultProp);
    CoordinatorClientImpl.setOvfProperties(ovfProps);
    ks = KeyStoreUtil.getViPRKeystore(coordinatorClient);
    KeyCertificatePairGenerator gen = new KeyCertificatePairGenerator();
    gen.setKeyCertificateAlgorithmValuesHolder(new KeyCertificateAlgorithmValuesHolder(coordinatorClient));
    entry = gen.generateKeyCertificatePair();
    hostName = System.getenv(KeyCertificatePairGeneratorTest.LOCALHOST_IP);
    if (StringUtils.isBlank(hostName)) {
        hostName = "localhost";
    }
    webServer = new TestWebServer(entry);
    webServer.start();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Properties(java.util.Properties) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) FileInputStream(java.io.FileInputStream) KeyCertificateAlgorithmValuesHolder(com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder) KeyCertificatePairGenerator(com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) Before(org.junit.Before)

Example 4 with KeyCertificatePairGenerator

use of com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator in project coprhd-controller by CoprHD.

the class SSLSocketFactoryTest method setup.

@Before
public void setup() throws Exception {
    ApplicationContextUtil.initContext(System.getProperty("buildType"), ApplicationContextUtil.SECURITY_CONTEXTS);
    List<URI> uri = new ArrayList<URI>();
    uri.add(URI.create(coordinatorServer));
    ZkConnection connection = new ZkConnection();
    connection.setServer(uri);
    connection.build();
    coordinatorClient.setZkConnection(connection);
    CoordinatorClientInetAddressMap map = new CoordinatorClientInetAddressMap();
    map.setNodeId("standalone");
    DualInetAddress localAddress = DualInetAddress.fromAddresses("127.0.0.1", "::1");
    map.setDualInetAddress(localAddress);
    Map<String, DualInetAddress> controllerNodeIPLookupMap = new HashMap<String, DualInetAddress>();
    controllerNodeIPLookupMap.put("localhost", localAddress);
    map.setControllerNodeIPLookupMap(controllerNodeIPLookupMap);
    coordinatorClient.setInetAddessLookupMap(map);
    coordinatorClient.start();
    FileInputStream is = new FileInputStream(defaultOvfPropsLocation);
    Properties defaultProp = new Properties();
    defaultProp.load(is);
    is.close();
    is = new FileInputStream(ovfPropsLocation);
    Properties ovfProps = new Properties();
    ovfProps.load(is);
    is.close();
    CoordinatorClientImpl.setDefaultProperties(defaultProp);
    CoordinatorClientImpl.setOvfProperties(ovfProps);
    ks = KeyStoreUtil.getViPRKeystore(coordinatorClient);
    KeyCertificateAlgorithmValuesHolder values = new KeyCertificateAlgorithmValuesHolder(coordinatorClient);
    gen = new KeyCertificatePairGenerator();
    gen.setKeyCertificateAlgorithmValuesHolder(values);
    entry = gen.generateKeyCertificatePair();
    hostName = System.getenv(KeyCertificatePairGeneratorTest.LOCALHOST_IP);
    if (StringUtils.isBlank(hostName)) {
        hostName = "localhost";
    }
    webServer = new TestWebServer(entry);
    webServer.start();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Properties(java.util.Properties) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) FileInputStream(java.io.FileInputStream) KeyCertificateAlgorithmValuesHolder(com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder) KeyCertificatePairGenerator(com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) Before(org.junit.Before)

Example 5 with KeyCertificatePairGenerator

use of com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator in project coprhd-controller by CoprHD.

the class KeyCertificatePairGeneratorTest method testGenerate.

@Test
public void testGenerate() throws GeneralSecurityException, IOException {
    // test the defaults
    KeyCertificatePairGenerator gen = new KeyCertificatePairGenerator();
    gen.setKeyCertificateAlgorithmValuesHolder(defaultValues);
    KeyCertificateEntry pair = gen.generateKeyCertificatePair();
    assertCertInformation((X509Certificate) pair.getCertificateChain()[0], defaultValues);
}
Also used : KeyCertificatePairGenerator(com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator) KeyCertificateEntry(com.emc.storageos.security.keystore.impl.KeyCertificateEntry) Test(org.junit.Test)

Aggregations

KeyCertificatePairGenerator (com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator)8 KeyCertificateAlgorithmValuesHolder (com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder)5 KeyCertificateEntry (com.emc.storageos.security.keystore.impl.KeyCertificateEntry)4 Test (org.junit.Test)4 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)3 DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)3 ZkConnection (com.emc.storageos.coordinator.common.impl.ZkConnection)3 FileInputStream (java.io.FileInputStream)3 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Properties (java.util.Properties)3 Before (org.junit.Before)3 SecurityException (com.emc.storageos.security.exceptions.SecurityException)1 DistributedKeyStoreImpl (com.emc.storageos.security.keystore.impl.DistributedKeyStoreImpl)1 DistributedLoadKeyStoreParam (com.emc.storageos.security.keystore.impl.DistributedLoadKeyStoreParam)1 TrustedCertificateEntry (com.emc.storageos.security.keystore.impl.TrustedCertificateEntry)1 ViPRX509TrustManager (com.emc.storageos.security.ssl.ViPRX509TrustManager)1 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)1 GeneralSecurityException (java.security.GeneralSecurityException)1