KeyPairCurator extends
    AbstractHibernateCurator<KeyPair> { public java.security.KeyPair getConsumerKeyPair(Consumer c) { KeyPair cpKeyPair = c.getKeyPair(); if (cpKeyPair == null) { cpKeyPair = generateKeyPair(); c.setKeyPair(cpKeyPair); } java.security.KeyPair returnMe = new java.security.KeyPair( cpKeyPair.getPublicKey(), cpKeyPair.getPrivateKey()); return returnMe; } @Inject  KeyPairCurator(PKIUtility pki); java.security.KeyPair getConsumerKeyPair(Consumer c); java.security.KeyPair getKeyPair();  }
@Test public void testSameConsumerGetsSameKey() { Owner owner = createOwner(); Consumer consumer = createConsumer(owner); KeyPair keyPair1 = keyPairCurator.getConsumerKeyPair(consumer); KeyPair keyPair2 = keyPairCurator.getConsumerKeyPair(consumer); assertEquals(keyPair1.getPrivate(), keyPair2.getPrivate()); }
@Test public void testTwoConsumersGetDifferentKeys() { Owner owner = createOwner(); Consumer consumer1 = createConsumer(owner); Consumer consumer2 = createConsumer(owner); KeyPair keyPair1 = keyPairCurator.getConsumerKeyPair(consumer1); KeyPair keyPair2 = keyPairCurator.getConsumerKeyPair(consumer2); assertFalse(keyPair1.getPrivate().equals(keyPair2.getPrivate())); }