当前位置: 首页>>代码示例>>Java>>正文


Java Authorization.getStatus方法代码示例

本文整理汇总了Java中org.shredzone.acme4j.Authorization.getStatus方法的典型用法代码示例。如果您正苦于以下问题:Java Authorization.getStatus方法的具体用法?Java Authorization.getStatus怎么用?Java Authorization.getStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.shredzone.acme4j.Authorization的用法示例。


在下文中一共展示了Authorization.getStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: orderCertificate

import org.shredzone.acme4j.Authorization; //导入方法依赖的package包/类
/**
 * Runs the complete process of ordering a certificate.
 *
 * @param domain
 *            Name of the domain to order a certificate for
 * @param validator
 *            {@link Validator} that finds and prepares a {@link Challenge} for domain
 *            validation
 */
private void orderCertificate(String domain, Validator validator) throws Exception {
    KeyPair keyPair = createKeyPair();
    Session session = new Session(pebbleURI(), keyPair);

    Account account = new AccountBuilder()
                .agreeToTermsOfService()
                .create(session);

    KeyPair domainKeyPair = createKeyPair();

    Instant notBefore = Instant.now().truncatedTo(ChronoUnit.MILLIS);
    Instant notAfter = notBefore.plus(Duration.ofDays(20L));

    Order order = account.newOrder()
                .domain(domain)
                .notBefore(notBefore)
                .notAfter(notAfter)
                .create();
    assertThat(order.getNotBefore(), is(notBefore));
    assertThat(order.getNotAfter(), is(notAfter));
    assertThat(order.getStatus(), is(Status.PENDING));

    for (Authorization auth : order.getAuthorizations()) {
        assertThat(auth.getDomain(), is(domain));
        assertThat(auth.getStatus(), is(Status.PENDING));

        Challenge challenge = validator.prepare(auth);
        challenge.trigger();

        await()
            .pollInterval(1, SECONDS)
            .timeout(30, SECONDS)
            .conditionEvaluationListener(cond -> updateAuth(auth))
            .until(auth::getStatus, not(isOneOf(Status.PENDING, Status.PROCESSING)));

        if (auth.getStatus() != Status.VALID) {
            fail("Authorization failed");
        }
    }

    CSRBuilder csr = new CSRBuilder();
    csr.addDomain(domain);
    csr.sign(domainKeyPair);
    byte[] encodedCsr = csr.getEncoded();

    order.execute(encodedCsr);

    await()
        .pollInterval(1, SECONDS)
        .timeout(30, SECONDS)
        .conditionEvaluationListener(cond -> updateOrder(order))
        .until(order::getStatus, not(isOneOf(Status.PENDING, Status.PROCESSING)));


    Certificate certificate = order.getCertificate();
    X509Certificate cert = certificate.getCertificate();
    assertThat(cert, not(nullValue()));
    assertThat(cert.getNotAfter(), not(nullValue()));
    assertThat(cert.getNotBefore(), not(nullValue()));
    assertThat(cert.getSubjectX500Principal().getName(), containsString("CN=" + domain));
}
 
开发者ID:shred,项目名称:acme4j,代码行数:71,代码来源:OrderIT.java

示例2: testDnsValidation

import org.shredzone.acme4j.Authorization; //导入方法依赖的package包/类
/**
 * Test if a wildcard certificate can be ordered via dns-01 challenge.
 */
@Test
public void testDnsValidation() throws Exception {
    BammBammClient client = getBammBammClient();
    KeyPair keyPair = createKeyPair();
    Session session = new Session(pebbleURI(), keyPair);

    Account account = new AccountBuilder()
                .agreeToTermsOfService()
                .create(session);

    KeyPair domainKeyPair = createKeyPair();

    Instant notBefore = Instant.now().truncatedTo(ChronoUnit.MILLIS);
    Instant notAfter = notBefore.plus(Duration.ofDays(20L));

    Order order = account.newOrder()
                .domain(TEST_WILDCARD_DOMAIN)
                .domain(TEST_DOMAIN)
                .notBefore(notBefore)
                .notAfter(notAfter)
                .create();
    assertThat(order.getNotBefore(), is(notBefore));
    assertThat(order.getNotAfter(), is(notAfter));
    assertThat(order.getStatus(), is(Status.PENDING));

    for (Authorization auth : order.getAuthorizations()) {
        assertThat(auth.getDomain(), is(TEST_DOMAIN));
        assertThat(auth.getStatus(), is(Status.PENDING));

        Dns01Challenge challenge = auth.findChallenge(Dns01Challenge.TYPE);
        assertThat(challenge, is(notNullValue()));

        String challengeDomainName = "_acme-challenge." + TEST_DOMAIN;

        client.dnsAddTxtRecord(challengeDomainName, challenge.getDigest());
        cleanup(() -> client.dnsRemoveTxtRecord(challengeDomainName));

        challenge.trigger();

        await()
            .pollInterval(1, SECONDS)
            .timeout(30, SECONDS)
            .conditionEvaluationListener(cond -> updateAuth(auth))
            .until(auth::getStatus, not(isOneOf(Status.PENDING, Status.PROCESSING)));

        if (auth.getStatus() != Status.VALID) {
            fail("Authorization failed");
        }
    }

    CSRBuilder csr = new CSRBuilder();
    csr.addDomain(TEST_DOMAIN);
    csr.addDomain(TEST_WILDCARD_DOMAIN);
    csr.sign(domainKeyPair);
    byte[] encodedCsr = csr.getEncoded();

    order.execute(encodedCsr);

    await()
        .pollInterval(1, SECONDS)
        .timeout(30, SECONDS)
        .conditionEvaluationListener(cond -> updateOrder(order))
        .until(order::getStatus, not(isOneOf(Status.PENDING, Status.PROCESSING)));


    Certificate certificate = order.getCertificate();
    X509Certificate cert = certificate.getCertificate();
    assertThat(cert, not(nullValue()));
    assertThat(cert.getNotAfter(), not(nullValue()));
    assertThat(cert.getNotBefore(), not(nullValue()));
    assertThat(cert.getSubjectX500Principal().getName(), containsString("CN=" + TEST_DOMAIN));

    List<String> san = cert.getSubjectAlternativeNames().stream()
            .filter(it -> ((Number) it.get(0)).intValue() == GeneralName.dNSName)
            .map(it -> (String) it.get(1))
            .collect(toList());
    assertThat(san, contains(TEST_DOMAIN, TEST_WILDCARD_DOMAIN));
}
 
