本文整理汇总了Java中org.bouncycastle.asn1.DLSequence类的典型用法代码示例。如果您正苦于以下问题:Java DLSequence类的具体用法?Java DLSequence怎么用?Java DLSequence使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DLSequence类属于org.bouncycastle.asn1包,在下文中一共展示了DLSequence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verify
import org.bouncycastle.asn1.DLSequence; //导入依赖的package包/类
@Override
public boolean verify(byte[] hash, byte[] signature, byte[] publicKey) {
ASN1InputStream asn1 = new ASN1InputStream(signature);
try {
ECDSASigner signer = new ECDSASigner();
signer.init(false, new ECPublicKeyParameters(curve.getCurve().decodePoint(publicKey), domain));
DLSequence seq = (DLSequence) asn1.readObject();
BigInteger r = ((ASN1Integer) seq.getObjectAt(0)).getPositiveValue();
BigInteger s = ((ASN1Integer) seq.getObjectAt(1)).getPositiveValue();
return signer.verifySignature(hash, r, s);
} catch (Exception e) {
return false;
} finally {
try {
asn1.close();
} catch (IOException ignored) {
}
}
}
示例2: 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);
}
}
示例3: toASN1Primitive
import org.bouncycastle.asn1.DLSequence; //导入依赖的package包/类
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
for (int i = 0; i != info.length; i++)
{
v.add(info[i]);
}
if (isBer)
{
return new BERSequence(v);
}
else
{
return new DLSequence(v);
}
}
示例4: toASN1Primitive
import org.bouncycastle.asn1.DLSequence; //导入依赖的package包/类
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* ContentInfo ::= SEQUENCE {
* contentType ContentType,
* content
* [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
* </pre>
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(contentType);
if (content != null)
{
v.add(new BERTaggedObject(true, 0, content));
}
if (isBer)
{
return new BERSequence(v);
}
else
{
return new DLSequence(v);
}
}
示例5: 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;
}
}
示例6: 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());
}
示例7: 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());
}
示例8: 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;
}
}
示例9: KerberosRelevantAuthData
import org.bouncycastle.asn1.DLSequence; //导入依赖的package包/类
public KerberosRelevantAuthData ( byte[] token, Map<Integer, KerberosKey> keys ) throws PACDecodingException {
DLSequence authSequence;
try {
try ( ASN1InputStream stream = new ASN1InputStream(new ByteArrayInputStream(token)) ) {
authSequence = ASN1Util.as(DLSequence.class, stream);
}
}
catch ( IOException e ) {
throw new PACDecodingException("Malformed kerberos ticket", e);
}
this.authorizations = new ArrayList<>();
Enumeration<?> authElements = authSequence.getObjects();
while ( authElements.hasMoreElements() ) {
DLSequence authElement = ASN1Util.as(DLSequence.class, authElements);
ASN1Integer authType = ASN1Util.as(ASN1Integer.class, ASN1Util.as(DERTaggedObject.class, authElement, 0));
DEROctetString authData = ASN1Util.as(DEROctetString.class, ASN1Util.as(DERTaggedObject.class, authElement, 1));
this.authorizations.addAll(KerberosAuthData.parse(authType.getValue().intValue(), authData.getOctets(), keys));
}
}
示例10: 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;
}
示例11: 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;
}
}
示例12: 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;
}
示例13: parseDG15
import org.bouncycastle.asn1.DLSequence; //导入依赖的package包/类
private void parseDG15(byte[] DG15) {
try (ASN1InputStream bIn = new ASN1InputStream(DG15)) {
DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();
ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
byte[] data = ((ASN1Primitive)seq.getObjects().nextElement()).getEncoded();
Log.d(getClass().getName(), "Data = "+ Bytes.hexString(data));
try (ASN1InputStream in = new ASN1InputStream(data)) {
Enumeration seq1 = ((DLSequence) in.readObject()).getObjects();
while (seq1.hasMoreElements()) {
ASN1Primitive obj = (ASN1Primitive)seq1.nextElement();
byte[] data1 = obj.getEncoded();
Log.d(getClass().getName(), "data1 = "+ Bytes.hexString(data1));
if (data1[0] == (byte) 0x01) {
this.set18(data1[2] == 0x01);
} else if (data1[0] == (byte) 0x02) {
this.setAge(Bytes.toInt(data1[2]));
}
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例14: parseDG16
import org.bouncycastle.asn1.DLSequence; //导入依赖的package包/类
private void parseDG16(byte[] DG16) {
try (ASN1InputStream bIn = new ASN1InputStream(DG16)) {
DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();
ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
byte[] data = ((ASN1Primitive)seq.getObjects().nextElement()).getEncoded();
Log.d(getClass().getName(), "Data = "+ Bytes.hexString(data));
try (ASN1InputStream in = new ASN1InputStream(data)) {
Enumeration seq1 = ((DLSequence) in.readObject()).getObjects();
while (seq1.hasMoreElements()) {
ASN1Primitive obj = (ASN1Primitive)seq1.nextElement();
byte[] data1 = obj.getEncoded();
Log.d(getClass().getName(), "data1 = "+ Bytes.hexString(data1));
if (data1[0] == (byte) 0x01) {
this.set21(data1[2] == 0x01);
} else if (data1[0] == (byte) 0x02) {
this.setAge(Bytes.toInt(data1[2]));
}
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例15: parseDG15
import org.bouncycastle.asn1.DLSequence; //导入依赖的package包/类
private void parseDG15(byte[] DG15) {
try (ASN1InputStream bIn = new ASN1InputStream(DG15)) {
DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();
ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
byte[] data = ((ASN1Primitive)seq.getObjects().nextElement()).getEncoded();
try (ASN1InputStream in = new ASN1InputStream(data)) {
Enumeration seq1 = ((DLSequence) in.readObject()).getObjects();
while (seq1.hasMoreElements()) {
ASN1Primitive obj = (ASN1Primitive)seq1.nextElement();
byte[] data1 = obj.getEncoded();
if (data1[0] == (byte) 0x01) {
this.set18(data1[2] == 0x01);
} else if (data1[0] == (byte) 0x02) {
// Value of the age check
} else if (data1[0] == (byte) 0x04) {
// Random
}
}
}
} catch (IOException e) {
Log.e(getClass().getName(), e.getMessage(), e);
}
}