當前位置: 首頁>>代碼示例>>Java>>正文


Java Request.setChallengeResponse方法代碼示例

本文整理匯總了Java中org.restlet.Request.setChallengeResponse方法的典型用法代碼示例。如果您正苦於以下問題:Java Request.setChallengeResponse方法的具體用法?Java Request.setChallengeResponse怎麽用?Java Request.setChallengeResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.restlet.Request的用法示例。


在下文中一共展示了Request.setChallengeResponse方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: invokeQuery

import org.restlet.Request; //導入方法依賴的package包/類
private HandlerCommand invokeQuery( Reference ref, Object queryRequest, ResponseHandler resourceHandler, ResponseHandler processingErrorHandler )
{
    Request request = new Request( Method.GET, ref );

    if( queryRequest != null )
    {
        contextResourceFactory.writeRequest( request, queryRequest );
    }

    contextResourceFactory.updateQueryRequest( request );

    User user = request.getClientInfo().getUser();
    if ( user != null)
        request.setChallengeResponse( new ChallengeResponse( ChallengeScheme.HTTP_BASIC, user.getName(), user.getSecret() ) );

    Response response = new Response( request );

    contextResourceFactory.getClient().handle( request, response );

    if( response.getStatus().isSuccess() )
    {
        contextResourceFactory.updateCache( response );

        return resourceHandler.handleResponse( response, this );
    } else if (response.getStatus().isRedirection())
    {
        Reference redirectedTo = response.getLocationRef();
        return invokeQuery( redirectedTo, queryRequest, resourceHandler, processingErrorHandler );
    } else
    {
        if (response.getStatus().equals(Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY) && processingErrorHandler != null)
        {
            return processingErrorHandler.handleResponse( response, this );
        } else
        {
            // TODO This needs to be expanded to allow custom handling of all the various cases
            return errorHandler.handleResponse( response, this );
        }
    }
}
 
開發者ID:apache,項目名稱:polygene-java,代碼行數:41,代碼來源:ContextResourceClient.java

示例2: getRequestResultWithAuth

import org.restlet.Request; //導入方法依賴的package包/類
private Response getRequestResultWithAuth(String path,String user,String password){
    Request request = new Request(Method.GET, serverUrl+path);
    Client client = new Client(Protocol.HTTP);

    ChallengeResponse authentication = new ChallengeResponse(
            ChallengeScheme.HTTP_BASIC, user, password);
    request.setChallengeResponse(authentication);

    Response response = client.handle(request);
    return response;
}
 
開發者ID:eternnoir,項目名稱:MCRest,代碼行數:12,代碼來源:AuthResourceTest.java


注:本文中的org.restlet.Request.setChallengeResponse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。