Package com.sonatype.nexus.ssl.client

Examples of com.sonatype.nexus.ssl.client.Certificate


  @Test
  public void createReadDelete()
      throws Exception
  {
    // create a certificate
    final Certificate created = truststore().create()
        .withPem(FileUtils.readFileToString(testData().resolveFile("pem.txt")))
        .save();

    // check there are at list one certificate
    final Collection<Certificate> certificates = truststore().get();
    assertThat(certificates.size(), greaterThan(0));

    // check that we can get the created certificate
    final Certificate updated = truststore().get(created.id());
    assertThat(updated, is(equalTo(created)));

    // remove the certificate
    updated.remove();

    thrown.expect(exceptionWithStatus(Status.NOT_FOUND));

    truststore().get(created.id());
  }
View Full Code Here


    httpServer = Server.withPort(0).withKeystore("keystore", "password").
        serve("/*").withBehaviours(
        Behaviours.get(testData().resolveFile("proxy-repo"))
    ).start();

    final Certificate certificate = certificates().get("localhost", httpServer.getPort());

    assertThat(certificate, is(notNullValue()));
    assertThat(certificate.pem(), is(notNullValue()));
    assertThat(certificate.fingerprint(), is("CB:11:54:75:02:87:33:42:54:33:7D:2E:10:48:D7:4E:AE:BB:5C:90"));
  }
View Full Code Here

        repositories().create(MavenProxyRepository.class, repositoryIdForTest())
            .asProxyOf(httpServer.getUrl().toExternalForm())
            .doNotDownloadRemoteIndexes()
            .save();

    final Certificate certificate = certificates().get(proxyRepository.id());

    assertThat(certificate, is(notNullValue()));
    assertThat(certificate.pem(), is(notNullValue()));
    assertThat(certificate.fingerprint(), is("CB:11:54:75:02:87:33:42:54:33:7D:2E:10:48:D7:4E:AE:BB:5C:90"));
  }
View Full Code Here

        repositories().create(MavenProxyRepository.class, repositoryIdForTest())
            .asProxyOf("https://repository.sonatype.org/content/groups/sonatype-public-grid/")
            .doNotDownloadRemoteIndexes()
            .save();

    final Certificate certificate = certificates().get(proxyRepository.id());

    assertThat(certificate, is(notNullValue()));
    assertThat(certificate.pem(), is(notNullValue()));
    assertThat(certificate.fingerprint(), is("61:96:33:FA:AF:52:1C:EC:D5:97:CF:CC:C3:CE:15:20:F9:CC:22:6B"));
  }
View Full Code Here

   */
  @Test
  public void detailsFromPem()
      throws Exception
  {
    final Certificate certificate = certificates().getDetails(
        FileUtils.readFileToString(testData().resolveFile("pem.txt"))
    );
    assertThat(certificate, is(notNullValue()));
    assertThat(certificate.pem(), is(notNullValue()));
    assertThat(certificate.fingerprint(), is("19:08:03:84:0E:1D:0E:46:05:D4:17:50:5D:A1:FA:34:36:6E:06:C1"));
  }
View Full Code Here

    // sleep for 10 seconds to give time to mail server to startup
    logger.info("Waiting for mail server for 10s");
    Thread.sleep(10000);

    final Certificate certificate = certificates().get(
        "localhost", mailServer.getSmtps().getPort(), ServerSetup.PROTOCOL_SMTPS
    );

    assertThat(certificate, is(notNullValue()));
    assertThat(certificate.pem(), is(notNullValue()));
    assertThat(certificate.fingerprint(), is("F2:E7:5A:B6:BC:46:17:AB:54:8E:6E:35:23:62:6E:38:A5:28:62:D6"));
  }
View Full Code Here

  @Test
  public void delete()
      throws Exception
  {
    role.withPrivilege("ssl-truststore-create").save();
    final Certificate trustedKey = clientForTestUser.getSubsystem(TrustStore.class).create()
        .withPem(FileUtils.readFileToString(testData().resolveFile("pem.txt")))
        .save();

    try {
      trustedKey.remove();
      assertThat("Expected to fail with 403 Forbidden", false);
    }
    catch (UniformInterfaceException e) {
      // expected as user does not have the necessary permissions
      assertThat(e.getResponse().getClientResponseStatus(), Matchers.is(Status.FORBIDDEN));
    }

    role.withPrivilege("ssl-truststore-delete").save();
    trustedKey.remove();
  }
View Full Code Here

TOP

Related Classes of com.sonatype.nexus.ssl.client.Certificate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.