public class

IdentityDatabase

extends IdentityScope
implements Serializable
java.lang.Object
   ↳ java.security.Identity
     ↳ java.security.IdentityScope
       ↳ sun.security.provider.IdentityDatabase

Class Overview

An implementation of IdentityScope as a persistent identity database.

See Also

Summary

Public Constructors
IdentityDatabase(File file)
Construct a new, empty database with a specified source file.
IdentityDatabase(String name)
Construct a new, empty database.
Public Methods
void addIdentity(Identity identity)
Adds an identity to the database.
static IdentityDatabase fromFile(File f)
Initialize an IdentityDatabase from file.
static IdentityDatabase fromStream(InputStream is)
Initialize an identity database from a stream.
Identity getIdentity(String name)
Returns the identity in this scope with the specified name (if any).
Identity getIdentity(PublicKey key)
Get an identity by key.
Enumeration<Identity> identities()
Returns an enumeration of all identities in this identity scope.
void removeIdentity(Identity identity)
Removes an identity to the database.
void save()
Saves the database to the default source file.
void save(OutputStream os)
Save the database in its current state to an output stream.
int size()
Returns the number of identities within this identity scope.
String toString()
Returns a string representation of this identity scope, including its name, its scope name, and the number of identities in this identity scope.
[Expand]
Inherited Methods
From class java.security.IdentityScope
From class java.security.Identity
From class java.lang.Object
From interface java.security.Principal

Public Constructors

public IdentityDatabase (File file)

Construct a new, empty database with a specified source file.

Parameters
file the source file.

public IdentityDatabase (String name)

Construct a new, empty database.

Public Methods

public void addIdentity (Identity identity)

Adds an identity to the database.

Parameters
identity the identity to be added.
Throws
KeyManagementException if a name or key clash occurs, or if another exception occurs.

public static IdentityDatabase fromFile (File f)

Initialize an IdentityDatabase from file.

Parameters
f the filename where the identity database is stored.
Throws
IOException a file-related exception occurs (e.g. the directory of the file passed does not exists, etc.

public static IdentityDatabase fromStream (InputStream is)

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
IOException if a stream IO exception occurs

public Identity getIdentity (String name)

Returns the identity in this scope with the specified name (if any).

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.

public Identity getIdentity (PublicKey key)

Get an identity by key.

Parameters
key the public key for the identity to be returned.
Returns
  • the identity with a given key, or null if there are no identities with that key in the database.

public Enumeration<Identity> identities ()

Returns an enumeration of all identities in this identity scope.

Returns
  • an enumeration of all identities in the database.

public void removeIdentity (Identity identity)

Removes an identity to the database.

Parameters
identity the identity to be removed.

public void save ()

Saves the database to the default source file.

Throws
KeyManagementException when there is no default source file specified for this database.
IOException

public void save (OutputStream os)

Save the database in its current state to an output stream.

Parameters
os the output stream to which the database should be serialized.
Throws
IOException if an IO exception is raised by stream operations.

public int size ()

Returns the number of identities within this identity scope.

Returns
  • the number of identities in the database.

public String toString ()

Returns a string representation of this identity scope, including its name, its scope name, and the number of identities in this identity scope.

Returns
  • a string representation of this identity scope.