本文整理汇总了Java中org.bouncycastle.asn1.DLSequence.getObjectAt方法的典型用法代码示例。如果您正苦于以下问题:Java DLSequence.getObjectAt方法的具体用法?Java DLSequence.getObjectAt怎么用?Java DLSequence.getObjectAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.DLSequence
的用法示例。
在下文中一共展示了DLSequence.getObjectAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSki
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
/**
* This method returns SKI bytes from certificate.
*
* @param certificateToken
* {@code CertificateToken}
* @param computeIfMissing
* if the extension is missing and computeIfMissing = true, it will compute the SKI value from the Public
* Key
* @return ski bytes from the given certificate
* @throws DSSException
*/
public static byte[] getSki(final CertificateToken certificateToken, boolean computeIfMissing) throws DSSException {
try {
byte[] sKI = certificateToken.getCertificate().getExtensionValue(Extension.subjectKeyIdentifier.getId());
if (Utils.isArrayNotEmpty(sKI)) {
ASN1Primitive extension = X509ExtensionUtil.fromExtensionValue(sKI);
SubjectKeyIdentifier skiBC = SubjectKeyIdentifier.getInstance(extension);
return skiBC.getKeyIdentifier();
} else if (computeIfMissing) {
// If extension not present, we compute it from the certificate public key
DLSequence seq = (DLSequence) DERSequence.fromByteArray(certificateToken.getPublicKey().getEncoded());
DERBitString item = (DERBitString) seq.getObjectAt(1);
return DSSUtils.digest(DigestAlgorithm.SHA1, item.getOctets());
}
return null;
} catch (Exception e) {
throw new DSSException(e);
}
}
示例2: parseOtherName
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
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;
}
}
示例3: parseOtherName
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
private static OtherName 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 OtherName(oid, ((DERUTF8String) value).getString());
} else if (value instanceof DERIA5String) {
return new OtherName(oid, ((DERIA5String) value).getString());
}
}
}
}
return null;
} catch (IOException e) {
return null;
}
}
示例4: parseOtherName
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
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;
}
}
示例5: get
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
public static Map<String, String> get(final X500Principal x500Principal) {
Map<String, String> treeMap = new HashMap<String, String>();
final byte[] encoded = x500Principal.getEncoded();
final ASN1Sequence asn1Sequence = ASN1Sequence.getInstance(encoded);
final ASN1Encodable[] asn1Encodables = asn1Sequence.toArray();
for (final ASN1Encodable asn1Encodable : asn1Encodables) {
final DLSet dlSet = (DLSet) asn1Encodable;
for (int ii = 0; ii < dlSet.size(); ii++) {
final DLSequence dlSequence = (DLSequence) dlSet.getObjectAt(ii);
if (dlSequence.size() != 2) {
throw new DSSException("The DLSequence must contains exactly 2 elements.");
}
final ASN1Encodable asn1EncodableAttributeType = dlSequence.getObjectAt(0);
final String stringAttributeType = getString(asn1EncodableAttributeType);
final ASN1Encodable asn1EncodableAttributeValue = dlSequence.getObjectAt(1);
final String stringAttributeValue = getString(asn1EncodableAttributeValue);
treeMap.put(stringAttributeType, stringAttributeValue);
}
}
return treeMap;
}
示例6: getCertificatePolicies
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
/**
* Returns current certificate policies or null if no policies was found.
*
* @return list of policies
* @throws IOException when policy parsing fails
*/
public List<String> getCertificatePolicies() throws IOException {
logger.debug("");
byte[] extensionValue = originalCert.getExtensionValue("2.5.29.32");
List<String> policies = new ArrayList<>();
byte[] octets = ((DEROctetString) DEROctetString.fromByteArray(extensionValue)).getOctets();
ASN1Sequence sequence = (ASN1Sequence) ASN1Sequence.fromByteArray(octets);
Enumeration sequenceObjects = sequence.getObjects();
while (sequenceObjects.hasMoreElements()) {
DLSequence next = (DLSequence) sequenceObjects.nextElement();
Object objectAt = next.getObjectAt(0);
if (objectAt != null) {
policies.add(objectAt.toString());
}
}
return policies;
}
示例7: decodeToBigIntegerArray
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
/**
* DER - From byte[] to Big Integer rs
* UAF_ALG_SIGN_SECP256K1_ECDSA_SHA256_DER 0x06 DER [ITU-X690-2008] encoded
* ECDSA signature [RFC5480] on the secp256k1 curve. I.e. a DER encoded
* SEQUENCE { r INTEGER, s INTEGER }
*
* @param signature
* @return
* @throws IOException
*/
public static BigInteger[] decodeToBigIntegerArray(byte[] signature)
throws IOException {
ASN1InputStream decoder = new ASN1InputStream(signature);
DLSequence seq = (DLSequence) decoder.readObject();
ASN1Integer r = (ASN1Integer) seq.getObjectAt(0);
ASN1Integer s = (ASN1Integer) seq.getObjectAt(1);
decoder.close();
BigInteger[] ret = new BigInteger[2];
ret[0] = r.getPositiveValue();
ret[1] = s.getPositiveValue();
return ret;
}
示例8: getAuthorityKeyIdentifier
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
/**
*
*
* @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());
}
示例9: extractCertList
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
public static List<byte[]> extractCertList(byte[] sign) throws Exception {
List<byte[]> ret = null;
ASN1InputStream is = new ASN1InputStream(new ByteArrayInputStream(sign));
ASN1Primitive topLevel = is.readObject();
LOG.trace("top level:"
+ topLevel.getClass().getName());
if (topLevel instanceof org.bouncycastle.asn1.DLSequence) {
DLSequence topLevelDLS = (DLSequence) topLevel;
if (topLevelDLS.size() == 2) {
ASN1Encodable level1 = topLevelDLS.getObjectAt(1);
LOG.trace("level1:"
+ level1.getClass().getName());
if (level1 instanceof org.bouncycastle.asn1.DERTaggedObject) {
DERTaggedObject level1TO = (DERTaggedObject) level1;
ASN1Primitive level2 = level1TO.getObject();
LOG.trace("level2:"
+ level2.getClass().getName());
if (level2 instanceof org.bouncycastle.asn1.DERSequence) {
DERSequence level2DS = (DERSequence) level2;
LOG.trace("level2 len:"
+ level2DS.size());
ret = extractCertArray(level2DS);
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
return ret;
}
示例10: extractCertList
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
public static List<byte[]> extractCertList(byte[] sign) throws Exception {
List<byte[]> ret = null;
ASN1InputStream is = new ASN1InputStream(new ByteArrayInputStream(sign));
ASN1Primitive topLevel = is.readObject();
LOG.debug("top level:"
+ topLevel.getClass().getName());
if (topLevel instanceof org.bouncycastle.asn1.DLSequence) {
DLSequence topLevelDLS = (DLSequence) topLevel;
if (topLevelDLS.size() == 2) {
ASN1Encodable level1 = topLevelDLS.getObjectAt(1);
LOG.debug("level1:"
+ level1.getClass().getName());
if (level1 instanceof org.bouncycastle.asn1.DERTaggedObject) {
DERTaggedObject level1TO = (DERTaggedObject) level1;
ASN1Primitive level2 = level1TO.getObject();
LOG.debug("level2:"
+ level2.getClass().getName());
if (level2 instanceof org.bouncycastle.asn1.DERSequence) {
DERSequence level2DS = (DERSequence) level2;
LOG.debug("level2 len:"
+ level2DS.size());
ret = extractCertArray(level2DS);
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
return ret;
}
示例11: getAKI
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
public static byte[] getAKI(byte[] extensionValue, int index) {
byte[] ret = null;
try {
if (extensionValue == null) {
return null;
}
ASN1InputStream oAsnInStream = new ASN1InputStream(
new ByteArrayInputStream(extensionValue));
ASN1Primitive derObjCP = oAsnInStream.readObject();
DEROctetString dosCP = (DEROctetString) derObjCP;
byte[] cpOctets = dosCP.getOctets();
ASN1InputStream oAsnInStream2 = new ASN1InputStream(
new ByteArrayInputStream(cpOctets));
ASN1Primitive derObj2 = oAsnInStream2.readObject();
// derObj2 = oAsnInStream2.readObject();
DLSequence derSeq = (DLSequence) derObj2;
int seqLen = derSeq.size();
// for(int i = 0; i < seqLen; i++){
ASN1Encodable derObj3 = derSeq.getObjectAt(0);
DERTaggedObject derTO = (DERTaggedObject) derObj3;
int tag = derTO.getTagNo();
boolean empty = derTO.isEmpty();
ASN1Primitive derObj4 = derTO.getObject();
DEROctetString ocStr4 = (DEROctetString) derObj4;
ret = ocStr4.getOctets();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ret;
}
示例12: ECDSASignature
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
public ECDSASignature(byte[] signatureDEREncodedBytes, byte[] signingPubKey) throws IOException {
publicSigningKey = StellarDeterministicKeyGenerator.SECP256K1_PARAMS.getCurve().decodePoint(signingPubKey);
ASN1InputStream decoder = new ASN1InputStream(signatureDEREncodedBytes);
DLSequence seq = (DLSequence) decoder.readObject();
DERInteger r = (DERInteger) seq.getObjectAt(0);
DERInteger s = (DERInteger) seq.getObjectAt(1);
// OpenSSL deviates from the DER spec by interpreting these values as unsigned, though they should not be
// Thus, we always use the positive versions.
// See: http://r6.ca/blog/20111119T211504Z.html
this.r = r.getPositiveValue();
this.s = s.getPositiveValue();
decoder.close();
}
示例13: parse
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
@Override
public void parse(ASN1Primitive primitive) {
if (primitive instanceof DLSequence) {
DLSequence sequence = (DLSequence) primitive;
ASN1Encodable asn1Encodable = sequence.getObjectAt(0);
if (asn1Encodable instanceof DERTaggedObject) {
DERTaggedObject derTaggedObject = (DERTaggedObject) asn1Encodable;
ASN1Primitive object = derTaggedObject.getObject();
if (object instanceof DEROctetString) {
OctetString octetString = new OctetString();
octetString.parse(object);
this.issuerName = octetString.getValueUTF8();
} else if (object instanceof DERSequence) {
DERSequence sequence2 = (DERSequence) object;
for (int i = 0; i < sequence2.size(); i++) {
ASN1Encodable obj = sequence2.getObjectAt(i);
if (obj instanceof DERSet) {
DERSet set = (DERSet) obj;
ASN1Encodable object2 = set.getObjectAt(0);
if (object2 instanceof DERSequence) {
DERSequence sequence3 = (DERSequence) object2;
ObjectIdentifier objectIdendifier = new ObjectIdentifier();
objectIdendifier.parse(sequence3.getObjectAt(0).toASN1Primitive());
String name = null;
ASN1Encodable object3 = sequence3.getObjectAt(1);
if (object3 instanceof DERPrintableString) {
name = ((DERPrintableString) object3).getString();
} else if (object3 instanceof DERUTF8String) {
name = ((DERUTF8String) object3).getString();
} else {
System.out.println(policyMessagesBundle.getString("error.not.recognized.object",object3.getClass(),object3.toString()));
}
if (this.issuerNames == null) {
this.issuerNames = new HashMap<ObjectIdentifier, String>();
}
this.issuerNames.put(objectIdendifier, name);
}
}
}
}
}
}
}
示例14: getCertificateLevel
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
/**
* returns the ICP-BRASIL Certificate Level(A1, A2, A3, A4, S1, S2, S3,
* S4).<br>
* DOC-ICP-04 Returns the <b>null</b> value if the CertificatePolicies is
* NOT present.
*
* @return String Certificate level
*/
public String getCertificateLevel() {
try {
DLSequence sequence = (DLSequence) getExtensionValue(Extension.certificatePolicies.getId());
if (sequence != null) {
for (int pos = 0; pos < sequence.size(); pos++) {
DLSequence sequence2 = (DLSequence) sequence.getObjectAt(pos);
ASN1ObjectIdentifier policyIdentifier = (ASN1ObjectIdentifier) sequence2.getObjectAt(0);
PolicyInformation policyInformation = new PolicyInformation(policyIdentifier);
String id = policyInformation.getPolicyIdentifier().getId();
if (id == null) {
continue;
}
if (id.startsWith(OID_A1_CERTIFICATE)) {
return "A1";
}
if (id.startsWith(OID_A2_CERTIFICATE)) {
return "A2";
}
if (id.startsWith(OID_A3_CERTIFICATE)) {
return "A3";
}
if (id.startsWith(OID_A4_CERTIFICATE)) {
return "A4";
}
if (id.startsWith(OID_S1_CERTIFICATE)) {
return "S1";
}
if (id.startsWith(OID_S2_CERTIFICATE)) {
return "S2";
}
if (id.startsWith(OID_S3_CERTIFICATE)) {
return "S3";
}
if (id.startsWith(OID_S4_CERTIFICATE)) {
return "S4";
}
}
}
return null;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例15: extractHashId
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
public static String extractHashId(byte[] sign) throws Exception {
String ret = null;
ASN1InputStream is = new ASN1InputStream(new ByteArrayInputStream(sign));
ASN1Primitive topLevel = is.readObject();
LOG.trace("top level:" + topLevel.getClass().getName());
if (topLevel instanceof org.bouncycastle.asn1.DLSequence) {
DLSequence topLevelDLS = (DLSequence) topLevel;
if (topLevelDLS.size() == 2) {
ASN1Encodable level1 = topLevelDLS.getObjectAt(1);
LOG.trace("level1:"
+ level1.getClass().getName());
if (level1 instanceof org.bouncycastle.asn1.DERTaggedObject) {
DERTaggedObject level1TO = (DERTaggedObject) level1;
ASN1Primitive level2 = level1TO.getObject();
LOG.trace("level2:"
+ level2.getClass().getName());
if (level2 instanceof org.bouncycastle.asn1.DERSequence) {
DERSequence level2DS = (DERSequence) level2;
LOG.trace("level2 len:"
+ level2DS.size());
ASN1Encodable level3_1 = level2DS.getObjectAt(1);
LOG.trace("level3_1:"
+ level3_1.getClass().getName());
if (level3_1 instanceof org.bouncycastle.asn1.DERSet) {
DERSet level3_1Set = (DERSet) level3_1;
ASN1Encodable level4_1 = level3_1Set.getObjectAt(0);
LOG.trace("level4_1:"
+ level4_1.getClass().getName());
if (level4_1 instanceof org.bouncycastle.asn1.DERSequence) {
DERSequence level4_1Seq = (DERSequence) level4_1;
ASN1Encodable level5_0 = level4_1Seq.getObjectAt(0);
LOG.trace("level5_0:"
+ level5_0.getClass().getName());
if (level5_0 instanceof org.bouncycastle.asn1.ASN1ObjectIdentifier) {
ASN1ObjectIdentifier level5_0Seq = (ASN1ObjectIdentifier) level5_0;
LOG.trace(level5_0Seq.toString());
ret = level5_0Seq.toString();
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
} else {
throw new Exception("DER enconding error");
}
return ret;
}