com.ibm.crypto.fips.provider
Class IdentityDatabase
- java.lang.Object
java.security.Identity
java.security.IdentityScope
com.ibm.crypto.fips.provider.IdentityDatabase
All implemented interfaces:
java.io.Serializable, java.security.Principal
- public class IdentityDatabase
- extends java.security.IdentityScope
- implements java.io.Serializable
See Also:
Constructor Summary
Constructor and Description |
---|
IdentityDatabase(java.io.File file)
Construct a new, empty database with a specified source file.
|
IdentityDatabase(java.lang.String name)
Construct a new, empty database.
|
Method Summary
Modifier and Type | Method and Description |
---|---|
|
addIdentity(java.security.Identity identity)
Adds an identity to the database.
|
|
fromFile(java.io.File f)
Initialize an IdentityDatabase from file.
|
|
fromStream(java.io.InputStream is)
Initialize an identity database from a stream.
|
|
getIdentity(java.security.PublicKey key)
Get an identity by key.
|
|
getIdentity(java.lang.String name)
|
|
identities()
|
|
removeIdentity(java.security.Identity identity)
Removes an identity to the database.
|
|
save()
Saves the database to the default source file.
|
|
save(java.io.OutputStream os)
Save the database in its current state to an output stream.
|
|
size()
|
|
toString()
|
Methods inherited from class java.security.IdentityScope |
---|
getIdentity, getSystemScope, setSystemScope |
Methods inherited from class java.security.Identity |
---|
addCertificate, certificates, equals, getInfo, getName, getPublicKey, getScope, hashCode, identityEquals, removeCertificate, setInfo, setPublicKey, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail
IdentityDatabase
- public IdentityDatabase(java.io.File file)
- throws java.security.InvalidParameterException
Construct a new, empty database with a specified source file.
Parameters:
file
- the source file. Throws:
java.security.InvalidParameterException
IdentityDatabase
- public IdentityDatabase(java.lang.String name)
- throws java.security.InvalidParameterException
Construct a new, empty database.
Throws:
java.security.InvalidParameterException
Method Detail
fromStream
- public static IdentityDatabase fromStream( java.io.InputStream is)
- throws java.io.IOException
Initialize an identity database from a stream. The stream should
contain data to initialized a serialized IdentityDatabase
object.
Parameters:
is
- the input stream from which to restore the database. Throws:
java.io.IOException
- if a stream IO exception occurs fromFile
- public static IdentityDatabase fromFile( java.io.File f)
- throws java.io.IOException
Initialize an IdentityDatabase from file.
Parameters:
f
- the filename where the identity database is stored. Throws:
java.io.IOException
- a file-related exception occurs (e.g.
the directory of the file passed does not exists, etc. size
- public int size()
Specified by:
size
in class java.security.IdentityScope
Returns:
the number of identities in the database.
getIdentity
- public java.security.Identity getIdentity( java.lang.String name)
Specified by:
getIdentity
in class java.security.IdentityScope
Parameters:
name
- the name of the identity to be retrieved. Returns:
the identity named name, or null if there are
no identities named name in the database.
getIdentity
- public java.security.Identity getIdentity( java.security.PublicKey key)
Get an identity by key.
Specified by:
getIdentity
in class java.security.IdentityScope
Returns:
the identity with a given key, or null if there are no
identities with that key in the database.
addIdentity
- public void addIdentity(java.security.Identity identity)
- throws java.security.KeyManagementException
Adds an identity to the database.
Specified by:
addIdentity
in class java.security.IdentityScope
Parameters:
identity
- the identity to be added. Throws:
java.security.KeyManagementException
- if a name or key clash
occurs, or if another exception occurs. removeIdentity
- public void removeIdentity(java.security.Identity identity)
- throws java.security.KeyManagementException
Removes an identity to the database.
Specified by:
removeIdentity
in class java.security.IdentityScope
Throws:
java.security.KeyManagementException
identities
- public java.util.Enumeration identities( )
Specified by:
identities
in class java.security.IdentityScope
Returns:
an enumeration of all identities in the database.
save
- public void save(java.io.OutputStream os)
- throws java.io.IOException
Save the database in its current state to an output stream.
Parameters:
os
- the output stream to which the database should be serialized. Throws:
java.io.IOException
- if an IO exception is raised by stream
operations. save
- public void save()
- throws java.io.IOException
Saves the database to the default source file.
Throws:
java.io.IOException
- when there is no default source
file specified for this database. toString
- public java.lang.String toString( )
Specified by:
toString
in interface java.security.Principal
Overrides:
toString
in class java.security.IdentityScope