Search in sources :

Example 31 with Sequence

use of com.google.showcase.v1beta1.Sequence in project jss by dogtagpki.

the class ExtendedFailInfo method encode.

@Override
public void encode(Tag implicit, OutputStream ostream) throws IOException {
    SEQUENCE seq = new SEQUENCE();
    seq.addElement(failInfoOID);
    seq.addElement(failInfoValue);
    seq.encode(implicit, ostream);
}
Also used : SEQUENCE(org.mozilla.jss.asn1.SEQUENCE)

Example 32 with Sequence

use of com.google.showcase.v1beta1.Sequence in project jss by dogtagpki.

the class CertResponse method encode.

@Override
public void encode(Tag implicitTag, OutputStream ostream) throws IOException {
    SEQUENCE seq = new SEQUENCE();
    seq.addElement(certReqId);
    seq.addElement(status);
    if (certifiedKeyPair != null) {
        seq.addElement(certifiedKeyPair);
    }
    seq.encode(implicitTag, ostream);
}
Also used : SEQUENCE(org.mozilla.jss.asn1.SEQUENCE)

Example 33 with Sequence

use of com.google.showcase.v1beta1.Sequence in project OpenAM by OpenRock.

the class SecureLogHelperJSSImpl method createBagAttrs.

/**
     * Creates bag attributes.
     * @param nickName The nickname of the key / signature
     * @param localKeyId A hash of the entry to uniquely identify the given
     * key / signature
     * @throws Exception if it fails to generate key identifier
     */
private SET createBagAttrs(String nickName, byte[] localKeyId) throws Exception {
    try {
        SET attrs = new SET();
        SEQUENCE nickNameAttr = new SEQUENCE();
        nickNameAttr.addElement(SafeBag.FRIENDLY_NAME);
        SET nickNameSet = new SET();
        nickNameSet.addElement(new BMPString(nickName));
        nickNameAttr.addElement(nickNameSet);
        attrs.addElement(nickNameAttr);
        SEQUENCE localKeyAttr = new SEQUENCE();
        localKeyAttr.addElement(SafeBag.LOCAL_KEY_ID);
        SET localKeySet = new SET();
        localKeySet.addElement(new OCTET_STRING(localKeyId));
        localKeyAttr.addElement(localKeySet);
        attrs.addElement(localKeyAttr);
        return attrs;
    } catch (Exception e) {
        Debug.error("SecureLogHelper.createBagAttrs() : " + " Exception : ", e);
        throw new Exception("Failed to create Key Bag - " + e.toString());
    }
}
Also used : SET(org.mozilla.jss.asn1.SET) OCTET_STRING(org.mozilla.jss.asn1.OCTET_STRING) SEQUENCE(org.mozilla.jss.asn1.SEQUENCE) BMPString(org.mozilla.jss.asn1.BMPString)

Example 34 with Sequence

use of com.google.showcase.v1beta1.Sequence in project toolkit by googleapis.

the class ShowcaseTest method attemptSequenceTimeoutBackoff.

