本文整理汇总了Java中org.bouncycastle.asn1.DERBoolean类的典型用法代码示例。如果您正苦于以下问题:Java DERBoolean类的具体用法?Java DERBoolean怎么用?Java DERBoolean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DERBoolean类属于org.bouncycastle.asn1包,在下文中一共展示了DERBoolean类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: X509Extensions
import org.bouncycastle.asn1.DERBoolean; //导入依赖的package包/类
/**
* Constructor from ASN1Sequence.
*
* the extensions are a list of constructed sequences, either with (OID, OctetString) or (OID, Boolean, OctetString)
*/
public X509Extensions(
ASN1Sequence seq)
{
Enumeration e = seq.getObjects();
while (e.hasMoreElements())
{
ASN1Sequence s = ASN1Sequence.getInstance(e.nextElement());
if (s.size() == 3)
{
extensions.put(s.getObjectAt(0), new X509Extension(DERBoolean.getInstance(s.getObjectAt(1)), ASN1OctetString.getInstance(s.getObjectAt(2))));
}
else if (s.size() == 2)
{
extensions.put(s.getObjectAt(0), new X509Extension(false, ASN1OctetString.getInstance(s.getObjectAt(1))));
}
else
{
throw new IllegalArgumentException("Bad sequence size: " + s.size());
}
ordering.addElement(s.getObjectAt(0));
}
}
示例2: toASN1Primitive
import org.bouncycastle.asn1.DERBoolean; //导入依赖的package包/类
/**
* <pre>
* Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
*
* Extension ::= SEQUENCE {
* extnId EXTENSION.&id ({ExtensionSet}),
* critical BOOLEAN DEFAULT FALSE,
* extnValue OCTET STRING }
* </pre>
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector vec = new ASN1EncodableVector();
Enumeration e = ordering.elements();
while (e.hasMoreElements())
{
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
X509Extension ext = (X509Extension)extensions.get(oid);
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(oid);
if (ext.isCritical())
{
v.add(DERBoolean.TRUE);
}
v.add(ext.getValue());
vec.add(new DERSequence(v));
}
return new DERSequence(vec);
}
示例3: toASN1Object
import org.bouncycastle.asn1.DERBoolean; //导入依赖的package包/类
/**
* <pre>
* Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
*
* Extension ::= SEQUENCE {
* extnId EXTENSION.&id ({ExtensionSet}),
* critical BOOLEAN DEFAULT FALSE,
* extnValue OCTET STRING }
* </pre>
*/
public DERObject toASN1Object()
{
ASN1EncodableVector vec = new ASN1EncodableVector();
Enumeration e = ordering.elements();
while (e.hasMoreElements())
{
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
X509Extension ext = (X509Extension)extensions.get(oid);
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(oid);
if (ext.isCritical())
{
v.add(new DERBoolean(true));
}
v.add(ext.getValue());
vec.add(new DERSequence(v));
}
return new DERSequence(vec);
}
示例4: BasicConstraints
import org.bouncycastle.asn1.DERBoolean; //导入依赖的package包/类
/**
* @deprecated use one of the other two unambigous constructors.
* @param cA
* @param pathLenConstraint
*/
public BasicConstraints(
boolean cA,
int pathLenConstraint)
{
if (cA)
{
this.cA = new DERBoolean(cA);
this.pathLenConstraint = new DERInteger(pathLenConstraint);
}
else
{
this.cA = null;
this.pathLenConstraint = null;
}
}
示例5: getBasicConstraints
import org.bouncycastle.asn1.DERBoolean; //导入依赖的package包/类
/**
* Creates a <code>BasicConstraints</code> object from given
* extension.
*
* @param ext the extension.
* @return the <code>BasicConstraints</code> object.
* @exception IOException if something fails.
*/
public static BasicConstraints getBasicConstraints(X509Extension ext)
throws IOException {
DERObject obj = BouncyCastleUtil.getExtensionObject(ext);
if (obj instanceof ASN1Sequence) {
ASN1Sequence seq = (ASN1Sequence)obj;
int size = seq.size();
if (size == 0) {
return new BasicConstraints(false);
} else if (size == 1) {
DEREncodable value = seq.getObjectAt(0);
if (value instanceof DERInteger) {
int length = ((DERInteger)value).getValue().intValue();
return new BasicConstraints(false, length);
} else if (value instanceof DERBoolean) {
boolean ca = ((DERBoolean)value).isTrue();
return new BasicConstraints(ca);
}
}
}
return BasicConstraints.getInstance(obj);
}
示例6: BasicConstraints
import org.bouncycastle.asn1.DERBoolean; //导入依赖的package包/类
private BasicConstraints(
ASN1Sequence seq)
{
if (seq.size() == 0)
{
this.cA = null;
this.pathLenConstraint = null;
}
else
{
if (seq.getObjectAt(0) instanceof DERBoolean)
{
this.cA = DERBoolean.getInstance(seq.getObjectAt(0));
}
else
{
this.cA = null;
this.pathLenConstraint = ASN1Integer.getInstance(seq.getObjectAt(0));
}
if (seq.size() > 1)
{
if (this.cA != null)
{
this.pathLenConstraint = ASN1Integer.getInstance(seq.getObjectAt(1));
}
else
{
throw new IllegalArgumentException("wrong sequence in constructor");
}
}
}
}
示例7: X509Extension
import org.bouncycastle.asn1.DERBoolean; //导入依赖的package包/类
public X509Extension(
DERBoolean critical,
ASN1OctetString value)
{
this.critical = critical.isTrue();
this.value = value;
}
示例8: IssuingDistributionPoint
import org.bouncycastle.asn1.DERBoolean; //导入依赖的package包/类
/**
* Constructor from ASN1Sequence
*/
public IssuingDistributionPoint(
ASN1Sequence seq)
{
this.seq = seq;
for (int i = 0; i != seq.size(); i++)
{
ASN1TaggedObject o = ASN1TaggedObject.getInstance(seq.getObjectAt(i));
switch (o.getTagNo())
{
case 0:
// CHOICE so explicit
distributionPoint = DistributionPointName.getInstance(o, true);
break;
case 1:
onlyContainsUserCerts = DERBoolean.getInstance(o, false).isTrue();
break;
case 2:
onlyContainsCACerts = DERBoolean.getInstance(o, false).isTrue();
break;
case 3:
onlySomeReasons = new ReasonFlags(ReasonFlags.getInstance(o, false));
break;
case 4:
indirectCRL = DERBoolean.getInstance(o, false).isTrue();
break;
case 5:
onlyContainsAttributeCerts = DERBoolean.getInstance(o, false).isTrue();
break;
default:
throw new IllegalArgumentException(
"unknown tag in IssuingDistributionPoint");
}
}
}
示例9: checkedSortedSet
import org.bouncycastle.asn1.DERBoolean; //导入依赖的package包/类
private void checkedSortedSet(int attempt, ASN1Set s)
{
if (s.getObjectAt(0) instanceof DERBoolean
&& s.getObjectAt(1) instanceof DERInteger
&& s.getObjectAt(2) instanceof DERBitString
&& s.getObjectAt(3) instanceof DEROctetString)
{
return;
}
fail("sorting failed on attempt: " + attempt);
}
示例10: perform
import org.bouncycastle.asn1.DERBoolean; //导入依赖的package包/类
public TestResult perform()
{
byte[] data = { 0, 1, 0, 1, 0, 0, 1 };
ASN1Primitive values[] = {
new BERConstructedOctetString(data),
new BERSequence(new DERPrintableString("hello world")),
new BERSet(new DERPrintableString("hello world")),
new BERTaggedObject(0, new DERPrintableString("hello world")),
new DERApplicationSpecific(0, data),
new DERBitString(data),
new DERBMPString("hello world"),
new DERBoolean(true),
new DERBoolean(false),
new DEREnumerated(100),
new DERGeneralizedTime("20070315173729Z"),
new DERGeneralString("hello world"),
new DERIA5String("hello"),
new DERInteger(1000),
new DERNull(),
new DERNumericString("123456"),
new DERObjectIdentifier("1.1.1.10000.1"),
new DEROctetString(data),
new DERPrintableString("hello world"),
new DERSequence(new DERPrintableString("hello world")),
new DERSet(new DERPrintableString("hello world")),
new DERT61String("hello world"),
new DERTaggedObject(0, new DERPrintableString("hello world")),
new DERUniversalString(data),
new DERUTCTime(new Date()),
new DERUTF8String("hello world"),
new DERVisibleString("hello world")
};
try
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
ASN1OutputStream aOut = new ASN1OutputStream(bOut);
for (int i = 0; i != values.length; i++)
{
aOut.writeObject(values[i]);
}
ASN1Primitive[] readValues = new ASN1Primitive[values.length];
ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
ASN1InputStream aIn = new ASN1InputStream(bIn);
for (int i = 0; i != values.length; i++)
{
ASN1Primitive o = aIn.readObject();
if (!o.equals(values[i]))
{
return new SimpleTestResult(false, getName() + ": Failed equality test for " + o.getClass());
}
if (o.hashCode() != values[i].hashCode())
{
return new SimpleTestResult(false, getName() + ": Failed hashCode test for " + o.getClass());
}
}
}
catch (Exception e)
{
return new SimpleTestResult(false, getName() + ": Failed - exception " + e.toString(), e);
}
return new SimpleTestResult(true, getName() + ": Okay");
}
示例11: setExtensions
import org.bouncycastle.asn1.DERBoolean; //导入依赖的package包/类
private void setExtensions() throws Exception
{
try
{
Vector<DERObjectIdentifier> myOIDs = new Vector<DERObjectIdentifier>() ;
Hashtable<DERObjectIdentifier,X509Extension> myExtensions = new Hashtable<DERObjectIdentifier,X509Extension>() ;
//--------------------------------------------------------------------------
// id-ce-noRevAvail
ByteArrayOutputStream a = new ByteArrayOutputStream() ;
new DEROutputStream( a ).writeObject( ( new DERNull() ).toASN1Object() ) ;
ASN1OctetString nraOctetString = ASN1OctetString.getInstance( new DEROctetString( a.toByteArray() ) ) ;
X509Extension nraExtension = new X509Extension( new DERBoolean( false ) , nraOctetString ) ;
DERObjectIdentifier nraOID = new DERObjectIdentifier( "2.5.29.56" ) ;
myOIDs.add( nraOID ) ;
myExtensions.put( nraOID , nraExtension ) ;
//--------------------------------------------------------------------------
// AuthorityKeyIdentifier
myLogger.warn("VOMSAttributeCertificate verification not implemented yet.");
// String issuerDN = this.getIssuer() ;
//
// String serverName = "unknown" ;
// //serverName = VirtualOrganisation.getServer( issuerDN ) ;
//
// if( ! serverName.equals( "unknown" ) )
// {
// String vomsServerCredentialLocation = new String( System.getProperty( "user.home" ) + "/gridsecurity/certificates/voms-server-certificates/" + serverName ) ;
//
// X509Certificate vomsServerCredential = CertUtil.loadCertificate( vomsServerCredentialLocation ) ;
//
// PublicKey pk = vomsServerCredential.getPublicKey() ;
//
// SubjectPublicKeyInfo spki = new SubjectPublicKeyInfo( (ASN1Sequence) new ASN1InputStream( new ByteArrayInputStream( pk.getEncoded() ) ).readObject() ) ;
// AuthorityKeyIdentifier aki = new AuthorityKeyIdentifier( spki ) ;
//
// // not clear why this does not work...
// // DEROctetString akiOctetString = (DEROctetString) DEROctetString.getInstance( akiSequence.getDERObject() ) ;
//
// // These three lines get to the desired result...
// ByteArrayOutputStream b = new ByteArrayOutputStream() ;
// new DEROutputStream( b ).writeObject( aki.toASN1Object() ) ;
// ASN1OctetString akiOctetString = ASN1OctetString.getInstance( new DEROctetString( b.toByteArray() ) ) ;
//
// X509Extension akiExtension = new X509Extension( new DERBoolean( false ) , akiOctetString ) ;
// DERObjectIdentifier akiOID = new DERObjectIdentifier( "2.5.29.35" ) ;
//
// myOIDs.add( akiOID ) ;
// myExtensions.put( akiOID , akiExtension ) ;
//
// this.extensions = new X509Extensions( myOIDs , myExtensions ) ;
//
// }
}
catch( Exception e )
{
myLogger.error(e);
//e.printStackTrace() ;
}
}