use of org.spongycastle.asn1.ASN1InputStream in project robovm by robovm.
the class NetscapeCertRequest method getKeySpec.
private ASN1Primitive getKeySpec() throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ASN1Primitive obj = null;
try {
baos.write(pubkey.getEncoded());
baos.close();
ASN1InputStream derin = new ASN1InputStream(new ByteArrayInputStream(baos.toByteArray()));
obj = derin.readObject();
} catch (IOException ioe) {
throw new InvalidKeySpecException(ioe.getMessage());
}
return obj;
}
use of org.spongycastle.asn1.ASN1InputStream in project robovm by robovm.
the class X509CertificateObject method getExtendedKeyUsage.
public List getExtendedKeyUsage() throws CertificateParsingException {
byte[] bytes = this.getExtensionBytes("2.5.29.37");
if (bytes != null) {
try {
ASN1InputStream dIn = new ASN1InputStream(bytes);
ASN1Sequence seq = (ASN1Sequence) dIn.readObject();
List list = new ArrayList();
for (int i = 0; i != seq.size(); i++) {
list.add(((ASN1ObjectIdentifier) seq.getObjectAt(i)).getId());
}
return Collections.unmodifiableList(list);
} catch (Exception e) {
throw new CertificateParsingException("error processing extended key usage extension");
}
}
return null;
}
use of org.spongycastle.asn1.ASN1InputStream in project robovm by robovm.
the class PKCS12BagAttributeCarrierImpl method readObject.
public void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
Object obj = in.readObject();
if (obj instanceof Hashtable) {
this.pkcs12Attributes = (Hashtable) obj;
this.pkcs12Ordering = (Vector) in.readObject();
} else {
ASN1InputStream aIn = new ASN1InputStream((byte[]) obj);
ASN1ObjectIdentifier oid;
while ((oid = (ASN1ObjectIdentifier) aIn.readObject()) != null) {
this.setBagAttribute(oid, aIn.readObject());
}
}
}
use of org.spongycastle.asn1.ASN1InputStream in project robovm by robovm.
the class PEMUtil method readPEMObject.
ASN1Sequence readPEMObject(InputStream in) throws IOException {
String line;
StringBuffer pemBuf = new StringBuffer();
while ((line = readLine(in)) != null) {
if (line.startsWith(_header1) || line.startsWith(_header2)) {
break;
}
}
while ((line = readLine(in)) != null) {
if (line.startsWith(_footer1) || line.startsWith(_footer2)) {
break;
}
pemBuf.append(line);
}
if (pemBuf.length() != 0) {
ASN1Primitive o = new ASN1InputStream(Base64.decode(pemBuf.toString())).readObject();
if (!(o instanceof ASN1Sequence)) {
throw new IOException("malformed PEM data encountered");
}
return (ASN1Sequence) o;
}
return null;
}
use of org.spongycastle.asn1.ASN1InputStream in project robovm by robovm.
the class X509CRLObject method toString.
/**
* Returns a string representation of this CRL.
*
* @return a string representation of this CRL.
*/
public String toString() {
StringBuffer buf = new StringBuffer();
String nl = System.getProperty("line.separator");
buf.append(" Version: ").append(this.getVersion()).append(nl);
buf.append(" IssuerDN: ").append(this.getIssuerDN()).append(nl);
buf.append(" This update: ").append(this.getThisUpdate()).append(nl);
buf.append(" Next update: ").append(this.getNextUpdate()).append(nl);
buf.append(" Signature Algorithm: ").append(this.getSigAlgName()).append(nl);
byte[] sig = this.getSignature();
buf.append(" Signature: ").append(new String(Hex.encode(sig, 0, 20))).append(nl);
for (int i = 20; i < sig.length; i += 20) {
if (i < sig.length - 20) {
buf.append(" ").append(new String(Hex.encode(sig, i, 20))).append(nl);
} else {
buf.append(" ").append(new String(Hex.encode(sig, i, sig.length - i))).append(nl);
}
}
Extensions extensions = c.getTBSCertList().getExtensions();
if (extensions != null) {
Enumeration e = extensions.oids();
if (e.hasMoreElements()) {
buf.append(" Extensions: ").append(nl);
}
while (e.hasMoreElements()) {
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) e.nextElement();
Extension ext = extensions.getExtension(oid);
if (ext.getExtnValue() != null) {
byte[] octs = ext.getExtnValue().getOctets();
ASN1InputStream dIn = new ASN1InputStream(octs);
buf.append(" critical(").append(ext.isCritical()).append(") ");
try {
if (oid.equals(Extension.cRLNumber)) {
buf.append(new CRLNumber(ASN1Integer.getInstance(dIn.readObject()).getPositiveValue())).append(nl);
} else if (oid.equals(Extension.deltaCRLIndicator)) {
buf.append("Base CRL: " + new CRLNumber(ASN1Integer.getInstance(dIn.readObject()).getPositiveValue())).append(nl);
} else if (oid.equals(Extension.issuingDistributionPoint)) {
buf.append(IssuingDistributionPoint.getInstance(dIn.readObject())).append(nl);
} else if (oid.equals(Extension.cRLDistributionPoints)) {
buf.append(CRLDistPoint.getInstance(dIn.readObject())).append(nl);
} else if (oid.equals(Extension.freshestCRL)) {
buf.append(CRLDistPoint.getInstance(dIn.readObject())).append(nl);
} else {
buf.append(oid.getId());
buf.append(" value = ").append(ASN1Dump.dumpAsString(dIn.readObject())).append(nl);
}
} catch (Exception ex) {
buf.append(oid.getId());
buf.append(" value = ").append("*****").append(nl);
}
} else {
buf.append(nl);
}
}
}
Set set = getRevokedCertificates();
if (set != null) {
Iterator it = set.iterator();
while (it.hasNext()) {
buf.append(it.next());
buf.append(nl);
}
}
return buf.toString();
}
Aggregations