CertTools.installBCProvider();  ISignSessionHome home = (ISignSessionHome) javax.rmi.PortableRemoteObject.narrow(getInitialContext().lookup("RSASignSession"), ISignSessionHome.class); ISignSessionRemote ss = home.create();  Object obj = getInitialContext().lookup("UserAdminSession"); IUserAdminSessionHome userhome = (IUserAdminSessionHome) javax.rmi.PortableRemoteObject.narrow(obj, IUserAdminSessionHome.class); IUserAdminSessionRemote usersession = userhome.create();  String email = "test@test.se"; if (!usersession.existsUser(admin, user)) { keypair = KeyTools.genKeys(2048); usersession.addUser(admin, user, "foo123", "CN=TESTKEYREC", "rfc822name=" + email, email, false, SecConst.EMPTY_ENDENTITYPROFILE, SecConst.CERTPROFILE_FIXED_ENDUSER, SecConst.USER_ENDUSER, SecConst.TOKEN_SOFT_P12, 0, "CN=TEST".hashCode());  cert = (X509Certificate) ss.createCertificate(admin, user, "foo123", keypair.getPublic());
Context jndiContext = getInitialContext(); if (cacheAdmin == null) { if (cacheHome == null) { Object obj1 = jndiContext.lookup("KeyRecoverySession"); cacheHome = (IKeyRecoverySessionHome) javax.rmi.PortableRemoteObject.narrow(obj1, IKeyRecoverySessionHome.class); } cacheAdmin = cacheHome.create();
    public TestKeyRecovery(String name) {        super(name);        // Generate test keypair and certificate.        try {            CertTools.installBCProvider();            ISignSessionHome home = (ISignSessionHome) javax.rmi.PortableRemoteObject.narrow(getInitialContext().lookup("RSASignSession"), ISignSessionHome.class);            ISignSessionRemote ss = home.create();            Object obj = getInitialContext().lookup("UserAdminSession");            IUserAdminSessionHome userhome = (IUserAdminSessionHome) javax.rmi.PortableRemoteObject.narrow(obj, IUserAdminSessionHome.class);            IUserAdminSessionRemote usersession = userhome.create();            String email = "test@test.se";            if (!usersession.existsUser(admin, user)) {                keypair = KeyTools.genKeys(2048);                usersession.addUser(admin, user, "foo123", "CN=TESTKEYREC", "rfc822name=" + email, email, false, SecConst.EMPTY_ENDENTITYPROFILE, SecConst.CERTPROFILE_FIXED_ENDUSER, SecConst.USER_ENDUSER, SecConst.TOKEN_SOFT_P12, 0, "CN=TEST".hashCode());                cert = (X509Certificate) ss.createCertificate(admin, user, "foo123", keypair.getPublic());            }        } catch (Exception e) {            System.out.println("Error Creating TestKeyRecovery instance.");        }    }