FileDocCategorySizeDatePackage
NewEmployee.javaAPI DocExample1727Mon Jan 15 13:21:04 GMT 2001javasec.samples.appc

NewEmployee

public class NewEmployee extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        try {
            IdentityScope is = IdentityScope.getSystemScope();
            Signer origSigner = (Signer) is.getIdentity(args[0]);

            System.out.println(
                        "Please insert the floppy for " + args[0]);
            System.out.print("Press enter when ready:  ");
            System.in.read();
            XYZFileScope privateScope =
                        new XYZFileScope("/floppy/floppy0/private");
            XYZSigner newSigner = new XYZSigner(args[0], privateScope);
            KeyPair kp = new KeyPair(origSigner.getPublicKey(),
                                      origSigner.getPrivateKey());
            newSigner.setKeyPair(kp);
            newSigner.setInfo(origSigner.getInfo());
            Certificate certs[] = origSigner.certificates();
            for (int i = 0; i < certs.length; i++)
                newSigner.addCertificate(certs[i]);
            newSigner.setTrust(Integer.parseInt(args[1]));
            privateScope.save();

            XYZFileScope sharedScope =
                        new XYZFileScope("/auto/shared/sharedScope");
            XYZIdentity newId = new XYZIdentity(args[0], sharedScope);
            newId.setPublicKey(origSigner.getPublicKey());
            newId.setInfo(origSigner.getInfo());
            certs = origSigner.certificates();
            for (int i = 0; i < certs.length; i++)
                newId.addCertificate(certs[i]);
            newId.setTrust(Integer.parseInt(args[1]));
            sharedScope.save();
        } catch (Exception e) {
            System.out.println(e);
        }