开发者ID:shred,项目名称:acme4j,代码行数:82,代码来源:OrderWildcardIT.java

示例3: testHttpValidation

import org.shredzone.acme4j.Authorization; //导入方法依赖的package包/类
/**
 * Test if a certificate can be ordered via http-01 challenge.
 */
@Test
public void testHttpValidation() throws Exception {
    KeyPair keyPair = createKeyPair();
    Session session = new Session(boulderURI(), keyPair);

    Account account = new AccountBuilder()
                .agreeToTermsOfService()
                .create(session);

    KeyPair domainKeyPair = createKeyPair();

    Order order = account.newOrder().domain(TEST_DOMAIN).create();

    for (Authorization auth : order.getAuthorizations()) {
        TlsSni02Challenge challenge = auth.findChallenge(TlsSni02Challenge.TYPE);
        assertThat(challenge, is(notNullValue()));

        KeyPair challengeKeyPair = createKeyPair();
        X509Certificate challengeCert = CertificateUtils.createTlsSni02Certificate(challengeKeyPair, challenge.getSubject(), challenge.getSanB());

        client.tlsSniAddCertificate(challenge.getSubject(), challengeKeyPair.getPrivate(), challengeCert);

        challenge.trigger();

        await()
            .pollInterval(1, SECONDS)
            .timeout(30, SECONDS)
            .conditionEvaluationListener(cond -> updateAuth(auth))
            .until(auth::getStatus, not(isOneOf(Status.PENDING, Status.PROCESSING)));

        if (auth.getStatus() != Status.VALID) {
            fail("Authorization failed");
        }

        client.tlsSniRemoveCertificate(challenge.getSubject());
    }

    CSRBuilder csr = new CSRBuilder();
    csr.addDomain(TEST_DOMAIN);
    csr.sign(domainKeyPair);
    byte[] encodedCsr = csr.getEncoded();

    order.execute(encodedCsr);

    await()
        .pollInterval(1, SECONDS)
        .timeout(30, SECONDS)
        .conditionEvaluationListener(cond -> updateOrder(order))
        .until(order::getStatus, not(isOneOf(Status.PENDING, Status.PROCESSING)));

    Certificate certificate = order.getCertificate();
    X509Certificate cert = certificate.getCertificate();
    assertThat(cert, not(nullValue()));
    assertThat(cert.getNotAfter(), not(nullValue()));
    assertThat(cert.getNotBefore(), not(nullValue()));
    assertThat(cert.getSubjectX500Principal().getName(), containsString("CN=" + TEST_DOMAIN));
}
 
开发者ID:shred,项目名称:acme4j,代码行数:61,代码来源:OrderTlsSniIT.java

示例4: testHttpValidation

import org.shredzone.acme4j.Authorization; //导入方法依赖的package包/类
/**
 * Test if a certificate can be ordered via http-01 challenge.
 */
@Test
public void testHttpValidation() throws Exception {
    KeyPair keyPair = createKeyPair();
    Session session = new Session(boulderURI(), keyPair);

    Account account = new AccountBuilder()
                .agreeToTermsOfService()
                .create(session);

    KeyPair domainKeyPair = createKeyPair();

    Order order = account.newOrder().domain(TEST_DOMAIN).create();

    for (Authorization auth : order.getAuthorizations()) {
        Http01Challenge challenge = auth.findChallenge(Http01Challenge.TYPE);
        assertThat(challenge, is(notNullValue()));

        client.httpAddToken(challenge.getToken(), challenge.getAuthorization());

        challenge.trigger();

        await()
            .pollInterval(1, SECONDS)
            .timeout(30, SECONDS)
            .conditionEvaluationListener(cond -> updateAuth(auth))
            .until(auth::getStatus, not(isOneOf(Status.PENDING, Status.PROCESSING)));

        if (auth.getStatus() != Status.VALID) {
            fail("Authorization failed");
        }

        client.httpRemoveToken(challenge.getToken());
    }

    CSRBuilder csr = new CSRBuilder();
    csr.addDomain(TEST_DOMAIN);
    csr.sign(domainKeyPair);
    byte[] encodedCsr = csr.getEncoded();

    order.execute(encodedCsr);

    await()
        .pollInterval(1, SECONDS)
        .timeout(30, SECONDS)
        .conditionEvaluationListener(cond -> updateOrder(order))
        .until(order::getStatus, not(isOneOf(Status.PENDING, Status.PROCESSING)));

    Certificate certificate = order.getCertificate();
    X509Certificate cert = certificate.getCertificate();
    assertThat(cert, not(nullValue()));
    assertThat(cert.getNotAfter(), not(nullValue()));
    assertThat(cert.getNotBefore(), not(nullValue()));
    assertThat(cert.getSubjectX500Principal().getName(), containsString("CN=" + TEST_DOMAIN));
}
 
开发者ID:shred,项目名称:acme4j,代码行数:58,代码来源:OrderHttpIT.java


注:本文中的org.shredzone.acme4j.Authorization.getStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。