iaik.pkcs.pkcs12
Class SafeBag

java.lang.Object
  |
  +--iaik.pkcs.pkcs12.Attributes
        |
        +--iaik.pkcs.pkcs12.SafeBag
All Implemented Interfaces:
ASN1Type
Direct Known Subclasses:
CertificateBag, CRLBag, KeyBag, SafeContentsBag, SecretBag

public abstract class SafeBag
extends Attributes
implements ASN1Type

This class implements the PKCS#12 structure SafeBag.

The PKCS#12 Personal Information Exchange Syntax Standard defines the SafeBag structure as collection of one particular piece of information (a key, a certificate, ...) and some additional attributes for forming the basic building block of a PFX PDU:

 SafeBag :== SEQUENCE {
  bagType         OBJECT IDENTIFIER,
  bagContent      [0] EXPLICIT ANY DEFINED BY bagType,
  bagAttributes   Attributes OPTIONAL   -- from X.501
 }
 

Version:
File Revision 20
See Also:
AuthenticatedSafe, PKCS12

Constructor Summary
protected SafeBag()
          Default Constructor.
protected SafeBag(String friendlyName, byte[] localKeyID)
          Creates a new SafeBag from a friendly name and a local key ID.
 
Method Summary
static SafeBag create(ObjectID oid)
          Creates a new SafeBag from a given ObjectID.
protected static byte[] encodeSafeContents(SafeBag[] safeBags)
          Creates the SafeContants byte array as needed by AuthenticatedSafe from an array of SafeBags.
protected static ASN1Object encodeSafeContentsAsASN1Object(SafeBag[] safeBags)
          Creates the SafeContants ASN1Object as needed by SafeContentsBag from an array of SafeBags.
 ObjectID getBagType()
          Returns the type of this SafeBag.
protected static SafeBag[] parseSafeContents(ASN1Object safeContents)
          Parses the SafeContents data structure and returns the included SafeBags.
protected static SafeBag[] parseSafeContents(byte[] safeContents)
          Parses the SafeContents data structure and returns the included SafeBags.
static void register(ObjectID oid, Class cls)
          Registers a new implementation for a PKCS#12 SafeBag defined through the given ObjectID.
 String toString()
          Returns a String representation of these Attributes.
 
Methods inherited from class iaik.pkcs.pkcs12.Attributes
getAttributes, getFriendlyName, getLocalKeyID, setAttributes, setFriendlyName, setLocalKeyID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface iaik.asn1.ASN1Type
decode, toASN1Object
 

Constructor Detail

SafeBag

protected SafeBag()
Default Constructor. Creates an empty SafeBag object. Implements the ASN1Type interface.

SafeBag

protected SafeBag(String friendlyName,
                  byte[] localKeyID)
Creates a new SafeBag from a friendly name and a local key ID.
Method Detail

create

public static SafeBag create(ObjectID oid)
                      throws PKCSException
Creates a new SafeBag from a given ObjectID.
Parameters:
oid - the object id of the bag to create
Returns:
the just created SafeBag
Throws:
PKCSException - if there is no bag type registered for the given object id

register

public static void register(ObjectID oid,
                            Class cls)
Registers a new implementation for a PKCS#12 SafeBag defined through the given ObjectID.
Parameters:
oid - the object id of the PKCS#12 SafeBag to be registered
cls - the implementing class

encodeSafeContents

protected static byte[] encodeSafeContents(SafeBag[] safeBags)
                                    throws CodingException
Creates the SafeContants byte array as needed by AuthenticatedSafe from an array of SafeBags.
Parameters:
safeBags - the SafeBags to encode
Returns:
the SafeBags as DER encoded Sequence of SafeBag

encodeSafeContentsAsASN1Object

protected static ASN1Object encodeSafeContentsAsASN1Object(SafeBag[] safeBags)
                                                    throws CodingException
Creates the SafeContants ASN1Object as needed by SafeContentsBag from an array of SafeBags.
Parameters:
safeBags - the SafeBags to encode
Returns:
the SafeBags as ASN1Object of SafeBag

parseSafeContents

protected static SafeBag[] parseSafeContents(byte[] safeContents)
                                      throws CodingException
Parses the SafeContents data structure and returns the included SafeBags.
Parameters:
safeContents - the SafeContents ASN.1 structure as byte array
Returns:
the SafeBags within this SafeContents
Throws:
CodingException - if an error occurs during parsing the safe contents

parseSafeContents

protected static SafeBag[] parseSafeContents(ASN1Object safeContents)
                                      throws CodingException
Parses the SafeContents data structure and returns the included SafeBags.
Parameters:
safeContents - the SafeContents ASN.1 structure as ASN1Object
Returns:
the SafeBags within this SafeContents
Throws:
CodingException - if an error occurs during parsing the safe contents

getBagType

public ObjectID getBagType()
Returns the type of this SafeBag.

Possible values are:

Returns:
the type of this SafeBag
See Also:
ObjectID

toString

public String toString()
Returns a String representation of these Attributes.
Overrides:
toString in class Attributes

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK