0

First of all i am sorry if my question is not valid because i don't have any idea on the SSL implementation and validating the request from a trusted certificate authority.

Basically we are using .jks file to validate the request and we are using JAX-RS deployed on wildfly.

In the standalone.xml we have done the configuration like this:

<management>
 <security-realms>
**<security-realm name="SslRealm">
  <server-identities>
    <ssl>
      <keystore path="../../../ssl/keystore.jks" relative-to="jboss.server.config.dir" keystore-password="changeme"/>
    </ssl>
  </server-identities>
</security-realm>**
</security-realms>

Now in the java code we need to read the .jks file , username and password:

 public static Response getArtifactsHttps(String authInfo, String area) {
        String username = "username";
        String password1 = "password";
        StringBuilder authorization = new StringBuilder();
        authorization.append(username).append(":").append(password1);

        // String authHeader = "Basic " + Base64.getEncoder().encodeToString(authorization.toString().getBytes());
        Response response = RestAssured
                .given()
                .keyStore("pathOffile\\DemoTrust.jks", "DemoTrustKeyStorePassPhrase")
                .when()
                .contentType(MediaType.APPLICATION_JSON)
                .accept(MediaType.APPLICATION_JSON)
                .header(Constant.HTTP_HEADERS.AUTHORIZATION, "Basic " + authInfo)
                .header(Constant.HTTP_HEADERS.MODULETYPE, Constant.AC_MODULETYPE.CLIENT)
                .get("login").thenReturn();

        System.out.println("RESPONSE" + response);
        return response;
    }

In the above you can see i have hardcoded the path of the .jks file pathoffile\DemoTrust.jks also username and password i have hardcoded.

Now i want to read all these value from the standalone.xml file. Can anybody suggest me how i can do this using java?

Rohitesh
  • 1,514
  • 7
  • 28
  • 51

1 Answers1

1

Use System.getProperty("jboss.server.config.dir") to get the root of the configuration path.

Jonathan Rosenne
  • 2,159
  • 17
  • 27
  • I am getting C:\wildfly-10.1.0_\wildfly-10.1.0.Final\standalone\configuration . Do i need to manually append the standalone.xml and read that file like a xml file ? Also my .jks file is 2 level up of this folder how to get that .jks file path and username and password from standalone.xml file – Rohitesh Dec 04 '17 at 07:06
  • You should append “/ssl/keystore.jks” and place the ssl directory in the configuration directory. – Jonathan Rosenne Dec 04 '17 at 07:11
  • Sir do i need to read that standalone.xml file to get the keystore-password under the – Rohitesh Dec 04 '17 at 07:15