@Test public void testUnlocking() throws NoSuchAlgorithmException, CryptoException, AgentAccessDeniedException, InternalSecurityException, AgentLockedException, AgentOperationFailedException { String passphrase = "A passphrase to unlock"; UserAgentImpl a = UserAgentImpl.createUserAgent(passphrase); try { a.decryptSymmetricKey(null); fail("AgentLockedException should have been thrown"); } catch (AgentLockedException e) { } catch (SerializationException e) { fail("SecurityException should have been thrown"); e.printStackTrace(); } try { a.unlock("bad passphrase"); fail("SecurityException should have been thrown"); } catch (AgentAccessDeniedException e) { } try { a.decryptSymmetricKey(null); fail("AgentLockedException should have been thrown"); } catch (AgentLockedException e) { } catch (SerializationException e) { fail("AgentLockedException should have been thrown"); e.printStackTrace(); } a.unlock(passphrase); try { a.decryptSymmetricKey(null); } catch (IllegalArgumentException e) { } catch (SerializationException e) { fail("Illegal argument exception should have been thrown"); e.printStackTrace(); } }
public static UserAgentImpl createUserAgent(String passphrase) throws CryptoException, AgentOperationFailedException { byte[] salt = CryptoTools.generateSalt(); return new UserAgentImpl(CryptoTools.generateKeyPair(), passphrase, salt); }
UserAgentImpl extends PassphraseAgentImpl implements UserAgent { public static UserAgentImpl createUserAgent(String passphrase) throws CryptoException, AgentOperationFailedException { byte[] salt = CryptoTools.generateSalt(); return new UserAgentImpl(CryptoTools.generateKeyPair(), passphrase, salt); } }
UserAgentImpl extends PassphraseAgentImpl implements UserAgent { public static UserAgentImpl createUserAgent(String passphrase) throws CryptoException, AgentOperationFailedException { byte[] salt = CryptoTools.generateSalt(); return new UserAgentImpl(CryptoTools.generateKeyPair(), passphrase, salt); } protected  UserAgentImpl(KeyPair pair, String passphrase, byte[] salt); protected  UserAgentImpl(PublicKey pubKey, byte[] encryptedPrivate, byte[] salt); }
UserAgentImpl extends PassphraseAgentImpl implements UserAgent { public static UserAgentImpl createUserAgent(String passphrase) throws CryptoException, AgentOperationFailedException { byte[] salt = CryptoTools.generateSalt(); return new UserAgentImpl(CryptoTools.generateKeyPair(), passphrase, salt); } protected  UserAgentImpl(KeyPair pair, String passphrase, byte[] salt); protected  UserAgentImpl(PublicKey pubKey, byte[] encryptedPrivate, byte[] salt); @Override String getLoginName(); @Override boolean hasLoginName(); @Override void setLoginName(String loginName); @Override void setEmail(String email); @Override String toXmlString(); static UserAgentImpl createFromXml(String xml); static UserAgentImpl createUserAgent(String passphrase); static UserAgentImpl createFromXml(Element root); @Override void receiveMessage(Message message, AgentContext context); @Override void notifyUnregister(); @Override String getEmail(); @Override boolean hasEmail(); }
UserAgentImpl extends PassphraseAgentImpl implements UserAgent { public static UserAgentImpl createUserAgent(String passphrase) throws CryptoException, AgentOperationFailedException { byte[] salt = CryptoTools.generateSalt(); return new UserAgentImpl(CryptoTools.generateKeyPair(), passphrase, salt); } protected  UserAgentImpl(KeyPair pair, String passphrase, byte[] salt); protected  UserAgentImpl(PublicKey pubKey, byte[] encryptedPrivate, byte[] salt); @Override String getLoginName(); @Override boolean hasLoginName(); @Override void setLoginName(String loginName); @Override void setEmail(String email); @Override String toXmlString(); static UserAgentImpl createFromXml(String xml); static UserAgentImpl createUserAgent(String passphrase); static UserAgentImpl createFromXml(Element root); @Override void receiveMessage(Message message, AgentContext context); @Override void notifyUnregister(); @Override String getEmail(); @Override boolean hasEmail();  }