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:
AlgorithmStatus, java.security.Principal, java.io.Serializable

public class IdentityDatabase
extends java.security.IdentityScope
implements java.io.Serializable, AlgorithmStatus

An implementation of IdentityScope as a persistent identity database.

Version:
1.36, 07/07/98
Author:
Benjamin Renaud
See Also:
Identity, Key, Serialized Form

Constructor Summary
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
 void addIdentity(java.security.Identity identity)
          Adds an identity to the database.
static IdentityDatabase fromFile(java.io.File f)
          Initialize an IdentityDatabase from file.
static IdentityDatabase fromStream(java.io.InputStream is)
          Initialize an identity database from a stream.
 java.security.Identity getIdentity(java.security.PublicKey key)
          Get an identity by key.
 java.security.Identity getIdentity(java.lang.String name)
           
 java.util.Enumeration identities()
           
 boolean isFipsApproved()
          Module identifies if the cryptographic operation (algorithm) is FIPS certified
 void removeIdentity(java.security.Identity identity)
          Removes an identity to the database.
 void save()
          Saves the database to the default source file.
 void save(java.io.OutputStream os)
          Save the database in its current state to an output stream.
 int size()
           
 java.lang.String 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.

IdentityDatabase

public IdentityDatabase(java.lang.String name)
                 throws java.security.InvalidParameterException
Construct a new, empty database.
Method Detail

isFipsApproved

public boolean isFipsApproved()
Description copied from interface: AlgorithmStatus
Module identifies if the cryptographic operation (algorithm) is FIPS certified
Specified by:
isFipsApproved in interface AlgorithmStatus
See Also:
AlgorithmStatus.isFipsApproved()

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
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

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.
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

size

public int size()
Overrides:
size in class java.security.IdentityScope
Returns:
the number of identities in the database.
Throws:
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

getIdentity

public java.security.Identity getIdentity(java.lang.String name)
Overrides:
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.
Throws:
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

getIdentity

public java.security.Identity getIdentity(java.security.PublicKey key)
Get an identity by key.
Overrides:
getIdentity in class java.security.IdentityScope
Parameters:
name - the key of the identity to be retrieved.
Returns:
the identity with a given key, or null if there are no identities with that key in the database.
Throws:
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

addIdentity

public void addIdentity(java.security.Identity identity)
                 throws java.security.KeyManagementException
Adds an identity to the database.
Overrides:
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.
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

removeIdentity

public void removeIdentity(java.security.Identity identity)
                    throws java.security.KeyManagementException
Removes an identity to the database.
Overrides:
removeIdentity in class java.security.IdentityScope
Throws:
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

identities

public java.util.Enumeration identities()
Overrides:
identities in class java.security.IdentityScope
Returns:
an enumeration of all identities in the database.
Throws:
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

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.
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

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.
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

toString

public java.lang.String toString()
Overrides:
toString in class java.security.IdentityScope
Throws:
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.