如何与Jersy客户进行身份验证

时间:2020-02-11 09:19:01

标签: rest jersey client

大家好,我想通过Jersy客户对Atlassian人群进行自动申请,但我却被未经授权退还,没有什么可能发生的。

    public ClientResponse addToAudit() throws JSONException {

    try {

        webResource = client.resource("http://0.0.0.0:0000/crowd/rest/usermanagement/latest/session");System.out.println(encodeToBase64());
        clientResponse = webResource.type("application/xml").accept("application/xml").post(ClientResponse.class,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + 
                "           <authentication-context>\r\n" + 
                "             <username></username>\r\n" + 
                "             <password></password>\r\n" + 
                "             <validation-factors>\r\n" + 
                "               <validation-factor>\r\n" + 
                "                 <name>remote_address</name>\r\n" + 
                "                 <value>0.0.0.0:000</value>\r\n" + 
                "               </validation-factor>\r\n" + 
                "             </validation-factors>\r\n" + 
                "           </authentication-context>");
        return clientResponse;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

0 个答案:

没有答案