use of com.android.org.bouncycastle.asn1.ASN1Sequence in project xipki by xipki.
the class ProxyP11Module method refresh.
public void refresh() throws P11TokenException {
byte[] resp = send(P11ProxyConstants.ACTION_GET_SERVER_CAPS, null);
Asn1ServerCaps caps;
try {
caps = Asn1ServerCaps.getInstance(resp);
} catch (BadAsn1ObjectException ex) {
throw new P11TokenException("response is a valid Asn1ServerCaps", ex);
}
if (!caps.getVersions().contains(version)) {
throw new P11TokenException("Server does not support any version supported by the client");
}
this.readOnly = caps.isReadOnly();
resp = send(P11ProxyConstants.ACTION_GET_SLOT_IDS, null);
ASN1Sequence seq;
try {
seq = ASN1Sequence.getInstance(resp);
} catch (IllegalArgumentException ex) {
throw new P11TokenException("response is not ASN1Sequence", ex);
}
final int n = seq.size();
Set<P11Slot> slots = new HashSet<>();
for (int i = 0; i < n; i++) {
Asn1P11SlotIdentifier asn1SlotId;
try {
ASN1Encodable obj = seq.getObjectAt(i);
asn1SlotId = Asn1P11SlotIdentifier.getInstance(obj);
} catch (Exception ex) {
throw new P11TokenException(ex.getMessage(), ex);
}
P11SlotIdentifier slotId = asn1SlotId.getSlotId();
if (!conf.isSlotIncluded(slotId)) {
continue;
}
if (!conf.isSlotIncluded(slotId)) {
LOG.info("skipped slot {}", slotId);
continue;
}
P11Slot slot = new ProxyP11Slot(this, slotId, conf.isReadOnly(), conf.getP11MechanismFilter());
slots.add(slot);
}
setSlots(slots);
}
use of com.android.org.bouncycastle.asn1.ASN1Sequence in project signer by demoiselle.
the class SignPolicyInfo method parse.
@Override
public void parse(ASN1Primitive derObject) {
ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject);
this.signPolicyIdentifier = new SignPolicyId();
this.signPolicyIdentifier.parse(derSequence.getObjectAt(0).toASN1Primitive());
this.dateOfIssue = new GeneralizedTime();
this.dateOfIssue.parse(derSequence.getObjectAt(1).toASN1Primitive());
this.policyIssuerName = new PolicyIssuerName();
this.policyIssuerName.parse(derSequence.getObjectAt(2).toASN1Primitive());
this.fieldOfApplication = new FieldOfApplication();
this.fieldOfApplication.parse(derSequence.getObjectAt(3).toASN1Primitive());
this.signatureValidationPolicy = new SignatureValidationPolicy();
this.signatureValidationPolicy.parse(derSequence.getObjectAt(4).toASN1Primitive());
if (derSequence.size() == 6) {
this.signPolExtensions = new SignPolExtensions();
this.signPolExtensions.parse(derSequence.getObjectAt(5).toASN1Primitive());
}
}
use of com.android.org.bouncycastle.asn1.ASN1Sequence in project signer by demoiselle.
the class SignerRules method parse.
@Override
public void parse(ASN1Primitive primitive) {
ASN1Sequence derSequence = ASN1Object.getDERSequence(primitive);
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 mandatedCertificateRef:
this.mandatedCertificateRef = CertRefReq.parse(object);
break;
case mandatedCertificateInfo:
this.mandatedCertificateInfo = CertInfoReq.parse(object);
break;
case signPolExtensions:
this.signPolExtensions = new SignPolExtensions();
this.signPolExtensions.parse(object);
break;
default:
break;
}
}
}
}
int i = 0;
ASN1Encodable object = derSequence.getObjectAt(i);
if (!(object instanceof DERSequence)) {
if (object instanceof ASN1Boolean) {
this.externalSignedData = ((ASN1Boolean) object).isTrue();
}
i++;
}
this.mandatedSignedAttr = new CMSAttrs();
this.mandatedSignedAttr.parse(derSequence.getObjectAt(i).toASN1Primitive());
i++;
this.mandatedUnsignedAttr = new CMSAttrs();
this.mandatedUnsignedAttr.parse(derSequence.getObjectAt(i).toASN1Primitive());
}
use of com.android.org.bouncycastle.asn1.ASN1Sequence in project signer by demoiselle.
the class SigningPeriod method parse.
@Override
public void parse(ASN1Primitive derObject) {
ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject);
this.notBefore = new GeneralizedTime();
this.notBefore.parse(derSequence.getObjectAt(0).toASN1Primitive());
if (derSequence.size() == 2) {
this.notAfter = new GeneralizedTime();
this.notAfter.parse(derSequence.getObjectAt(1).toASN1Primitive());
}
}
use of com.android.org.bouncycastle.asn1.ASN1Sequence in project signer by demoiselle.
the class LPA method parse.
@Override
public void parse(ASN1Primitive derObject) {
ASN1Sequence sequence = ASN1Object.getDERSequence(derObject);
ASN1Primitive policyInfos = sequence.getObjectAt(0).toASN1Primitive();
DLSequence policyInfosSequence = (DLSequence) policyInfos;
if (policyInfosSequence != null && policyInfosSequence.size() > 0) {
this.policyInfos = new ArrayList<>();
for (int i = 0; i < policyInfosSequence.size(); i++) {
PolicyInfo policyInfo = new PolicyInfo();
policyInfo.parse(policyInfosSequence.getObjectAt(i).toASN1Primitive());
this.policyInfos.add(policyInfo);
}
}
this.nextUpdate = new Time();
this.nextUpdate.parse(sequence.getObjectAt(1).toASN1Primitive());
}
Aggregations