簡體   English   中英

Axis2使用偶數BASIC身份驗證

[英]Axis2 working with even BASIC authentication

它甚至可能嗎? 文檔沒有說清楚。 我已經嘗試了各種不同的機制來使身份驗證工作,但我不斷得到“401:Unauthorized”錯誤。 這是我在的地方:

    stub = new EngineStub();

    HttpClient client = new HttpClient();
    client.getParams().setAuthenticationPreemptive(true);
    stub._getServiceClient().getServiceContext().getConfigurationContext().setProperty(HTTPConstants.CACHED_HTTP_CLIENT, client);

    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
    List<String> authpref = new ArrayList<String>();
    authpref.add(AuthPolicy.BASIC);
    auth.setAuthSchemes(authpref);
    auth.setUsername(username); 
    auth.setPassword(password);
    auth.setPreemptiveAuthentication(true);
    stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, auth);

什么是什么意思軸2與BASIC AUTH一起工作? 如果您的后端服務使用基本身份驗證進行保護,您所要做的就是從客戶端設置基本身份驗證頭並發送請求。 您的客戶代碼看起來正確; 不確定auth政策;嘗試沒有這樣;

 auth.setUsername(USER_NAME);
    auth.setPassword(PASSWORD);
    auth.setPreemptiveAuthentication(true);
    option.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
    option.setManageSession(true);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM