⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pkcs12bagattributecarrierimpl.java

📁 kmlnjlkj nlkjlkjkljl okopokipoipo oipipipo i
💻 JAVA
字号:
package org.bouncycastle.jce.provider;import org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier;import org.bouncycastle.asn1.DERObjectIdentifier;import org.bouncycastle.asn1.DEREncodable;import org.bouncycastle.asn1.ASN1OutputStream;import org.bouncycastle.asn1.ASN1InputStream;import java.util.Enumeration;import java.util.Hashtable;import java.util.Vector;import java.io.ObjectOutputStream;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.ObjectInputStream;class PKCS12BagAttributeCarrierImpl    implements PKCS12BagAttributeCarrier{    private Hashtable pkcs12Attributes;    private Vector pkcs12Ordering;    PKCS12BagAttributeCarrierImpl(Hashtable attributes, Vector ordering)    {        this.pkcs12Attributes = attributes;        this.pkcs12Ordering = ordering;    }    public PKCS12BagAttributeCarrierImpl()    {        this(new Hashtable(), new Vector());    }    public void setBagAttribute(        DERObjectIdentifier oid,        DEREncodable        attribute)    {        if (pkcs12Attributes.containsKey(oid))        {                           // preserve original ordering            pkcs12Attributes.put(oid, attribute);        }        else        {            pkcs12Attributes.put(oid, attribute);            pkcs12Ordering.addElement(oid);        }    }    public DEREncodable getBagAttribute(        DERObjectIdentifier oid)    {        return (DEREncodable)pkcs12Attributes.get(oid);    }    public Enumeration getBagAttributeKeys()    {        return pkcs12Ordering.elements();    }    int size()    {        return pkcs12Ordering.size();    }    Hashtable getAttributes()    {        return pkcs12Attributes;    }    Vector getOrdering()    {        return pkcs12Ordering;    }    public void writeObject(ObjectOutputStream out)        throws IOException    {        if (pkcs12Ordering.size() == 0)        {            out.writeObject(new Hashtable());            out.writeObject(new Vector());        }        else        {            ByteArrayOutputStream bOut = new ByteArrayOutputStream();            ASN1OutputStream aOut = new ASN1OutputStream(bOut);            Enumeration             e = this.getBagAttributeKeys();            while (e.hasMoreElements())            {                DERObjectIdentifier    oid = (DERObjectIdentifier)e.nextElement();                aOut.writeObject(oid);                aOut.writeObject(pkcs12Attributes.get(oid));            }            out.writeObject(bOut.toByteArray());        }    }    public void readObject(ObjectInputStream in)        throws IOException, ClassNotFoundException    {        Object obj = in.readObject();        if (obj instanceof Hashtable)        {            this.pkcs12Attributes = (Hashtable)obj;            this.pkcs12Ordering = (Vector)in.readObject();        }        else        {            ASN1InputStream aIn = new ASN1InputStream((byte[])obj);            DERObjectIdentifier    oid;            while ((oid = (DERObjectIdentifier)aIn.readObject()) != null)            {                this.setBagAttribute(oid, aIn.readObject());            }        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -