|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<E> java.util.ArrayList codec.asn1.ASN1AbstractCollection codec.asn1.ASN1Sequence codec.asn1.ASN1SequenceOf codec.pkcs12.AuthenticatedSafe
public class AuthenticatedSafe
This class represents an AuthenticatedSafe
as defined in
PKCS#12. The ASN.1 definition of this structure is
AuthenticatedSafe ::= SEQUENCE OF ContentInfo --Data if unencrypted --Encrypted data if password-encrypted --Enveloped data if public-key-encrypted
PFX
The AuthenicatedSafe PDUs hold the data to be transmitted.
Field Summary | |
---|---|
int |
NO_PROTECTION
identifies no protection mode |
private static int[] |
oid_
The OID of this structure. |
int |
PASSWORD_PROTECTION
identifies password protection mode |
int |
PUBLIC_KEY_PROTECTION
identifies public-key-protection mode |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
AuthenticatedSafe()
the default constructor. |
|
AuthenticatedSafe(SafeContents safe)
Constructs a SafeContents from a SafeBag. |
|
AuthenticatedSafe(SafeContents safe,
char[] passwd,
String algorithm)
Constructs an AuthenticatedSafe and places a SafeContents in it protected by a password. |
|
AuthenticatedSafe(SafeContents safe,
SecretKey key,
String algorithm,
AlgorithmParameters params,
X509Certificate[] cert)
Creates an authenticated safe and places a SafeContents in public-key-encrypted mode inside. |
Method Summary | |
---|---|
void |
addSafeContents(SafeContents safe)
Adds a SafeContents to the AuthenticatedSafe. |
void |
addSafeContents(SafeContents safe,
char[] passwd,
String algorithm)
adds a safeContents to the AuthenticatedSafe and protects it with a password. |
void |
addSafeContents(SafeContents safe,
SecretKey key,
String algorithm,
AlgorithmParameters params,
X509Certificate[] cert)
Adds a SafeContents to the AuthenticatedSafe. |
ASN1ObjectIdentifier |
getOID()
A SafeContents can be put recursively into a SafeBag. |
int[] |
getProtectionMode()
Returns the protection mode of each SafeContents in the AuthenticatedSafe |
SafeContents |
getSafeContents(int i)
returns the contents of the SafeBag in the AuthenticatedSafe at position i, if the SafeBag is not protected. |
SafeContents |
getSafeContents(int i,
char[] passwd)
returns the contents of the SafeBag in the AuthenticatedSafe at position i, if the SafeBag is password-protected. |
SafeContents |
getSafeContents(int i,
PrivateKey key,
X509Certificate cert)
returns the contents of the SafeBag in the AuthenticatedSafe at position i, if the SafeBag is public-key-protected. |
private ContentInfo |
makeData(SafeContents safe)
returns a ContentInfo with contentType Data to feed to an AuthenticatedSafe. |
private ContentInfo |
makeEncryptedData(SafeContents safe,
char[] pwd,
String algorithm)
|
private ContentInfo |
makeEnvelopedData(SafeContents safe,
SecretKey key,
String algorithm,
AlgorithmParameters params,
X509Certificate[] cert)
|
String |
toString()
Returns a human-readable String representation of this object. |
Methods inherited from class codec.asn1.ASN1SequenceOf |
---|
decode, getElementType, newElement |
Methods inherited from class codec.asn1.ASN1Sequence |
---|
getTag |
Methods inherited from class codec.asn1.ASN1AbstractCollection |
---|
checkConstraints, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, setConstraint, setExplicit, setOptional |
Methods inherited from class java.util.ArrayList |
---|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode, iterator, listIterator, listIterator, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, removeAll, retainAll |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface codec.asn1.ASN1Collection |
---|
getCollection |
Methods inherited from interface codec.asn1.ASN1Type |
---|
checkConstraints, encode, getConstraint, getTag, getTagClass, getValue, isExplicit, isOptional, isType, setConstraint, setExplicit, setOptional |
Methods inherited from interface java.util.Collection |
---|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Methods inherited from interface java.util.List |
---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList |
Field Detail |
---|
private static final int[] oid_
public int NO_PROTECTION
public int PASSWORD_PROTECTION
public int PUBLIC_KEY_PROTECTION
Constructor Detail |
---|
public AuthenticatedSafe()
public AuthenticatedSafe(SafeContents safe) throws IOException, ASN1Exception
safe
- The SafeContents to put in the AuthenticatedSafe.
IOException
ASN1Exception
public AuthenticatedSafe(SafeContents safe, char[] passwd, String algorithm) throws IOException, ASN1Exception, GeneralSecurityException
safe
- The SafeContents to put in the AuthenticatedSafepasswd
- The password used to protect the contents of the
SafeContents.algorithm
- the PBE algorithm to be used
IOException
ASN1Exception
GeneralSecurityException
public AuthenticatedSafe(SafeContents safe, SecretKey key, String algorithm, AlgorithmParameters params, X509Certificate[] cert) throws IOException, ASN1Exception, BadNameException, GeneralSecurityException, CorruptedCodeException
EnvelopedData
and therefore requires a
secret key and a certificate.
safe
- The SafeContents to put in the AuthenticatedSafekey
- The secret key for the symmetric encryptionalgorithm
- the symmetric encryption algorithmparams
- algorithm parameters for the symmetric
encryption algorithmcert
- The certificate chain for the intended recipients of the
SafeContents
IOException
ASN1Exception
BadNameException
GeneralSecurityException
CorruptedCodeException
Method Detail |
---|
public void addSafeContents(SafeContents safe) throws IOException, ASN1Exception
safe
- the SafeContents to be added to the AuthenticatedSafe
IOException
ASN1Exception
public void addSafeContents(SafeContents safe, char[] passwd, String algorithm) throws IOException, ASN1Exception, GeneralSecurityException
safe
- The SafeContents to put in the AuthenticatedSafepasswd
- The password used to protect the contents of the
SafeContents.algorithm
- the PBE algorithm to be used
IOException
ASN1Exception
GeneralSecurityException
public void addSafeContents(SafeContents safe, SecretKey key, String algorithm, AlgorithmParameters params, X509Certificate[] cert) throws IOException, ASN1Exception, BadNameException, GeneralSecurityException, CorruptedCodeException
EnvelopedData
and therefore requires a
secret key and a certificate.
safe
- The SafeContents to put in the AuthenticatedSafekey
- The secret key for the symmetric encryptionalgorithm
- the symmetric encryption algorithmparams
- algorithm parameters for the symmetric
encryption algorithmcert
- The certificate chain for the intended recipients of the
SafeContents
IOException
ASN1Exception
BadNameException
GeneralSecurityException
CorruptedCodeException
public ASN1ObjectIdentifier getOID()
public int[] getProtectionMode()
public SafeContents getSafeContents(int i) throws IOException, ASN1Exception
i
- The integer specifying the position.
IOException
ASN1Exception
public SafeContents getSafeContents(int i, char[] passwd) throws IOException, ASN1Exception, GeneralSecurityException
i
- The integer specifying the position.
IOException
ASN1Exception
GeneralSecurityException
public SafeContents getSafeContents(int i, PrivateKey key, X509Certificate cert) throws IOException, ASN1Exception, GeneralSecurityException, NoSuchElementException
i
- The integer specifying the position.key
- the private key for decrypting the contentcert
- the certificate corresponding to the private key
IOException
ASN1Exception
GeneralSecurityException
NoSuchElementException
private ContentInfo makeData(SafeContents safe) throws IOException, ASN1Exception
IOException
ASN1Exception
private ContentInfo makeEncryptedData(SafeContents safe, char[] pwd, String algorithm) throws IOException, ASN1Exception, GeneralSecurityException
IOException
ASN1Exception
GeneralSecurityException
private ContentInfo makeEnvelopedData(SafeContents safe, SecretKey key, String algorithm, AlgorithmParameters params, X509Certificate[] cert) throws IOException, GeneralSecurityException, BadNameException, ASN1Exception, CorruptedCodeException
IOException
GeneralSecurityException
BadNameException
ASN1Exception
CorruptedCodeException
public String toString()
toString
in class ASN1AbstractCollection
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |