本文整理汇总了Java中org.bouncycastle.asn1.DLSequence.size方法的典型用法代码示例。如果您正苦于以下问题:Java DLSequence.size方法的具体用法?Java DLSequence.size怎么用?Java DLSequence.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.DLSequence
的用法示例。
在下文中一共展示了DLSequence.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: parse
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
public void parse(ASN1Primitive derObject) {
ASN1Sequence sequence = ASN1Object.getDERSequence(derObject);
ASN1Primitive firstObject = sequence.getObjectAt(0).toASN1Primitive();
this.version = new Version();
int indice = 0;
if (firstObject instanceof ASN1Integer) {
this.version.parse(firstObject);
indice++;
}
ASN1Primitive policyInfos = sequence.getObjectAt(indice).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 GeneralizedTime();
this.nextUpdate.parse(sequence.getObjectAt(indice + 1).toASN1Primitive());
}
示例3: parse
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
@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());
}
示例4: 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;
}
}
示例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: 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;
}
}
示例7: 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());
}
示例8: 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;
}
示例9: 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;
}
示例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: 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;
}
示例12: 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;
}
示例13: extractSignature
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
public static byte[] extractSignature(byte[] sign) throws Exception {
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());
ASN1Encodable level3_4 = level2DS.getObjectAt(level2DS
.size() - 1);
LOG.trace("level3_4:"
+ level3_4.getClass().getName());
if (level3_4 instanceof org.bouncycastle.asn1.DERSet) {
DERSet level3_4DS = (DERSet) level3_4;
ASN1Encodable level3_4_0 = level3_4DS
.getObjectAt(0);
LOG.trace("level3_4_0:"
+ level3_4_0.getClass().getName());
if (level3_4_0 instanceof org.bouncycastle.asn1.DERSequence) {
DERSequence level3_4_0DS = (DERSequence) level3_4_0;
LOG.trace("level3_4_0DS len:"
+ level3_4_0DS.size());
ASN1Encodable signature = level3_4_0DS
.getObjectAt(level3_4_0DS.size() - 1);
LOG.trace("signature:"
+ signature.getClass().getName());
if (signature instanceof org.bouncycastle.asn1.DEROctetString) {
DEROctetString signDOS = (DEROctetString) signature;
ret = signDOS.getOctets();
}
} 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;
}
示例14: extractDTOSignPolicyOid
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
public static DERTaggedObject extractDTOSignPolicyOid(byte[] sign,
SignCompare signCompare) throws Exception {
DERTaggedObject 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());
signCompare.setNumCerts(extractCertCount(level2DS));
ret = extractSignedAttributes(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;
}
示例15: extractSignCompare2
import org.bouncycastle.asn1.DLSequence; //导入方法依赖的package包/类
public static void extractSignCompare2(byte[] sign,
SignCompare2 signCompare) throws Exception {
saveDebug(sign);
DERTaggedObject 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());
signCompare.setNumCerts(extractCertCount(level2DS));
ret = extractSignedAttributes(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;
}