List of usage examples for org.bouncycastle.asn1 ASN1Sequence getObjectAt
public ASN1Encodable getObjectAt(int index)
From source file:net.sf.portecle.crypto.X509Ext.java
License:Open Source License
/** * Get Novell Security Attributes (2.16.840.1.113719.1.9.4.1) extension value as a string. * //from w w w.j a v a 2 s . c om * @see <a href="http://developer.novell.com/repository/attributes/">Novell Certificate Extension * Attributes</a> * @param bValue The octet string value * @return Extension value as a string * @throws IOException If an I/O problem occurs */ private String getNovellSecurityAttributesStringValue(byte[] bValue) throws IOException { // TODO... ASN1Sequence attrs = (ASN1Sequence) ASN1Primitive.fromByteArray(bValue); StringBuilder sb = new StringBuilder(); // "Novell Security Attribute(tm)" String sTM = ((ASN1String) attrs.getObjectAt(2)).getString(); sb.append(escapeHtml(sTM)); sb.append("<br>"); // OCTET STRING of size 2, 1st is major version, 2nd is minor version byte[] bVer = ((DEROctetString) attrs.getObjectAt(0)).getOctets(); sb.append("Major version: ").append(Byte.toString(bVer[0])); sb.append(", minor version: ").append(Byte.toString(bVer[1])); sb.append("<br>"); // Nonverified Subscriber Information boolean bNSI = ((ASN1Boolean) attrs.getObjectAt(1)).isTrue(); sb.append("Nonverified Subscriber Information: ").append(bNSI); sb.append("<br>"); // URI reference String sUri = ((ASN1String) attrs.getObjectAt(3)).getString(); sb.append("URI: "); sb.append(getLink(sUri, escapeHtml(sUri), LinkClass.BROWSER)); // GLB Extensions (GLB ~ "Greatest Lower Bound") sb.append("<ul>"); ASN1Sequence glbs = (ASN1Sequence) attrs.getObjectAt(4); sb.append("<li>GLB extensions:<ul>"); /* * TODO: verify that we can do getObjectAt(n) or if we need to examine tag numbers of the tagged * objects */ // Key quality ASN1Sequence keyq = (ASN1Sequence) ((ASN1TaggedObject) glbs.getObjectAt(0)).getObject(); sb.append("<li>").append(RB.getString("NovellKeyQuality")); sb.append("<ul>").append(getNovellQualityAttr(keyq)).append("</ul></li>"); // Crypto process quality ASN1Sequence cpq = (ASN1Sequence) ((ASN1TaggedObject) glbs.getObjectAt(1)).getObject(); sb.append("<li>").append(RB.getString("NovellCryptoProcessQuality")); sb.append("<ul>").append(getNovellQualityAttr(cpq)).append("</ul></li>"); // Certificate class ASN1Sequence cclass = (ASN1Sequence) ((ASN1TaggedObject) glbs.getObjectAt(2)).getObject(); sb.append("<li>").append(RB.getString("NovellCertClass")); sb.append(": "); BigInteger sv = ((ASN1Integer) cclass.getObjectAt(0)).getValue(); String sc = getRes("NovellCertClass." + sv, "UnregocnisedNovellCertClass"); sb.append(MessageFormat.format(sc, sv)); sb.append("</li>"); boolean valid = true; if (cclass.size() > 1) { valid = ((ASN1Boolean) cclass.getObjectAt(1)).isTrue(); } sb.append("<li>"); sb.append(RB.getString("NovellCertClassValid." + valid)); sb.append("</li></ul>"); // Enterprise ID /* * ASN1Sequence eid = (ASN1Sequence) ((ASN1TaggedObject) glbs.getObjectAt(3)).getObject(); * ASN1Sequence rootLabel = (ASN1Sequence) ((ASN1TaggedObject) eid.getObjectAt(0)).getObject(); * ASN1Sequence registryLabel = (ASN1Sequence) ((ASN1TaggedObject) eid.getObjectAt(1)).getObject(); * ASN1Sequence eLabels = (ASN1Sequence) ((ASN1TaggedObject) eid.getObjectAt(2)).getObject(); for (int * i = 0, len = eLabels.size(); i < len; i++) { // Hmm... I thought this would be a sequence of * sequences, // but the following throws a ClassCastException...? // ASN1Sequence eLabel = * (ASN1Sequence) eLabels.getObjectAt(i); } */ sb.append(RB.getString("NovellEnterpriseID")); sb.append(' ').append(RB.getString("DecodeNotImplemented")); // TODO return sb.toString(); }
From source file:net.sf.portecle.crypto.X509Ext.java
License:Open Source License
/** * Gets a Novell quality attribute in a decoded, human readable form. * /* w w w . j av a 2 s. com*/ * @param seq the quality attribute * @return the decoded quality attribute */ private CharSequence getNovellQualityAttr(ASN1Sequence seq) { StringBuilder res = new StringBuilder(); boolean enforceQuality = ((ASN1Boolean) seq.getObjectAt(0)).isTrue(); res.append("<li>").append(RB.getString("NovellQualityEnforce")); res.append(' ').append(enforceQuality).append("</li>"); ASN1Sequence compusecQ = (ASN1Sequence) seq.getObjectAt(1); int clen = compusecQ.size(); if (clen > 0) { res.append("<li>"); res.append(RB.getString("NovellCompusecQuality")); res.append("<ul>"); for (int i = 0; i < clen; i++) { ASN1Sequence cqPair = (ASN1Sequence) compusecQ.getObjectAt(i); ASN1Integer tmp = (ASN1Integer) cqPair.getObjectAt(0); long type = tmp.getValue().longValue(); String csecCriteria = getRes("NovellCompusecQuality." + type, "UnrecognisedNovellCompusecQuality"); csecCriteria = MessageFormat.format(csecCriteria, tmp.getValue()); res.append("<li>").append(csecCriteria); tmp = (ASN1Integer) cqPair.getObjectAt(1); String csecRating; if (type == 1L) { // TCSEC csecRating = getRes("TCSECRating." + tmp.getValue(), "UnrecognisedTCSECRating"); } else { csecRating = RB.getString("UnrecognisedNovellQualityRating"); } csecRating = MessageFormat.format(csecRating, tmp.getValue()); res.append("<ul><li>").append(RB.getString("NovellQualityRating")); res.append(' ').append(csecRating).append("</li></ul>"); res.append("</li>"); } res.append("</ul></li>"); } // ASN1Sequence cryptoQ = (ASN1Sequence) seq.getObjectAt(2); res.append("<li>").append(RB.getString("NovellCryptoQuality")); res.append(' ').append(RB.getString("DecodeNotImplemented")); // TODO res.append("</li>"); /* * TODO for (int i = 0, len = cryptoQ.size(); i < len; i++) { ASN1Sequence cqPair = (ASN1Sequence) * cryptoQ.getObjectAt(i); ASN1Integer cryptoModuleCriteria = (ASN1Integer) cqPair.getObjectAt(0); * ASN1Integer cryptoModuleRating = (ASN1Integer) cqPair.getObjectAt(1); } */ BigInteger ksqv = ((ASN1Integer) seq.getObjectAt(3)).getValue(); String ksq = getRes("NovellKeyStorageQuality." + ksqv, "UnrecognisedNovellKeyStorageQuality"); res.append("<li>").append(RB.getString("NovellKeyStorageQuality")); res.append(": ").append(MessageFormat.format(ksq, ksqv)); res.append("</li>"); return res; }
From source file:net.sf.portecle.crypto.X509Ext.java
License:Open Source License
/** * Get extension value for Certificate Policies as a string. * // w w w .j av a 2s . c o m * @see <a href="http://tools.ietf.org/html/rfc3280">RFC 3280</a> * @param bValue The octet string value * @return Extension value as a string * @throws IOException If an I/O problem occurs */ private String getCertificatePoliciesStringValue(byte[] bValue) throws IOException { ASN1Sequence pSeq = (ASN1Sequence) ASN1Primitive.fromByteArray(bValue); StringBuilder sb = new StringBuilder(); for (int i = 0, len = pSeq.size(); i < len; i++) { PolicyInformation pi = PolicyInformation.getInstance(pSeq.getObjectAt(i)); String piId = pi.getPolicyIdentifier().getId(); sb.append("<ul><li>"); sb.append(RB.getString("PolicyIdentifier")); sb.append(": "); sb.append(MessageFormat.format(getRes(piId, "UnrecognisedPolicyIdentifier"), piId)); ASN1Sequence pQuals; if ((pQuals = pi.getPolicyQualifiers()) != null) { sb.append("<ul>"); for (int j = 0, plen = pQuals.size(); j < plen; j++) { ASN1Sequence pqi = (ASN1Sequence) pQuals.getObjectAt(j); ASN1Encodable pqId = pqi.getObjectAt(0); String spqId = pqId.toString(); sb.append("<li>"); sb.append(MessageFormat.format(getRes(spqId, "UnrecognisedPolicyQualifier"), spqId)); sb.append(": "); ASN1Encodable d = pqi.getObjectAt(1); sb.append("<ul>"); if (pqId.equals(PolicyQualifierId.id_qt_cps)) { // cPSuri String sUri = ((ASN1String) d).getString(); sb.append("<li>"); sb.append(RB.getString("CpsUri")); sb.append(": "); sb.append(getLink(sUri, escapeHtml(sUri), LinkClass.BROWSER)); sb.append("</li>"); } else if (pqId.equals(PolicyQualifierId.id_qt_unotice)) { // userNotice ASN1Sequence un = (ASN1Sequence) d; for (int k = 0, dlen = un.size(); k < dlen; k++) { ASN1Encodable de = un.getObjectAt(k); // TODO: is it possible to use something // smarter than instanceof here? if (de instanceof ASN1String) { // explicitText sb.append("<li>"); sb.append(RB.getString("ExplicitText")); sb.append(": "); sb.append(stringify(de)); sb.append("</li>"); } else if (de instanceof ASN1Sequence) { // noticeRef ASN1Sequence nr = (ASN1Sequence) de; String orgstr = stringify(nr.getObjectAt(0)); ASN1Sequence nrs = (ASN1Sequence) nr.getObjectAt(1); StringBuilder nrstr = new StringBuilder(); for (int m = 0, nlen = nrs.size(); m < nlen; m++) { nrstr.append(stringify(nrs.getObjectAt(m))); if (m != nlen - 1) { nrstr.append(", "); } } sb.append("<li>"); sb.append(RB.getString("NoticeRef")); sb.append(": "); sb.append(RB.getString("NoticeRefOrganization")); sb.append(": "); sb.append(orgstr); sb.append(", "); sb.append(RB.getString("NoticeRefNumber")); sb.append(": "); sb.append(nrstr); sb.append("</li>"); } // else TODO } } else { sb.append(stringify(d)); } sb.append("</ul></li>"); } sb.append("</ul></li>"); } sb.append("</ul>"); if (i != len) { sb.append("<br>"); } } return sb.toString(); }
From source file:net.sf.portecle.crypto.X509Ext.java
License:Open Source License
/** * Get the supplied general name as a string ([general name type]=[general name]). * //from w w w . j ava2s.c o m * <pre> * GeneralName ::= CHOICE { * otherName [0] OtherName, * rfc822Name [1] IA5String, x * dNSName [2] IA5String, x * x400Address [3] ORAddress, * directoryName [4] Name, x * ediPartyName [5] EDIPartyName, * uniformResourceIdentifier [6] IA5String, x * iPAddress [7] OCTET STRING, x * registeredID [8] OBJECT IDENTIFIER x } * OtherName ::= SEQUENCE { * type-id OBJECT IDENTIFIER, * value [0] EXPLICIT ANY DEFINED BY type-id } * EDIPartyName ::= SEQUENCE { * nameAssigner [0] DirectoryString OPTIONAL, * partyName [1] DirectoryString } * DirectoryString ::= CHOICE { * teletexString TeletexString (SIZE (1..maxSize), * printableString PrintableString (SIZE (1..maxSize)), * universalString UniversalString (SIZE (1..maxSize)), * utf8String UTF8String (SIZE (1.. MAX)), * bmpString BMPString (SIZE(1..maxSIZE)) } * </pre> * * @param generalName The general name * @return General name string * @throws IOException */ private String getGeneralNameString(GeneralName generalName, LinkClass linkClass) throws IOException { StringBuilder strBuff = new StringBuilder(); int tagNo = generalName.getTagNo(); switch (tagNo) { case GeneralName.otherName: ASN1Sequence other = (ASN1Sequence) generalName.getName(); String sOid = ((ASN1ObjectIdentifier) other.getObjectAt(0)).getId(); String sVal = stringify(other.getObjectAt(1)); try { strBuff.append(RB.getString(sOid)); } catch (MissingResourceException e) { strBuff.append(MessageFormat.format(RB.getString("GeneralName." + tagNo), sOid)); } strBuff.append(": "); strBuff.append(sVal); break; case GeneralName.rfc822Name: String sRfc822 = generalName.getName().toString(); String urlEnc = URLEncoder.encode(sRfc822, "UTF-8"); strBuff.append(RB.getString("GeneralName." + tagNo)); strBuff.append(": "); strBuff.append(getLink("mailto:" + urlEnc, escapeHtml(sRfc822), null)); break; case GeneralName.dNSName: case GeneralName.registeredID: case GeneralName.x400Address: // TODO: verify formatting case GeneralName.ediPartyName: // TODO: verify formatting strBuff.append(RB.getString("GeneralName." + tagNo)); strBuff.append(": "); strBuff.append(escapeHtml(generalName.getName())); break; case GeneralName.directoryName: ASN1Encodable name = generalName.getName(); strBuff.append(RB.getString("GeneralName." + tagNo)); strBuff.append(": "); // TODO: make E=foo@bar.com mail links strBuff.append(escapeHtml(name)); break; case GeneralName.uniformResourceIdentifier: String sUri = generalName.getName().toString(); strBuff.append(RB.getString("GeneralName." + tagNo)); strBuff.append(": "); strBuff.append(getLink(sUri, escapeHtml(sUri), linkClass)); break; case GeneralName.iPAddress: ASN1OctetString ipAddress = (ASN1OctetString) generalName.getName(); byte[] bIpAddress = ipAddress.getOctets(); // Output the IP Address components one at a time separated by dots StringBuilder sbIpAddress = new StringBuilder(); for (int iCnt = 0, bl = bIpAddress.length; iCnt < bl; iCnt++) { // Convert from (possibly negative) byte to positive int sbIpAddress.append(bIpAddress[iCnt] & 0xFF); if ((iCnt + 1) < bIpAddress.length) { sbIpAddress.append('.'); } } strBuff.append(RB.getString("GeneralName." + tagNo)); strBuff.append(": "); strBuff.append(escapeHtml(sbIpAddress)); break; default: // Unsupported general name type strBuff.append( MessageFormat.format(RB.getString("UnrecognizedGeneralNameType"), generalName.getTagNo())); strBuff.append(": "); strBuff.append(escapeHtml(generalName.getName())); break; } return strBuff.toString(); }
From source file:net.sf.portecle.crypto.X509Ext.java
License:Open Source License
/** * Gets a HTML escaped string representation of the given object. * /* ww w . ja v a 2s . c o m*/ * @param obj Object * @return String representation of <code>obj</code> */ private static String stringify(Object obj) { if (obj instanceof ASN1String) { return escapeHtml(((ASN1String) obj).getString()); } // TODO: why not ASN1Integer as number? else if (obj instanceof ASN1Integer || obj instanceof byte[]) { return convertToHexString(obj); } else if (obj instanceof ASN1TaggedObject) { ASN1TaggedObject tagObj = (ASN1TaggedObject) obj; // Note: "[", _not_ '[' ... return "[" + tagObj.getTagNo() + "] " + stringify(tagObj.getObject()); } else if (obj instanceof ASN1Sequence) { ASN1Sequence aObj = (ASN1Sequence) obj; StringBuilder tmp = new StringBuilder("["); for (int i = 0, len = aObj.size(); i < len; i++) { tmp.append(stringify(aObj.getObjectAt(i))); if (i != len - 1) { tmp.append(", "); } } return tmp.append("]").toString(); } else { String hex = null; try { Method method = obj.getClass().getMethod("getOctets", (Class[]) null); hex = convertToHexString(method.invoke(obj, (Object[]) null)); } catch (Exception e) { // Ignore } if (hex == null && obj != null) { hex = escapeHtml(obj.toString()); } return hex; } }
From source file:net.wstech2.me.httpsclient.CertificateValidatorUtils.java
License:Apache License
/** * /*from ww w .ja v a 2 s . co m*/ * Inspected and display various informations from the Certificate passed as * parameter. Keys are presented in HEX values and ASN1 structures dumped * using ASN1Dump.dumpAsString. * * This method is intended for debug purposes only. * * * @param cert * The X509CertificateStructure to be inspected. * */ public static void dumpCertificateInfo(org.bouncycastle.asn1.x509.Certificate cert) { boolean valid = false; TBSCertificate tbs = cert.getTBSCertificate(); RSAEngine engine = new RSAEngine(); SHA1Digest digest = new SHA1Digest(); GenericSigner signer = new GenericSigner((engine), digest); RSAPublicKey signingKey; try { signingKey = RSAPublicKey.getInstance(cert.getSubjectPublicKeyInfo().parsePublicKey()); HttpsConnectionUtils.logDebug("Public Key:[[" + cert.getSubjectPublicKeyInfo().parsePublicKey() + "]]"); RSAKeyParameters keySpec = new RSAKeyParameters(false, signingKey.getModulus(), signingKey.getPublicExponent()); signer.init(false, keySpec); HttpsConnectionUtils.logDebug("TBS DER object:[[" + tbs.getEncoded("DER") + "]]"); signer.update(tbs.getEncoded(), 0, tbs.getEncoded().length); valid = signer.verifySignature(cert.getSignature().getBytes()); HttpsConnectionUtils.logDebug("signer.verifySignature:[[" + valid + "]]"); SHA1Digest d2 = new SHA1Digest(); d2.update(tbs.getEncoded("DER"), 0, tbs.getEncoded("DER").length); byte[] hash = new byte[d2.getDigestSize()]; d2.doFinal(hash, 0); HttpsConnectionUtils.logDebug("tbs.getDEREncoded() HASH:[[" + new String(Hex.encode(hash)) + "]]"); DEROctetString asn1Hash = new DEROctetString(hash); HttpsConnectionUtils.logDebug( "ASN1 DEROctetString hash:[[" + new String(Hex.encode(asn1Hash.getEncoded("DER"))) + "]]"); d2 = new SHA1Digest(); d2.update(cert.getEncoded(), 0, cert.getEncoded().length); hash = new byte[d2.getDigestSize()]; d2.doFinal(hash, 0); HttpsConnectionUtils.logDebug("cert.getEncoded() HASH:[[" + new String(Hex.encode(hash)) + "]]"); byte[] signature = cert.getSignature().getBytes(); HttpsConnectionUtils .logDebug("cert.getSignature().getBytes():[[" + new String(Hex.encode(signature)) + "]]"); PKCS1Encoding engine2 = new PKCS1Encoding(new RSAEngine()); engine2.init(false, keySpec); byte[] decryptedHash = engine2.processBlock(signature, 0, signature.length); HttpsConnectionUtils.logDebug("decryptedHash:[[" + new String(Hex.encode(decryptedHash)) + "]]"); ASN1Object o = ASN1Primitive.fromByteArray(decryptedHash); HttpsConnectionUtils.logDebug( "decryptedHash.getDEREncoded():[[" + new String(Hex.encode(o.getEncoded("DER"))) + "]]"); HttpsConnectionUtils.logDebug( "ASN1Dump.dumpAsString(decryptedHash,true):[[" + ASN1Dump.dumpAsString(o, true) + "]]"); HttpsConnectionUtils.logDebug("engine.getInputBlockSize():[[" + engine2.getInputBlockSize() + "]]"); HttpsConnectionUtils.logDebug("engine.getOutputBlockSize():[[" + engine2.getOutputBlockSize() + "]]"); ASN1Sequence asn1SignSeq = (ASN1Sequence) ASN1Sequence.fromByteArray(decryptedHash); HttpsConnectionUtils .logDebug("Signature ASN1 Sequence:[[" + ASN1Dump.dumpAsString(asn1SignSeq, true) + "]]"); AlgorithmIdentifier algorithm = AlgorithmIdentifier.getInstance(asn1SignSeq.getObjectAt(0)); HttpsConnectionUtils.logDebug("AlgorithmIdentifier:[[" + ASN1Dump.dumpAsString(algorithm, true) + "]]"); DEROctetString signedHash = (DEROctetString) DEROctetString.getInstance(asn1SignSeq.getObjectAt(1)); HttpsConnectionUtils.logDebug("signedHash:[[" + ASN1Dump.dumpAsString(signedHash, true) + "]]"); } catch (Exception e) { e.printStackTrace(); } }
From source file:net.wstech2.me.httpsclient.CertificateValidatorUtils.java
License:Apache License
/** * Retrieves the list of alternative DNS names for this certificate, if any. * /*from w ww.j a v a2 s . c o m*/ * @param cert * The certificate from which the issuer name is to the * extracted. * @return A list with all alternative DNS names included in the * certificate. * @throws IOException */ public static List extractSubjectAlternativeNameList(org.bouncycastle.asn1.x509.Certificate cert) throws IOException { List dnsNames = new ArrayList(); dnsNames.add(CertificateValidatorUtils.extractCommonName(cert, true)); Extension subjectAlternativeName = cert.getTBSCertificate().getExtensions() .getExtension(Extension.subjectAlternativeName); if (subjectAlternativeName == null) { return dnsNames; } ASN1OctetString oct = subjectAlternativeName.getExtnValue(); ASN1InputStream extIn = new ASN1InputStream(new ByteArrayInputStream(oct.getOctets())); GeneralNames gn = GeneralNames.getInstance(extIn.readObject()); extIn.close(); ASN1Sequence sq = (ASN1Sequence) gn.toASN1Primitive(); for (int i = 0; i != sq.size(); i++) { GeneralName n = GeneralName.getInstance(sq.getObjectAt(i)); dnsNames.add(n.getName().toString()); } return dnsNames; }
From source file:nl.uva.vlet.grid.voms.VOMSAttributeCertificate.java
License:Apache License
public ArrayList<String> getVOMSFQANs() throws Exception { ArrayList<String> theseFQANs = new ArrayList<String>(); try {// w w w. ja v a 2 s . com // could have more than one AC in here... for (Enumeration a = this.attributes.getObjects(); a.hasMoreElements();) { ASN1Sequence sequence = (ASN1Sequence) a.nextElement(); // sequence contains the OID [voms 4] (as a DERObjectIdentifier) at address 0 , and an SET at address 1 ASN1Set set = (ASN1Set) sequence.getObjectAt(1); // set contains only a SEQUENCE at address 0 ASN1Sequence sequence2 = (ASN1Sequence) set.getObjectAt(0); // sequence2 contains a TAGGED OBJECT ad address 0 and another SEQUENCE at address 1 ASN1TaggedObject taggedObject = (ASN1TaggedObject) sequence2.getObjectAt(0); // dig down the tagged object... (undocumented?) - TagNumber value is 0 ASN1TaggedObject taggedObject2 = (ASN1TaggedObject) taggedObject.getObject(); // this tagged object has TagNumber value of 6 (?) ASN1OctetString originOctetString = (ASN1OctetString) taggedObject2.getObject(); String origin = (new DERGeneralString(originOctetString.getOctets())).getString(); ASN1Sequence fqanSequence = (ASN1Sequence) sequence2.getObjectAt(1); // this is the actual sequence of FQANs for (int fqan = 0; fqan < fqanSequence.size(); fqan++) { ASN1OctetString fqanOctetString = (ASN1OctetString) fqanSequence.getObjectAt(fqan); String FQAN_Value = (new DERGeneralString(fqanOctetString.getOctets())).getString(); theseFQANs.add(FQAN_Value); } } } catch (Exception e) { throw e; } return theseFQANs; }
From source file:org.apache.catalina.realm.X509SubjectAlternativeNameRetriever.java
License:Apache License
/** * The method converts ASNDerEncodedByteArray into String * @param byteArray//ww w . j ava2 s . co m * @return String */ private String getStringFromASNDerEncodedByteArray(byte[] byteArray) { if (logger.isDebugEnabled()) { logger.debug("getStringFromASNDerEncodedByteArray(byte[]) - start"); } String ret = null; try { ASN1InputStream asn1InputStream = new ASN1InputStream(new ByteArrayInputStream(byteArray)); DERObject derObject = asn1InputStream.readObject(); ASN1Sequence asn1Sequence = ASN1Sequence.getInstance(derObject); Object objectValue = asn1Sequence.getObjectAt(1); if (objectValue instanceof ASN1TaggedObject) { ASN1TaggedObject asn1TaggedObject = (ASN1TaggedObject) objectValue; try { if (logger.isDebugEnabled()) { logger.debug("Try to get string from DERUTF8String."); } DERObject derTaggedObject = asn1TaggedObject.getObject(); DERUTF8String derUtf8String = DERUTF8String.getInstance(derTaggedObject); ret = derUtf8String.getString(); } catch (IllegalArgumentException e) { if (logger.isDebugEnabled()) { logger.debug("Can not get String From DERUTF8String, [" + e.getMessage() + "]."); } } } } catch (Exception e) { if (logger.isInfoEnabled()) { logger.info("Can not get String From ASNDerEncoded ByteArray, [" + e.getMessage() + "]."); } } if (logger.isDebugEnabled()) { logger.debug("getStringFromASNDerEncodedByteArray(byte[]) - end. Ret is [" + ret + "]."); } return ret; }
From source file:org.cagrid.security.ssl.proxy.trust.ProxyCertInfo.java
License:Open Source License
/** * Creates a new instance of the ProxyCertInfo extension from given * ASN1Sequence object.//from w w w . ja v a2s . c o m * * @param seq * ASN1Sequence object to create the instance from. */ public ProxyCertInfo(ASN1Sequence seq) { if (seq.size() < 1) { throw new IllegalArgumentException("Invalid sequence"); } int seqPos = 0; if (seq.getObjectAt(seqPos) instanceof DERInteger) { this.pathLenConstraint = (DERInteger) seq.getObjectAt(seqPos); seqPos++; } ASN1Sequence policy = (ASN1Sequence) seq.getObjectAt(seqPos); this.proxyPolicy = new ProxyPolicy(policy); }