FileDocCategorySizeDatePackage
XYZFileScope.javaAPI DocExample3624Sun Oct 25 18:13:36 GMT 1998None

XYZFileScope

public class XYZFileScope extends IdentityScope

Fields Summary
private Hashtable
ids
private static String
fname
Constructors Summary
public XYZFileScope(String fname)

		super("XYZFileScope");
		this.fname = fname;
		try {
			FileInputStream fis = new FileInputStream(fname);
			ObjectInputStream ois = new ObjectInputStream(fis);
			ids = (Hashtable) ois.readObject();
		} catch (FileNotFoundException fnfe) {
			ids = new Hashtable();
		} catch (Exception e) {
			System.out.println(e);
			throw new KeyManagementException("Can't load identity database " + fname);
		}
	
Methods Summary
public voidaddIdentity(java.security.Identity identity)

		String name = identity.getName();
		if (getIdentity(name) != null)
			throw new KeyManagementException(name + " already in identity scope");

		PublicKey k = identity.getPublicKey();
		if (getIdentity(k) != null)
			throw new KeyManagementException(name + " already in identity scope");
		ids.put(name, identity);
	
public java.security.IdentitygetIdentity(java.lang.String name)

		Identity id;
		id = (Identity) ids.get(name);
		return id;
	
public java.security.IdentitygetIdentity(java.security.PublicKey key)

		if (key == null)
			return null;
		Identity id;
		for (Enumeration e = ids.elements(); e.hasMoreElements(); ) {
			id = (Identity) e.nextElement();
			PublicKey k = id.getPublicKey();
			if (k != null && k.equals(key))
				return id;
		}
		return null;
	
public java.util.Enumerationidentities()

		return ids.elements();
	
public voidremoveIdentity(java.security.Identity identity)

		String name = identity.getName();
		if (ids.get(name) == null)
			throw new KeyManagementException(name + " isn't in the identity scope");
		ids.remove(name);
	
public voidsave()

		try {
			FileOutputStream fos = new FileOutputStream(fname);
			ObjectOutputStream oos = new ObjectOutputStream(fos);
			oos.writeObject(ids);
		} catch (Exception e) {
			System.out.println(e);
			throw new RuntimeException("Can't save id database");
		}
	
public intsize()

		return ids.size();