Example #1
0
  @Test
  public void testSignature() throws Exception {
    Map<String, String> outProperties = new HashMap<String, String>();
    outProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
    outProperties.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
    outProperties.put(WSHandlerConstants.USER, "myalias");
    outProperties.put("password", "myAliasPassword");

    Map<String, String> inProperties = new HashMap<String, String>();
    inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
    inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "insecurity.properties");

    List<String> xpaths = new ArrayList<String>();
    xpaths.add("//wsse:Security");
    xpaths.add("//wsse:Security/ds:Signature");

    List<WSHandlerResult> handlerResults =
        getResults(makeInvocation(outProperties, xpaths, inProperties));
    WSSecurityEngineResult actionResult =
        handlerResults.get(0).getActionResults().get(WSConstants.SIGN).get(0);

    X509Certificate certificate =
        (X509Certificate) actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
    assertNotNull(certificate);
  }
Example #2
0
  @Test
  public void testPKIPath() throws Exception {
    Map<String, String> outProperties = new HashMap<String, String>();
    outProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
    outProperties.put(WSHandlerConstants.USER, "alice");
    outProperties.put(WSHandlerConstants.SIG_PROP_FILE, "alice.properties");
    outProperties.put(
        WSHandlerConstants.PW_CALLBACK_CLASS, KeystorePasswordCallback.class.getName());
    outProperties.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
    outProperties.put(WSHandlerConstants.USE_SINGLE_CERTIFICATE, "false");

    Map<String, String> inProperties = new HashMap<String, String>();
    inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
    inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "cxfca.properties");

    List<String> xpaths = new ArrayList<String>();
    xpaths.add("//wsse:Security");
    xpaths.add("//wsse:Security/ds:Signature");

    List<WSHandlerResult> handlerResults =
        getResults(makeInvocation(outProperties, xpaths, inProperties));
    WSSecurityEngineResult actionResult =
        handlerResults.get(0).getActionResults().get(WSConstants.SIGN).get(0);

    X509Certificate[] certificates =
        (X509Certificate[]) actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATES);
    assertNotNull(certificates);
    assertEquals(certificates.length, 2);
  }