Search in sources :

Example 1 with Qualifier

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();
    }
}
Also used : CPSuri(org.mozilla.jss.netscape.security.x509.CPSuri) CertificatePolicyInfo(org.mozilla.jss.netscape.security.x509.CertificatePolicyInfo) PolicyQualifierInfo(org.mozilla.jss.netscape.security.x509.PolicyQualifierInfo) UserNotice(org.mozilla.jss.netscape.security.x509.UserNotice) NoticeReference(org.mozilla.jss.netscape.security.x509.NoticeReference) IOException(java.io.IOException) CRLDistributionPoint(org.mozilla.jss.netscape.security.x509.CRLDistributionPoint) IssuingDistributionPoint(org.mozilla.jss.netscape.security.x509.IssuingDistributionPoint) DisplayText(org.mozilla.jss.netscape.security.x509.DisplayText) Qualifier(org.mozilla.jss.netscape.security.x509.Qualifier) CertificatePoliciesExtension(org.mozilla.jss.netscape.security.x509.CertificatePoliciesExtension) Vector(java.util.Vector) PolicyQualifiers(org.mozilla.jss.netscape.security.x509.PolicyQualifiers)

Example 2 with Qualifier

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());
    }
}
Also used : Digest(build.bazel.remote.execution.v2.Digest) Qualifier(build.bazel.remote.asset.v1.Qualifier) RequestMetadata(build.bazel.remote.execution.v2.RequestMetadata)

Aggregations

Qualifier (build.bazel.remote.asset.v1.Qualifier)1 Digest (build.bazel.remote.execution.v2.Digest)1 RequestMetadata (build.bazel.remote.execution.v2.RequestMetadata)1 IOException (java.io.IOException)1 Vector (java.util.Vector)1 CPSuri (org.mozilla.jss.netscape.security.x509.CPSuri)1 CRLDistributionPoint (org.mozilla.jss.netscape.security.x509.CRLDistributionPoint)1 CertificatePoliciesExtension (org.mozilla.jss.netscape.security.x509.CertificatePoliciesExtension)1 CertificatePolicyInfo (org.mozilla.jss.netscape.security.x509.CertificatePolicyInfo)1 DisplayText (org.mozilla.jss.netscape.security.x509.DisplayText)1 IssuingDistributionPoint (org.mozilla.jss.netscape.security.x509.IssuingDistributionPoint)1 NoticeReference (org.mozilla.jss.netscape.security.x509.NoticeReference)1 PolicyQualifierInfo (org.mozilla.jss.netscape.security.x509.PolicyQualifierInfo)1 PolicyQualifiers (org.mozilla.jss.netscape.security.x509.PolicyQualifiers)1 Qualifier (org.mozilla.jss.netscape.security.x509.Qualifier)1 UserNotice (org.mozilla.jss.netscape.security.x509.UserNotice)1