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);
}
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);
}
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());
}
}
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();
}
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;
}
Aggregations