Search in sources :

Example 6 with SecurityConfig

use of org.apache.hadoop.hdds.security.x509.SecurityConfig in project ozone by apache.

the class TestDefaultCAServer method testInit.

@Test
public void testInit() throws SCMSecurityException, CertificateException, IOException {
    SecurityConfig securityConfig = new SecurityConfig(conf);
    CertificateServer testCA = new DefaultCAServer("testCA", RandomStringUtils.randomAlphabetic(4), RandomStringUtils.randomAlphabetic(4), caStore, new DefaultProfile(), Paths.get(SCM_CA_CERT_STORAGE_DIR, SCM_CA_PATH).toString());
    testCA.init(securityConfig, SELF_SIGNED_CA);
    X509CertificateHolder first = testCA.getCACertificate();
    assertNotNull(first);
    // Init is idempotent.
    testCA.init(securityConfig, SELF_SIGNED_CA);
    X509CertificateHolder second = testCA.getCACertificate();
    assertEquals(first, second);
}
Also used : DefaultProfile(org.apache.hadoop.hdds.security.x509.certificate.authority.PKIProfiles.DefaultProfile) SecurityConfig(org.apache.hadoop.hdds.security.x509.SecurityConfig) X509CertificateHolder(org.bouncycastle.cert.X509CertificateHolder) Test(org.junit.Test)

Example 7 with SecurityConfig

use of org.apache.hadoop.hdds.security.x509.SecurityConfig in project ozone by apache.

the class TestDefaultCAServer method testIntermediaryCAWithEmpty.

@Test(expected = IllegalStateException.class)
public void testIntermediaryCAWithEmpty() throws Exception {
    CertificateServer scmCA = new DefaultCAServer("testCA", RandomStringUtils.randomAlphabetic(4), RandomStringUtils.randomAlphabetic(4), caStore, new DefaultProfile(), Paths.get("scm").toString());
    scmCA.init(new SecurityConfig(conf), INTERMEDIARY_CA);
}
Also used : DefaultProfile(org.apache.hadoop.hdds.security.x509.certificate.authority.PKIProfiles.DefaultProfile) SecurityConfig(org.apache.hadoop.hdds.security.x509.SecurityConfig) Test(org.junit.Test)

Example 8 with SecurityConfig

use of org.apache.hadoop.hdds.security.x509.SecurityConfig in project ozone by apache.

the class TestDefaultCertificateClient method setUp.

@Before
public void setUp() throws Exception {
    OzoneConfiguration config = new OzoneConfiguration();
    config.setStrings(OZONE_SCM_NAMES, "localhost");
    config.setInt(IPC_CLIENT_CONNECT_MAX_RETRIES_KEY, 2);
    final String omPath = GenericTestUtils.getTempPath(UUID.randomUUID().toString());
    final String dnPath = GenericTestUtils.getTempPath(UUID.randomUUID().toString());
    omMetaDirPath = Paths.get(omPath, "test");
    dnMetaDirPath = Paths.get(dnPath, "test");
    config.set(HDDS_METADATA_DIR_NAME, omMetaDirPath.toString());
    omSecurityConfig = new SecurityConfig(config);
    config.set(HDDS_METADATA_DIR_NAME, dnMetaDirPath.toString());
    dnSecurityConfig = new SecurityConfig(config);
    keyGenerator = new HDDSKeyGenerator(omSecurityConfig);
    omKeyCodec = new KeyCodec(omSecurityConfig, OM_COMPONENT);
    dnKeyCodec = new KeyCodec(dnSecurityConfig, DN_COMPONENT);
    Files.createDirectories(omSecurityConfig.getKeyLocation(OM_COMPONENT));
    Files.createDirectories(dnSecurityConfig.getKeyLocation(DN_COMPONENT));
    x509Certificate = generateX509Cert(null);
    certSerialId = x509Certificate.getSerialNumber().toString();
    getCertClient();
}
Also used : HDDSKeyGenerator(org.apache.hadoop.hdds.security.x509.keys.HDDSKeyGenerator) SecurityConfig(org.apache.hadoop.hdds.security.x509.SecurityConfig) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) CertificateCodec.getPEMEncodedString(org.apache.hadoop.hdds.security.x509.certificate.utils.CertificateCodec.getPEMEncodedString) KeyCodec(org.apache.hadoop.hdds.security.x509.keys.KeyCodec) Before(org.junit.Before)

Example 9 with SecurityConfig

use of org.apache.hadoop.hdds.security.x509.SecurityConfig in project ozone by apache.

the class TestCertificateSignRequest method init.

@Before
public void init() throws IOException {
    conf.set(OZONE_METADATA_DIRS, temporaryFolder.newFolder().toString());
    securityConfig = new SecurityConfig(conf);
}
Also used : SecurityConfig(org.apache.hadoop.hdds.security.x509.SecurityConfig) Before(org.junit.Before)

Example 10 with SecurityConfig

use of org.apache.hadoop.hdds.security.x509.SecurityConfig in project ozone by apache.

the class TestKeyCodec method init.

@Before
public void init() throws IOException {
    configuration = new OzoneConfiguration();
    prefix = temporaryFolder.newFolder().toString();
    configuration.set(HDDS_METADATA_DIR_NAME, prefix);
    keyGenerator = new HDDSKeyGenerator(configuration);
    securityConfig = new SecurityConfig(configuration);
    component = "test_component";
}
Also used : SecurityConfig(org.apache.hadoop.hdds.security.x509.SecurityConfig) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Before(org.junit.Before)

Aggregations

SecurityConfig (org.apache.hadoop.hdds.security.x509.SecurityConfig)47 Test (org.junit.Test)25 HDDSKeyGenerator (org.apache.hadoop.hdds.security.x509.keys.HDDSKeyGenerator)18 X509CertificateHolder (org.bouncycastle.cert.X509CertificateHolder)17 Before (org.junit.Before)17 KeyPair (java.security.KeyPair)15 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)15 IOException (java.io.IOException)12 DefaultProfile (org.apache.hadoop.hdds.security.x509.certificate.authority.PKIProfiles.DefaultProfile)11 CertificateCodec (org.apache.hadoop.hdds.security.x509.certificate.utils.CertificateCodec)11 File (java.io.File)9 X509Certificate (java.security.cert.X509Certificate)9 LocalDate (java.time.LocalDate)8 CertificateClient (org.apache.hadoop.hdds.security.x509.certificate.client.CertificateClient)7 KeyCodec (org.apache.hadoop.hdds.security.x509.keys.KeyCodec)7 PKCS10CertificationRequest (org.bouncycastle.pkcs.PKCS10CertificationRequest)7 Path (java.nio.file.Path)5 Date (java.util.Date)5 CertificateClientTestImpl (org.apache.hadoop.ozone.client.CertificateClientTestImpl)5 BeforeClass (org.junit.BeforeClass)5