use of org.bouncycastle.asn1.DERTaggedObject in project signer by demoiselle.
the class CommonRules method parse.
@Override
public void parse(ASN1Primitive derObject) {
ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject);
int total = derSequence.size();
if (total > 0) {
for (int i = 0; i < total; i++) {
ASN1Primitive object = derSequence.getObjectAt(i).toASN1Primitive();
if (object instanceof DERTaggedObject) {
DERTaggedObject derTaggedObject = (DERTaggedObject) object;
TAG tag = TAG.getTag(derTaggedObject.getTagNo());
switch(tag) {
case signerAndVeriferRules:
this.signerAndVeriferRules = new SignerAndVerifierRules();
this.signerAndVeriferRules.parse(object);
break;
case signingCertTrustCondition:
this.signingCertTrustCondition = new SigningCertTrustCondition();
this.signingCertTrustCondition.parse(object);
break;
case timeStampTrustCondition:
this.timeStampTrustCondition = new TimestampTrustCondition();
this.timeStampTrustCondition.parse(object);
break;
case attributeTrustCondition:
this.attributeTrustCondition = new AttributeTrustCondition();
this.attributeTrustCondition.parse(object);
break;
case algorithmConstraintSet:
this.algorithmConstraintSet = new AlgorithmConstraintSet();
this.algorithmConstraintSet.parse(object);
break;
case signPolExtensions:
this.signPolExtensions = new SignPolExtensions();
this.signPolExtensions.parse(object);
break;
default:
break;
}
}
}
}
}
use of org.bouncycastle.asn1.DERTaggedObject in project signer by demoiselle.
the class BasicCertificate method getAuthorityKeyIdentifier.
/**
* @return the authority key identifier of a certificate
* @throws IOException exception
*/
public String getAuthorityKeyIdentifier() throws IOException {
// TODO - Precisa validar este metodo com a RFC
DLSequence sequence = (DLSequence) getExtensionValue(Extension.authorityKeyIdentifier.getId());
if (sequence == null || sequence.size() == 0) {
return null;
}
DERTaggedObject taggedObject = (DERTaggedObject) sequence.getObjectAt(0);
DEROctetString oct = (DEROctetString) taggedObject.getObject();
return toString(oct.getOctets());
}
use of org.bouncycastle.asn1.DERTaggedObject in project netty by netty.
the class OcspUtils method ocspUri.
/**
* Returns the OCSP responder {@link URI} or {@code null} if it doesn't have one.
*/
public static URI ocspUri(X509Certificate certificate) throws IOException {
byte[] value = certificate.getExtensionValue(Extension.authorityInfoAccess.getId());
if (value == null) {
return null;
}
ASN1Primitive authorityInfoAccess = X509ExtensionUtil.fromExtensionValue(value);
if (!(authorityInfoAccess instanceof DLSequence)) {
return null;
}
DLSequence aiaSequence = (DLSequence) authorityInfoAccess;
DERTaggedObject taggedObject = findObject(aiaSequence, OCSP_RESPONDER_OID, DERTaggedObject.class);
if (taggedObject == null) {
return null;
}
if (taggedObject.getTagNo() != BERTags.OBJECT_IDENTIFIER) {
return null;
}
byte[] encoded = taggedObject.getEncoded();
int length = (int) encoded[1] & 0xFF;
String uri = new String(encoded, 2, length, CharsetUtil.UTF_8);
return URI.create(uri);
}
use of org.bouncycastle.asn1.DERTaggedObject in project Conversations by siacs.
the class XmppDomainVerifier method parseOtherName.
private static Pair<String, String> parseOtherName(byte[] otherName) {
try {
ASN1Primitive asn1Primitive = ASN1Primitive.fromByteArray(otherName);
if (asn1Primitive instanceof DERTaggedObject) {
ASN1Primitive inner = ((DERTaggedObject) asn1Primitive).getObject();
if (inner instanceof DLSequence) {
DLSequence sequence = (DLSequence) inner;
if (sequence.size() >= 2 && sequence.getObjectAt(1) instanceof DERTaggedObject) {
String oid = sequence.getObjectAt(0).toString();
ASN1Primitive value = ((DERTaggedObject) sequence.getObjectAt(1)).getObject();
if (value instanceof DERUTF8String) {
return new Pair<>(oid, ((DERUTF8String) value).getString());
} else if (value instanceof DERIA5String) {
return new Pair<>(oid, ((DERIA5String) value).getString());
}
}
}
}
return null;
} catch (IOException e) {
return null;
}
}
use of org.bouncycastle.asn1.DERTaggedObject in project wildfly by wildfly.
the class KerberosTestUtils method generateSpnegoTokenResp.
/**
* Generates SPNEGO response (to a "select mechanism challenge") with given bytes as the ticket for selected mechanism.
*
* @param ticket
* @return ASN.1 encoded SPNEGO response
*/
public static byte[] generateSpnegoTokenResp(byte[] ticket) throws IOException {
DEROctetString ourKerberosTicket = new DEROctetString(ticket);
// accept-incomplete
DERTaggedObject taggedNegState = new DERTaggedObject(0, new ASN1Enumerated(1));
DERTaggedObject taggedResponseToken = new DERTaggedObject(2, ourKerberosTicket);
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(taggedNegState);
v.add(taggedResponseToken);
DERSequence seqNegTokenResp = new DERSequence(v);
DERTaggedObject taggedSpnego = new DERTaggedObject(1, seqNegTokenResp);
return taggedSpnego.getEncoded();
}
Aggregations