use of com.github.zhenwei.core.asn1.ocsp.CertID in project jruby-openssl by jruby.
the class OCSPCertificateId method cmp_issuer.
@JRubyMethod(name = "cmp_issuer")
public IRubyObject cmp_issuer(IRubyObject other) {
Ruby runtime = getRuntime();
if (equals(other)) {
return RubyFixnum.zero(runtime);
}
if (other instanceof OCSPCertificateId) {
OCSPCertificateId that = (OCSPCertificateId) other;
CertID thisCert = this.getCertID();
CertID thatCert = that.getCertID();
int ret = thisCert.getHashAlgorithm().getAlgorithm().toString().compareTo(thatCert.getHashAlgorithm().getAlgorithm().toString());
if (ret != 0)
return RubyFixnum.newFixnum(runtime, ret);
ret = thisCert.getIssuerNameHash().toString().compareTo(thatCert.getIssuerNameHash().toString());
if (ret != 0)
return RubyFixnum.newFixnum(runtime, ret);
return RubyFixnum.newFixnum(runtime, thisCert.getIssuerKeyHash().toString().compareTo(thatCert.getIssuerKeyHash().toString()));
} else {
return runtime.getCurrentContext().nil;
}
}
use of com.github.zhenwei.core.asn1.ocsp.CertID in project xipki by xipki.
the class OcspBenchRequestor method buildRequest.
// method ask
private byte[] buildRequest(BigInteger[] serialNumbers) throws OcspRequestorException {
boolean canCache = (serialNumbers.length == 1) && !requestOptions.isUseNonce();
if (canCache) {
byte[] request = requests.get(serialNumbers[0]);
if (request != null) {
return request;
}
}
OCSPReqBuilder reqBuilder = new OCSPReqBuilder();
if (requestOptions.isUseNonce() || extensions != null) {
List<Extension> extns = new ArrayList<>(2);
if (requestOptions.isUseNonce()) {
Extension extn = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(nextNonce(requestOptions.getNonceLen())));
extns.add(extn);
}
if (extensions != null) {
extns.addAll(Arrays.asList(extensions));
}
reqBuilder.setRequestExtensions(new Extensions(extns.toArray(extnType)));
}
try {
for (BigInteger serialNumber : serialNumbers) {
CertID certId = new CertID(issuerhashAlg.getAlgorithmIdentifier(), issuerNameHash, issuerKeyHash, new ASN1Integer(serialNumber));
reqBuilder.addRequest(new CertificateID(certId));
}
byte[] request = reqBuilder.build().getEncoded();
if (canCache) {
requests.put(serialNumbers[0], request);
}
return request;
} catch (OCSPException | IOException ex) {
throw new OcspRequestorException(ex.getMessage(), ex);
}
}
use of com.github.zhenwei.core.asn1.ocsp.CertID in project LinLong-Java by zhenwei1108.
the class SingleResponse method toASN1Primitive.
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* SingleResponse ::= SEQUENCE {
* certID CertID,
* certStatus CertStatus,
* thisUpdate GeneralizedTime,
* nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL,
* singleExtensions [1] EXPLICIT Extensions OPTIONAL }
* </pre>
*/
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector(5);
v.add(certID);
v.add(certStatus);
v.add(thisUpdate);
if (nextUpdate != null) {
v.add(new DERTaggedObject(true, 0, nextUpdate));
}
if (singleExtensions != null) {
v.add(new DERTaggedObject(true, 1, singleExtensions));
}
return new DERSequence(v);
}
use of com.github.zhenwei.core.asn1.ocsp.CertID in project LinLong-Java by zhenwei1108.
the class Request method toASN1Primitive.
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* Request ::= SEQUENCE {
* reqCert CertID,
* singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL }
* </pre>
*/
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector(2);
v.add(reqCert);
if (singleRequestExtensions != null) {
v.add(new DERTaggedObject(true, 0, singleRequestExtensions));
}
return new DERSequence(v);
}
use of com.github.zhenwei.core.asn1.ocsp.CertID in project LinLong-Java by zhenwei1108.
the class OOBCertHash method toASN1Primitive.
/**
* <pre>
* OOBCertHash ::= SEQUENCE {
* hashAlg [0] AlgorithmIdentifier OPTIONAL,
* certId [1] CertId OPTIONAL,
* hashVal BIT STRING
* -- hashVal is calculated over the DER encoding of the
* -- self-signed certificate with the identifier certID.
* }
* </pre>
*
* @return a basic ASN.1 object representation.
*/
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector(3);
addOptional(v, 0, hashAlg);
addOptional(v, 1, certId);
v.add(hashVal);
return new DERSequence(v);
}
Aggregations