use of com.github.zhenwei.core.asn1.ASN1Set in project LinLong-Java by zhenwei1108.
the class PKCS10CertificationRequest method getAttributes.
/**
* Return an array of attributes matching the passed in type OID.
*
* @param type the type of the attribute being looked for.
* @return an array of Attribute of the requested type, zero length if none present.
*/
public Attribute[] getAttributes(ASN1ObjectIdentifier type) {
ASN1Set attrSet = certificationRequest.getCertificationRequestInfo().getAttributes();
if (attrSet == null) {
return EMPTY_ARRAY;
}
List list = new ArrayList();
for (int i = 0; i != attrSet.size(); i++) {
Attribute attr = Attribute.getInstance(attrSet.getObjectAt(i));
if (attr.getAttrType().equals(type)) {
list.add(attr);
}
}
if (list.size() == 0) {
return EMPTY_ARRAY;
}
return (Attribute[]) list.toArray(new Attribute[list.size()]);
}
use of com.github.zhenwei.core.asn1.ASN1Set in project LinLong-Java by zhenwei1108.
the class PKCS10CertificationRequest method getAttributes.
/**
* Return the attributes, if any associated with this request.
*
* @return an array of Attribute, zero length if none present.
*/
public Attribute[] getAttributes() {
ASN1Set attrSet = certificationRequest.getCertificationRequestInfo().getAttributes();
if (attrSet == null) {
return EMPTY_ARRAY;
}
Attribute[] attrs = new Attribute[attrSet.size()];
for (int i = 0; i != attrSet.size(); i++) {
attrs[i] = Attribute.getInstance(attrSet.getObjectAt(i));
}
return attrs;
}
use of com.github.zhenwei.core.asn1.ASN1Set in project LinLong-Java by zhenwei1108.
the class BCEdDSAPrivateKey method getEncoded.
public byte[] getEncoded() {
try {
ASN1Set attrSet = ASN1Set.getInstance(attributes);
PrivateKeyInfo privInfo = PrivateKeyInfoFactory.createPrivateKeyInfo(eddsaPrivateKey, attrSet);
if (hasPublicKey && !Properties.isOverrideSet("com.github.zhenwei.pkix.pkcs8.v1_info_only")) {
return privInfo.getEncoded();
} else {
return new PrivateKeyInfo(privInfo.getPrivateKeyAlgorithm(), privInfo.parsePrivateKey(), attrSet).getEncoded();
}
} catch (IOException e) {
return null;
}
}
use of com.github.zhenwei.core.asn1.ASN1Set in project LinLong-Java by zhenwei1108.
the class BCXDHPrivateKey method getEncoded.
public byte[] getEncoded() {
try {
ASN1Set attrSet = ASN1Set.getInstance(attributes);
PrivateKeyInfo privInfo = PrivateKeyInfoFactory.createPrivateKeyInfo(xdhPrivateKey, attrSet);
if (hasPublicKey && !Properties.isOverrideSet("com.github.zhenwei.pkix.pkcs8.v1_info_only")) {
return privInfo.getEncoded();
} else {
return new PrivateKeyInfo(privInfo.getPrivateKeyAlgorithm(), privInfo.parsePrivateKey(), attrSet).getEncoded();
}
} catch (IOException e) {
return null;
}
}
use of com.github.zhenwei.core.asn1.ASN1Set in project LinLong-Java by zhenwei1108.
the class P7bBuilder method buildP7b.
public static ArrayList<X509Certificate> buildP7b(byte[] data) throws WeGooCryptoException {
ContentInfo contentInfo = ContentInfo.getInstance(data);
// P7B 的 contentType应该是这个
// ASN1ObjectIdentifier signedData = PKCSObjectIdentifiers.signedData;
SignedData signedData = SignedData.getInstance(contentInfo.getContent());
if (signedData == null)
throw new WeGooCryptoException(CryptoExceptionMassageEnum.build_err);
ASN1Set certs = signedData.getCertificates();
ArrayList<X509Certificate> list = new ArrayList<>();
for (ASN1Encodable cert : certs) {
list.add(CertBuilder.getInstance(cert).getCert());
}
return list;
}
Aggregations