ocspresp.java
来自「内容:基于jdk1.4的加密算法的具体实现」· Java 代码 · 共 109 行
JAVA
109 行
package org.bouncycastle.ocsp;import java.io.ByteArrayInputStream;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.InputStream;import org.bouncycastle.asn1.ASN1InputStream;import org.bouncycastle.asn1.ASN1OutputStream;import org.bouncycastle.asn1.ocsp.BasicOCSPResponse;import org.bouncycastle.asn1.ocsp.OCSPObjectIdentifiers;import org.bouncycastle.asn1.ocsp.OCSPResponse;import org.bouncycastle.asn1.ocsp.ResponseBytes;public class OCSPResp{ private OCSPResponse resp; public OCSPResp( OCSPResponse resp) { this.resp = resp; } public OCSPResp( byte[] resp) throws IOException { this(new ByteArrayInputStream(resp)); } public OCSPResp( InputStream in) throws IOException { this.resp = OCSPResponse.getInstance( new ASN1InputStream(in).readObject()); } public int getStatus() { return this.resp.getResponseStatus().getValue().intValue(); } public Object getResponseObject() throws OCSPException { ResponseBytes rb = this.resp.getResponseBytes(); if (rb == null) { return null; } if (rb.getResponseType().equals(OCSPObjectIdentifiers.id_pkix_ocsp_basic)) { try { ASN1InputStream aIn = new ASN1InputStream( new ByteArrayInputStream(rb.getResponse().getOctets())); return new BasicOCSPResp( BasicOCSPResponse.getInstance(aIn.readObject())); } catch (Exception e) { throw new OCSPException("problem decoding object: " + e, e); } } return rb.getResponse(); } /** * return the ASN.1 encoded representation of this object. */ public byte[] getEncoded() throws IOException { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ASN1OutputStream aOut = new ASN1OutputStream(bOut); aOut.writeObject(resp); return bOut.toByteArray(); } public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof OCSPResp)) { return false; } OCSPResp r = (OCSPResp)o; return resp.equals(r.resp); } public int hashCode() { return resp.hashCode(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?