Exemple #1
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   this.keyProvider = TestKeyProvider.getInstance();
   this.configuration = ConfigurationFactory.createDefault();
   DatabaseServer databaseServer = new DatabaseServer(configuration);
   this.keyserver = new KeyServer(databaseServer, configuration);
   this.bc = new BouncyCastleProvider();
 }
 /** @return a list of groups the test user is member of */
 private GroupList fetchGroupsList() {
   GroupList list = null;
   try {
     list =
         (GroupList)
             proc.process(content, TestKeyProvider.getInstance().getUserID(), "testRequest");
   } catch (BackendProcessException e) {
     fail(e.getMessage());
   }
   return list;
 }
Exemple #3
0
  public void testEncapsulateKey() {
    System.out.println("begin testEncapsulateKey:");
    byte[] key = new byte[32];
    Random rnd = new Random();
    rnd.nextBytes(key);
    X509Certificate certificate = keyProvider.getUserEncCert();
    byte[] encapsulatedKey = keyserver.encapsulateKey(key, certificate);

    PrivateKey privateKey = keyProvider.getUserEncKey().getPrivate();
    Cipher decapsulator = null;
    try {
      decapsulator = Cipher.getInstance("RSA/NONE/OAEPPadding", bc);
      decapsulator.init(Cipher.DECRYPT_MODE, privateKey);
      byte[] decapsulatedKey = decapsulator.doFinal(encapsulatedKey);
      assertTrue("Decapsulated key differs from plain key", Arrays.equals(key, decapsulatedKey));
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
    System.out.println("end testEncapsulateKey:");
  }
 /** Create processor and SAMLEngine. */
 @Override
 public void setUp() {
   super.setUp();
   proc = new GetGroupsForUserProcessor();
   try {
     content = SAMLEngine.getXMLObject(GetGroupsForUser.class);
     content.setValue(TestKeyProvider.getInstance().getUserIDBase64());
   } catch (SAMLEngineException e) {
     e.log();
     fail(e.toString());
   }
 }