/** * Extract extensions from CSR object */ public static Extensions getExtensionsFromCSR(JcaPKCS10CertificationRequest csr) { Attribute[] attributess = csr.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest); for (Attribute attribute : attributess) { ASN1Set attValue = attribute.getAttrValues(); if (attValue != null) { ASN1Encodable extension = attValue.getObjectAt(0); if (extension instanceof Extensions) { return (Extensions) extension; } else if (extension instanceof DERSequence) { return Extensions.getInstance(extension); } } } return null; }
final Extensions extensions = Extensions.getInstance(attribute.getAttrValues().getObjectAt(0)); final GeneralNames gns = GeneralNames.fromExtensions(extensions, Extension.subjectAlternativeName); if (gns != null && gns.getNames() != null && gns.getNames().length > 0) {
private TimeStampToken extractTimeStampTokenFromSignerInformation(SignerInformation signerInformation) throws CMSException, IOException, TSPException { if (signerInformation.getUnsignedAttributes() == null) { return null; } AttributeTable unsignedAttributes = signerInformation.getUnsignedAttributes(); // https://stackoverflow.com/questions/1647759/how-to-validate-if-a-signed-jar-contains-a-timestamp Attribute attribute = unsignedAttributes.get( PKCSObjectIdentifiers.id_aa_signatureTimeStampToken); if (attribute == null) { return null; } ASN1Object obj = (ASN1Object) attribute.getAttrValues().getObjectAt(0); CMSSignedData signedTSTData = new CMSSignedData(obj.getEncoded()); return new TimeStampToken(signedTSTData); }
if (signingTime != null) Time timeInstance = Time.getInstance(signingTime.getAttrValues().getObjectAt(0)); try
/** * Returns the content type contained in this contentType attribute. * * @return the contentType. */ public DERObjectIdentifier getContentType() { return (DERObjectIdentifier) getAttrValues().getObjectAt(0); } }
public AttributeTypeAndValue[] getTypesAndValues() { AttributeTypeAndValue[] tmp = new AttributeTypeAndValue[values.size()]; for (int i = 0; i != tmp.length; i++) { tmp[i] = AttributeTypeAndValue.getInstance(values.getObjectAt(i)); } return tmp; }
public Attribute[] getAttributes() { Attribute[] rv = new Attribute[attributes.size()]; for (int i = 0; i != rv.length; i++) { rv[i] = Attribute.getInstance(attributes.getObjectAt(i)); } return rv; }
public ASN1Encodable[] toArray() { ASN1Encodable[] values = new ASN1Encodable[this.size()]; for (int i = 0; i != this.size(); i++) { values[i] = this.getObjectAt(i); } return values; }
public Attribute[] getAttributes() { Attribute[] rv = new Attribute[attributes.size()]; for (int i = 0; i != rv.length; i++) { rv[i] = Attribute.getInstance(attributes.getObjectAt(i)); } return rv; }
public ASN1Encodable[] toArray() { ASN1Encodable[] values = new ASN1Encodable[this.size()]; for (int i = 0; i != this.size(); i++) { values[i] = this.getObjectAt(i); } return values; }
private MessageType toMessageType(final Attribute attr) { final DERPrintableString string = (DERPrintableString) attr .getAttrValues().getObjectAt(0); return MessageType.valueOf(Integer.valueOf(string.getString())); }
public ASN1Encodable[] getValues() { ASN1Set s = attr.getAttrValues(); ASN1Encodable[] values = new ASN1Encodable[s.size()]; for (int i = 0; i != s.size(); i++) { values[i] = (ASN1Encodable)s.getObjectAt(i); } return values; }
private CRL getCRL() throws CRLException { if (sData == null || sDataObjectCount >= sData.size()) { return null; } return new X509CRLObject( CertificateList.getInstance( sData.getObjectAt(sDataObjectCount++))); }
private TransactionId toTransactionId(final Attribute attr) { final DERPrintableString string = (DERPrintableString) attr .getAttrValues().getObjectAt(0); return new TransactionId(string.getOctets()); }
/** * Returns the recipient {@link MessageType} associated with this <code>pkiMessage</code>. * * @return the sender {@link MessageType}. */ public MessageType getMessageType() { final Attribute attr = getAttributeTable().get(SCEPObjectIdentifiers.messageType); final DERPrintableString msgType = (DERPrintableString) attr.getAttrValues().getObjectAt(0); return MessageType.valueOf(Integer.parseInt(msgType.getString())); }
/** * @param timestampToken * @return the content of SignedAttribute: ATS-hash-index unsigned attribute {itu-t(0) identified-organization(4) etsi(0) electronic-signature-standard(1733) attributes(2) 5} */ private ASN1Sequence getAtsHashIndex(TimestampToken timestampToken) { final AttributeTable timestampTokenUnsignedAttributes = timestampToken.getUnsignedAttributes(); final Attribute atsHashIndexAttribute = timestampTokenUnsignedAttributes.get(id_aa_ATSHashIndex); final ASN1Set attrValues = atsHashIndexAttribute.getAttrValues(); return (ASN1Sequence) attrValues.getObjectAt(0).toASN1Primitive(); }
public static ASN1Encodable getFirstAttrValue(AttributeTable attrs, ASN1ObjectIdentifier type) { requireNonNull("attrs", attrs); requireNonNull("type", type); Attribute attr = attrs.get(type); if (attr == null) { return null; } ASN1Set set = attr.getAttrValues(); return (set.size() == 0) ? null : set.getObjectAt(0); }
private ASN1Encodable getChallengePassword(Attribute[] attributes) { for (Attribute attribute : attributes) { if (PKCSObjectIdentifiers.pkcs_9_at_challengePassword.equals(attribute.getAttrType())) { if (attribute.getAttrValues() != null && attribute.getAttrValues().size() > 0) { return attribute.getAttrValues().getObjectAt(0); } } } return null; }
private static String getChallengePassword(CertificationRequestInfo csr) { ASN1Set attrs = csr.getAttributes(); for (int i = 0; i < attrs.size(); i++) { Attribute attr = Attribute.getInstance(attrs.getObjectAt(i)); if (PKCSObjectIdentifiers.pkcs_9_at_challengePassword.equals(attr.getAttrType())) { ASN1String str = (ASN1String) attr.getAttributeValues()[0]; return str.getString(); } } return null; }
public static String getChallengePassword(CertificationRequestInfo csr) { Args.notNull(csr, "csr"); ASN1Set attrs = csr.getAttributes(); for (int i = 0; i < attrs.size(); i++) { Attribute attr = Attribute.getInstance(attrs.getObjectAt(i)); if (PKCSObjectIdentifiers.pkcs_9_at_challengePassword.equals(attr.getAttrType())) { ASN1String str = (ASN1String) attr.getAttributeValues()[0]; return str.getString(); } } return null; }