本文整理匯總了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 );
}
}
}
示例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;
}