当前位置: 首页>>代码示例>>Java>>正文


Java DEREnumerated类代码示例

本文整理汇总了Java中org.bouncycastle.asn1.DEREnumerated的典型用法代码示例。如果您正苦于以下问题:Java DEREnumerated类的具体用法?Java DEREnumerated怎么用?Java DEREnumerated使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DEREnumerated类属于org.bouncycastle.asn1包,在下文中一共展示了DEREnumerated类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ObjectDigestInfo

import org.bouncycastle.asn1.DEREnumerated; //导入依赖的package包/类
/**
 * Constructor from given details.
 * <p>
 * If <code>digestedObjectType</code> is not {@link #publicKeyCert} or
 * {@link #publicKey} <code>otherObjectTypeID</code> must be given,
 * otherwise it is ignored.
 * 
 * @param digestedObjectType The digest object type.
 * @param otherObjectTypeID The object type ID for
 *            <code>otherObjectDigest</code>.
 * @param digestAlgorithm The algorithm identifier for the hash.
 * @param objectDigest The hash value.
 */
public ObjectDigestInfo(
    int digestedObjectType,
    String otherObjectTypeID,
    AlgorithmIdentifier digestAlgorithm,
    byte[] objectDigest)
{
    this.digestedObjectType = new DEREnumerated(digestedObjectType);
    if (digestedObjectType == otherObjectDigest)
    {
        this.otherObjectTypeID = new DERObjectIdentifier(otherObjectTypeID);
    }

    this.digestAlgorithm = digestAlgorithm; 

    this.objectDigest = new DERBitString(objectDigest);
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:30,代码来源:ObjectDigestInfo.java

示例2: RevokedInfo

import org.bouncycastle.asn1.DEREnumerated; //导入依赖的package包/类
private RevokedInfo(
    ASN1Sequence    seq)
{
    this.revocationTime = ASN1GeneralizedTime.getInstance(seq.getObjectAt(0));

    if (seq.size() > 1)
    {
        this.revocationReason = CRLReason.getInstance(DEREnumerated.getInstance(
                            (ASN1TaggedObject)seq.getObjectAt(1), true));
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:RevokedInfo.java

示例3: SpnegoTargToken

import org.bouncycastle.asn1.DEREnumerated; //导入依赖的package包/类
public SpnegoTargToken(byte[] token) throws DecodingException {
    ASN1InputStream stream = new ASN1InputStream(new ByteArrayInputStream(token));
    ASN1TaggedObject tagged;
    try {
        tagged = DecodingUtil.as(ASN1TaggedObject.class, stream);
    } catch(IOException e) {
        throw new DecodingException("spnego.token.malformed", null, e);
    }

    ASN1Sequence sequence = ASN1Sequence.getInstance(tagged, true);
    Enumeration<?> fields = sequence.getObjects();
    while(fields.hasMoreElements()) {
        tagged = DecodingUtil.as(ASN1TaggedObject.class, fields);
        switch (tagged.getTagNo()) {
        case 0:
            ASN1Enumerated enumerated = DEREnumerated.getInstance(tagged, true);
            result = enumerated.getValue().intValue();
            break;
        case 1:
            ASN1ObjectIdentifier mechanismOid = DERObjectIdentifier.getInstance(tagged, true);
            mechanism = mechanismOid.getId();
            break;
        case 2:
            ASN1OctetString mechanismTokenString = ASN1OctetString.getInstance(tagged, true);
            mechanismToken = mechanismTokenString.getOctets();
            break;
        case 3:
            ASN1OctetString mechanismListString = ASN1OctetString.getInstance(tagged, true);
            mechanismList = mechanismListString.getOctets();
            break;
        default:
            Object[] args = new Object[]{tagged.getTagNo()};
            throw new DecodingException("spnego.field.invalid", args, null);
        }
    }
}
 
开发者ID:cbsit,项目名称:JaasLounge,代码行数:37,代码来源:SpnegoTargToken.java

示例4: CRLReason

import org.bouncycastle.asn1.DEREnumerated; //导入依赖的package包/类
public CRLReason(
    DEREnumerated reason)
{
    super(reason.getValue().intValue());
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:6,代码来源:CRLReason.java

示例5: getDigestedObjectType

import org.bouncycastle.asn1.DEREnumerated; //导入依赖的package包/类
public DEREnumerated getDigestedObjectType()
{
    return digestedObjectType;
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:5,代码来源:ObjectDigestInfo.java

示例6: checkCRLCreation1

import org.bouncycastle.asn1.DEREnumerated; //导入依赖的package包/类
public void checkCRLCreation1()
    throws Exception
{
    KeyPairGenerator     kpGen = KeyPairGenerator.getInstance("RSA", "BC");
    X509V2CRLGenerator   crlGen = new X509V2CRLGenerator();
    Date                 now = new Date();
    KeyPair              pair = kpGen.generateKeyPair();
    
    crlGen.setIssuerDN(new X500Principal("CN=Test CA"));
    
    crlGen.setThisUpdate(now);
    crlGen.setNextUpdate(new Date(now.getTime() + 100000));
    crlGen.setSignatureAlgorithm("SHA256WithRSAEncryption");
    
    crlGen.addCRLEntry(BigInteger.ONE, now, CRLReason.privilegeWithdrawn);
    
    crlGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(pair.getPublic()));
    
    X509CRL    crl = crlGen.generate(pair.getPrivate(), "BC");
    
    if (!crl.getIssuerX500Principal().equals(new X500Principal("CN=Test CA")))
    {
        fail("failed CRL issuer test");
    }
    
    byte[] authExt = crl.getExtensionValue(X509Extensions.AuthorityKeyIdentifier.getId());
    
    if (authExt == null)
    {
        fail("failed to find CRL extension");
    }
    
    AuthorityKeyIdentifier authId = new AuthorityKeyIdentifierStructure(authExt);
    
    X509CRLEntry entry = crl.getRevokedCertificate(BigInteger.ONE);
    
    if (entry == null)
    {
        fail("failed to find CRL entry");
    }
    
    if (!entry.getSerialNumber().equals(BigInteger.ONE))
    {
        fail("CRL cert serial number does not match");
    }
    
    if (!entry.hasExtensions())
    {
        fail("CRL entry extension not found");
    }

    byte[]  ext = entry.getExtensionValue(X509Extensions.ReasonCode.getId());

    if (ext != null)
    {
        DEREnumerated   reasonCode = (DEREnumerated)X509ExtensionUtil.fromExtensionValue(ext);
                                                                   
        if (reasonCode.getValue().intValue() != CRLReason.privilegeWithdrawn)
        {
            fail("CRL entry reasonCode wrong");
        }
    }
    else
    {
        fail("CRL entry reasonCode not found");
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:68,代码来源:CertTest.java

示例7: perform

import org.bouncycastle.asn1.DEREnumerated; //导入依赖的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");
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:71,代码来源:EqualsAndHashCodeTest.java

示例8: toString

import org.bouncycastle.asn1.DEREnumerated; //导入依赖的package包/类
public String toString()
{
    StringBuffer buf = new StringBuffer();
    String nl = System.getProperty("line.separator");

    buf.append("      userCertificate: ").append(this.getSerialNumber()).append(nl);
    buf.append("       revocationDate: ").append(this.getRevocationDate()).append(nl);

    Extensions extensions = c.getExtensions();

    if (extensions != null)
    {
        Enumeration e = extensions.oids();
        if (e.hasMoreElements())
        {
            buf.append("   crlEntryExtensions:").append(nl);

            while (e.hasMoreElements())
            {
                ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
                Extension ext = extensions.getExtension(oid);
                if (ext.getExtnValue() != null)
                {
                    byte[]                  octs = ext.getExtnValue().getOctets();
                    ASN1InputStream dIn = new ASN1InputStream(octs);
                    buf.append("                       critical(").append(ext.isCritical()).append(") ");
                    try
                    {
                        if (oid.equals(X509Extension.reasonCode))
                        {
                            buf.append(CRLReason.getInstance(DEREnumerated.getInstance(dIn.readObject()))).append(nl);
                        }
                        else if (oid.equals(X509Extension.certificateIssuer))
                        {
                            buf.append("Certificate issuer: ").append(GeneralNames.getInstance(dIn.readObject())).append(nl);
                        }
                        else 
                        {
                            buf.append(oid.getId());
                            buf.append(" value = ").append(ASN1Dump.dumpAsString(dIn.readObject())).append(nl);
                        }
                    }
                    catch (Exception ex)
                    {
                        buf.append(oid.getId());
                        buf.append(" value = ").append("*****").append(nl);
                    }
                }
                else
                {
                    buf.append(nl);
                }
            }
        }
    }

    return buf.toString();
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:59,代码来源:X509CRLEntryObject.java

示例9: checkCRLCreation1

import org.bouncycastle.asn1.DEREnumerated; //导入依赖的package包/类
public void checkCRLCreation1()
    throws Exception
{
    KeyPairGenerator     kpGen = KeyPairGenerator.getInstance("RSA", "BC");
    X509V2CRLGenerator   crlGen = new X509V2CRLGenerator();
    Date                 now = new Date();
    KeyPair              pair = kpGen.generateKeyPair();
    
    crlGen.setIssuerDN(new X509Principal("CN=Test CA"));
    
    crlGen.setThisUpdate(now);
    crlGen.setNextUpdate(new Date(now.getTime() + 100000));
    crlGen.setSignatureAlgorithm("SHA256WithRSAEncryption");
    
    crlGen.addCRLEntry(BigInteger.ONE, now, CRLReason.privilegeWithdrawn);
    
    crlGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(pair.getPublic()));
    
    X509CRL    crl = crlGen.generate(pair.getPrivate(), "BC");
    
    if (!crl.getIssuerDN().equals(new X509Principal("CN=Test CA")))
    {
        fail("failed CRL issuer test");
    }
    
    byte[] authExt = crl.getExtensionValue(X509Extensions.AuthorityKeyIdentifier.getId());
    
    if (authExt == null)
    {
        fail("failed to find CRL extension");
    }
    
    AuthorityKeyIdentifier authId = new AuthorityKeyIdentifierStructure(authExt);
    
    X509CRLEntry entry = crl.getRevokedCertificate(BigInteger.ONE);
    
    if (entry == null)
    {
        fail("failed to find CRL entry");
    }
    
    if (!entry.getSerialNumber().equals(BigInteger.ONE))
    {
        fail("CRL cert serial number does not match");
    }
    
    if (!entry.hasExtensions())
    {
        fail("CRL entry extension not found");
    }

    byte[]  ext = entry.getExtensionValue(X509Extensions.ReasonCode.getId());

    if (ext != null)
    {
        DEREnumerated   reasonCode = (DEREnumerated)X509ExtensionUtil.fromExtensionValue(ext);
                                                                   
        if (reasonCode.getValue().intValue() != CRLReason.privilegeWithdrawn)
        {
            fail("CRL entry reasonCode wrong");
        }
    }
    else
    {
        fail("CRL entry reasonCode not found");
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:68,代码来源:CertTest.java


注:本文中的org.bouncycastle.asn1.DEREnumerated类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。