@Test
public void attemptSequenceTimeoutBackoff() throws Exception {
    // Recreate client with smaller timeout-backoff settings.
    SequenceServiceSettings.Builder builder = seqClient.getSettings().toBuilder();
    builder.attemptSequenceSettings().setRetrySettings(builder.attemptSequenceSettings().retrySettings().setInitialRpcTimeout(org.threeten.bp.Duration.ofSeconds(2L)).setMaxRpcTimeout(org.threeten.bp.Duration.ofSeconds(2L)).build()).build();
    SequenceServiceClient s = SequenceServiceClient.create(builder.build());
    long backendDelaySeconds = 1L;
    Sequence toCreate = Sequence.newBuilder().addResponses(Sequence.Response.newBuilder().setDelay(Duration.newBuilder().setSeconds(backendDelaySeconds)).setStatus(Status.newBuilder().setCode(Code.UNAVAILABLE_VALUE))).addResponses(Sequence.Response.newBuilder().setDelay(Duration.newBuilder().setSeconds(backendDelaySeconds)).setStatus(Status.newBuilder().setCode(Code.UNAVAILABLE_VALUE))).addResponses(Sequence.Response.newBuilder().setStatus(Status.newBuilder().setCode(Code.OK_VALUE))).build();
    Sequence sequence = s.createSequence(toCreate);
    assertThat(sequence.getName()).isNotNull();
    s.attemptSequence(AttemptSequenceRequest.newBuilder().setName(sequence.getName()).build());
    SequenceReport report = s.getSequenceReport(sequence.getName() + "/sequenceReport");
    assertThat(report.getAttemptsList()).isNotNull();
    assertThat(report.getAttemptsList().size()).isEqualTo(3);
    for (int i = 1; i < report.getAttemptsList().size(); i++) {
        SequenceReport.Attempt cur = report.getAttempts(i);
        SequenceReport.Attempt prev = report.getAttempts(i - 1);
        long secondsDiff = Math.abs(cur.getAttemptDeadline().getSeconds() - prev.getAttemptDeadline().getSeconds());
        // The difference in the perceived deadline should be equal to
        // the time it took the server to respond, because a new deadline is set
        // with each attempt based on the *attempt start time*.
        assertThat(secondsDiff).isGreaterThan(0);
        assertThat(secondsDiff).isEqualTo(backendDelaySeconds);
    }
    // clean up extra client
    s.shutdownNow();
}
Also used : SequenceServiceSettings(com.google.showcase.v1beta1.SequenceServiceSettings) SequenceReport(com.google.showcase.v1beta1.SequenceReport) SequenceServiceClient(com.google.showcase.v1beta1.SequenceServiceClient) Sequence(com.google.showcase.v1beta1.Sequence) Test(org.junit.Test)

Example 35 with Sequence

use of com.google.showcase.v1beta1.Sequence in project OpenAM by OpenRock.

the class SecureLogHelperJSSImpl method AddToSecretStore.

/**
     * Adds  secret information to the secret Storage.
     * @param cryptoMaterial : The data to be added
     */
private SEQUENCE AddToSecretStore(byte[] cryptoMaterial, String DataType) throws Exception {
    SEQUENCE encSafeContents = new SEQUENCE();
    ASN1Value data = new OCTET_STRING(cryptoMaterial);
    byte[] localKeyId = createLocalKeyId(cryptoMaterial);
    SET keyAttrs = createBagAttrs(DataType, localKeyId);
    // attributes: user friendly name, Local Key ID
    SafeBag keyBag = new SafeBag(SafeBag.SECRET_BAG, data, keyAttrs);
    encSafeContents.addElement(keyBag);
    return encSafeContents;
}
Also used : ASN1Value(org.mozilla.jss.asn1.ASN1Value) OCTET_STRING(org.mozilla.jss.asn1.OCTET_STRING) SET(org.mozilla.jss.asn1.SET) SEQUENCE(org.mozilla.jss.asn1.SEQUENCE) SafeBag(org.mozilla.jss.pkcs12.SafeBag)

Aggregations

SEQUENCE (org.mozilla.jss.asn1.SEQUENCE)50 OCTET_STRING (org.mozilla.jss.asn1.OCTET_STRING)16 Sequence (org.sbolstandard.core2.Sequence)11 SET (org.mozilla.jss.asn1.SET)9 ANY (org.mozilla.jss.asn1.ANY)8 InvalidBERException (org.mozilla.jss.asn1.InvalidBERException)8 OBJECT_IDENTIFIER (org.mozilla.jss.asn1.OBJECT_IDENTIFIER)8 URI (java.net.URI)7 BMPString (org.mozilla.jss.asn1.BMPString)7 CryptoToken (org.mozilla.jss.crypto.CryptoToken)7 ASN1Value (org.mozilla.jss.asn1.ASN1Value)6 INTEGER (org.mozilla.jss.asn1.INTEGER)6 AuthenticatedSafes (org.mozilla.jss.pkcs12.AuthenticatedSafes)6 FileOutputStream (java.io.FileOutputStream)5 IOException (java.io.IOException)5 SignatureException (java.security.SignatureException)5 EXPLICIT (org.mozilla.jss.asn1.EXPLICIT)5 SafeBag (org.mozilla.jss.pkcs12.SafeBag)5 Certificate (org.mozilla.jss.pkix.cert.Certificate)5 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)5