iaik.pkcs.pkcs12
Class SafeBag

java.lang.Object
  |
  +--iaik.pkcs.pkcs12.Attributes
        |
        +--iaik.pkcs.pkcs12.SafeBag
Direct Known Subclasses:
CertificateBag, KeyBag

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
 }
 

See Also:
AuthenticatedSafe, PKCS12

Constructor Summary
protected SafeBag()
          Default Constructor.
protected SafeBag(java.lang.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.
 ObjectID getBagType()
          Returns the type of this SafeBag.
protected static SafeBag[] parseSafeContents(DerInputStream safeContents)
          Parses the SafeContents data structure and returns the included SafeBags.
static void register(ObjectID oid, java.lang.Class cls)
          Registers a new implementation for a PKCS#12 SafeBag defined through the given ObjectID.
 java.lang.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
 

Constructor Detail

SafeBag

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

SafeBag

protected SafeBag(java.lang.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,
                            java.lang.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

parseSafeContents

protected static SafeBag[] parseSafeContents(DerInputStream 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

getBagType

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

Possible values are:

Returns:
the type of this SafeBag
See Also:
ObjectID

toString

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