2017-12-04 2 views
0

우선 SSL 구현에 대한 아이디어가없고 신뢰할 수있는 인증 기관의 요청을 확인하기 때문에 내 질문이 유효하지 않은 경우 미안합니다.standalone.xml wildfly에서 KeyStore 파일 경로를 읽는 방법

기본적으로 .jks 파일을 사용하여 요청의 유효성을 검사하고 있으며 wildfly에 배포 된 JAX-RS를 사용하고 있습니다.

는 standalone.xml에서 우리는 다음과 같이 구성을 완료했다 :

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; 
    } 
:

<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> 

지금 자바 코드에서 우리는 .jks 파일, 사용자 이름과 암호를 읽을 필요

위의 내용에서 .jks 파일의 경로를 하드 코드 한 것을 볼 수 있습니다. pathoffile \ DemoTrust.jks 또한 사용자 이름과 암호는 하드 코드되어 있습니다.

이제이 모든 값을 standalone.xml 파일에서 읽고 싶습니다. 아무도 내가 자바를 사용하여 이것을 할 수있는 방법을 제안 할 수 있습니까?

답변

0

System.getProperty ("jboss.server.config.dir")를 사용하여 구성 경로의 루트를 가져옵니다.

+0

C : \ wildfly-10.1.0_ \ wildfly-10.1.0.Final \ standalone \ configuration이 표시됩니다. standalone.xml을 수동으로 추가하고 해당 파일을 xml 파일처럼 읽어야합니까? 또한 내 .jks 파일은이 폴더의 2 레벨 업입니다. standalone.xml 파일에서 .jks 파일 경로와 사용자 이름 및 암호를 얻는 방법 – Rohitesh

+0

"/ssl/keystore.jks"를 추가하고 구성 디렉토리에 ssl 디렉토리를 추가해야합니다 . –

+0

각하 나는 그 standalone.xml 파일을 읽어서 Rohitesh

관련 문제