use of build.bazel.remote.asset.v1.Qualifier in project jss by dogtagpki.
the class ExtPrettyPrint method getCertificatePoliciesExtension.
private String getCertificatePoliciesExtension() {
StringBuffer sb = new StringBuffer();
try {
sb.append(pp.indent(mIndentSize) + mResource.getString(PrettyPrintResources.TOKEN_IDENTIFIER));
sb.append(mResource.getString(PrettyPrintResources.TOKEN_CERT_POLICIES) + "- " + mExt.getExtensionId().toString() + "\n");
sb.append(pp.indent(mIndentSize + 4) + mResource.getString(PrettyPrintResources.TOKEN_CRITICAL));
if (mExt.isCritical()) {
sb.append(mResource.getString(PrettyPrintResources.TOKEN_YES) + "\n");
} else {
sb.append(mResource.getString(PrettyPrintResources.TOKEN_NO) + "\n");
}
sb.append(pp.indent(mIndentSize + 4) + mResource.getString(PrettyPrintResources.TOKEN_CERT_POLICIES) + "\n");
CertificatePoliciesExtension cp = (CertificatePoliciesExtension) mExt;
@SuppressWarnings("unchecked") Vector<CertificatePolicyInfo> cpv = (Vector<CertificatePolicyInfo>) cp.get("infos");
Enumeration<CertificatePolicyInfo> e = cpv.elements();
if (e != null) {
while (e.hasMoreElements()) {
CertificatePolicyInfo cpi = e.nextElement();
sb.append(pp.indent(mIndentSize + 8) + "Policy Identifier: " + cpi.getPolicyIdentifier().getIdentifier().toString() + "\n");
PolicyQualifiers cpq = cpi.getPolicyQualifiers();
if (cpq != null) {
for (int i = 0; i < cpq.size(); i++) {
PolicyQualifierInfo pq = cpq.getInfoAt(i);
Qualifier q = pq.getQualifier();
if (q instanceof CPSuri) {
sb.append(pp.indent(mIndentSize + 12) + "Policy Qualifier Identifier: CPS Pointer Qualifier - " + pq.getId() + "\n");
sb.append(pp.indent(mIndentSize + 12) + "Policy Qualifier Data: " + ((CPSuri) q).getURI() + "\n");
} else if (q instanceof UserNotice) {
sb.append(pp.indent(mIndentSize + 12) + "Policy Qualifier Identifier: CPS User Notice Qualifier - " + pq.getId() + "\n");
NoticeReference nref = ((UserNotice) q).getNoticeReference();
DisplayText dt = ((UserNotice) q).getDisplayText();
sb.append(pp.indent(mIndentSize + 12) + "Policy Qualifier Data: \n");
if (nref != null) {
sb.append(pp.indent(mIndentSize + 16) + "Organization: " + nref.getOrganization().toString() + "\n");
sb.append(pp.indent(mIndentSize + 16) + "Notice Numbers: ");
int[] nums = nref.getNumbers();
for (int k = 0; k < nums.length; k++) {
if (k != 0) {
sb.append(",");
sb.append(nums[k]);
} else {
sb.append(nums[k]);
}
}
sb.append("\n");
}
if (dt != null) {
sb.append(pp.indent(mIndentSize + 16) + "Explicit Text: " + dt.toString() + "\n");
}
}
}
}
}
}
return sb.toString();
} catch (IOException e) {
return sb.toString();
}
}
use of build.bazel.remote.asset.v1.Qualifier in project bazel-buildfarm by bazelbuild.
the class FetchService method fetchBlob.
private void fetchBlob(Instance instance, FetchBlobRequest request, StreamObserver<FetchBlobResponse> responseObserver) {
Digest expectedDigest = null;
RequestMetadata requestMetadata = TracingMetadataUtils.fromCurrentContext();
if (request.getQualifiersCount() == 0) {
throw Status.INVALID_ARGUMENT.withDescription("Empty qualifier list").asRuntimeException();
}
for (Qualifier qualifier : request.getQualifiersList()) {
String name = qualifier.getName();
if (name.equals("checksum.sri")) {
expectedDigest = parseChecksumSRI(qualifier.getValue());
Digest.Builder result = Digest.newBuilder();
if (instance.containsBlob(expectedDigest, result, requestMetadata)) {
responseObserver.onNext(FetchBlobResponse.newBuilder().setBlobDigest(result.build()).build());
}
} else {
throw Status.INVALID_ARGUMENT.withDescription(format("Invalid qualifier '%s'", name)).asRuntimeException();
}
}
if (request.getUrisCount() != 0) {
addCallback(instance.fetchBlob(request.getUrisList(), expectedDigest, requestMetadata), new FutureCallback<Digest>() {
@Override
public void onSuccess(Digest actualDigest) {
logger.log(Level.INFO, format("fetch blob succeeded: %s inserted into CAS", DigestUtil.toString(actualDigest)));
responseObserver.onNext(FetchBlobResponse.newBuilder().setBlobDigest(actualDigest).build());
responseObserver.onCompleted();
}
@SuppressWarnings("NullableProblems")
@Override
public void onFailure(Throwable t) {
// handle NoSuchFileException
logger.log(Level.SEVERE, "fetch blob failed", t);
responseObserver.onError(t);
}
}, directExecutor());
} else {
responseObserver.onError(Status.INVALID_ARGUMENT.withDescription("Empty uris list").asRuntimeException());
}
}
Aggregations