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


Java Request.getChallengeResponse方法代碼示例

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


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

示例1: verify

import org.restlet.Request; //導入方法依賴的package包/類
/**
 * Verifies that the proposed secret is correct for the specified request.
 * By default, it compares the inputSecret of the request's authentication
 * response with the one obtain by the {@link ChallengeResponse#getSecret()}
 * method and sets the {@link org.restlet.security.User} instance of the
 * request's {@link ClientInfo} if successful.
 * 
 * @param request
 *            The request to inspect.
 * @param response
 *            The response to inspect.
 * @return Result of the verification based on the RESULT_* constants.
 */
public int verify(Request request, Response response)
{
    int result = RESULT_VALID;
    
    if (request.getChallengeResponse() == null)
    {
        result = RESULT_MISSING;
    }
    else
    {
        String identifier = getIdentifier(request, response);
        char[] secret = getSecret(request, response);
        AccountInfo accountInfo = new AccountInfo();
        accountInfo.setUserId(identifier);
        accountInfo.setPassword(new String(secret));
        MessageContext mc = ThreadLocalHolder.get();
        mc.getEntities().put(ESDKConstant.ACCT_INFO_ESDK, accountInfo);
        
        if (authorize.isLocalAuth("uc"))//TODO zhili
        {
            result = verify(identifier, secret);
        }
        else
        {
            Map<String, String> message = new HashMap<String, String>();
            message.put(ESDKConstant.ESDK_USER_ID, identifier);
            message.put(ESDKConstant.ESDK_PLAIN_PWD, new String(secret));
            result = restAppAuthorize.verify(request.getOriginalRef().getPath(), message);
        }
        
        if (result == RESULT_VALID)
        {
            request.getClientInfo().setUser(createUser(identifier, request, response));
        }
    }
    
    return result;
}
 
開發者ID:Huawei,項目名稱:eSDK_EC_SDK_Java,代碼行數:52,代碼來源:SecretVerifier.java

示例2: verify

import org.restlet.Request; //導入方法依賴的package包/類
@Override
public int verify(Request request, Response response) {
    final String token;

    try {
        ChallengeResponse cr = request.getChallengeResponse();
        if (cr == null) {
            return RESULT_MISSING;
        } else if (ChallengeScheme.HTTP_OAUTH_BEARER.equals(cr.getScheme())) {
            final String bearer = cr.getRawValue();
            if (bearer == null || bearer.isEmpty()) {
                return RESULT_MISSING;
            }
            token = bearer;
        } else {
            return RESULT_UNSUPPORTED;
        }
    } catch (Exception ex) {
        return RESULT_INVALID;
    }

    Try<User> user = accessTokenVerificationCommandFactory.createVerificationCommand(token).executeCommand();
    return user.map(u -> {
        org.restlet.security.User restletUser = createRestletUser(u);
        request.getClientInfo().setUser(restletUser);
        request.getAttributes().put("token", token);
        return RESULT_VALID;
    }).orElse(RESULT_INVALID);
}
 
開發者ID:cdelmas,項目名稱:microservices-comparison,代碼行數:30,代碼來源:AuthTokenVerifier.java

示例3: getUserIdFromHeader

import org.restlet.Request; //導入方法依賴的package包/類
private String getUserIdFromHeader(Request request) {
    ChallengeResponse cr = request.getChallengeResponse();
    return (cr != null) ? cr.getIdentifier() : null;
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:5,代碼來源:CustomActivitiRestAuthenticator.java

示例4: getPassword

import org.restlet.Request; //導入方法依賴的package包/類
private String getPassword(Request request) {
    ChallengeResponse cr = request.getChallengeResponse();
    return (cr != null) ? new String(cr.getSecret()) : null;
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:5,代碼來源:CustomActivitiRestAuthenticator.java

示例5: createInboundRoot

import org.restlet.Request; //導入方法依賴的package包/類
/**
 * Creates a root Restlet that will receive all incoming calls.
 */
@Override
public synchronized Restlet createInboundRoot() {
  Verifier verifier = new SecretVerifier() {

    @Override
    public boolean verify(String username, char[] password) throws IllegalArgumentException {
      boolean verified = ActivitiUtil.getIdentityService().checkPassword(username, new String(password));
      return verified;
    }
  };
  authenticator = new ChallengeAuthenticator(null, true, ChallengeScheme.HTTP_BASIC,
        "Activiti Realm") {
    
    @Override
    protected boolean authenticate(Request request, Response response) {
      if (request.getChallengeResponse() == null) {
        return false;
      } else {
        return super.authenticate(request, response);
      }
    }
  };
  authenticator.setVerifier(verifier);
  
  Router router = new Router(getContext());

  router.attachDefault(DefaultResource.class);
  
  router.attach("/process-engine", ProcessEngineResource.class);
  
  router.attach("/login", LoginResource.class);
  
  router.attach("/user/{userId}", UserResource.class);
  router.attach("/user/{userId}/groups", UserGroupsResource.class);
  router.attach("/group/{groupId}", GroupResource.class);
  router.attach("/groups/{groupId}/users", GroupUsersResource.class);
  
  router.attach("/process-definitions", ProcessDefinitionsResource.class);
  router.attach("/process-instances", ProcessInstancesResource.class);
  router.attach("/process-instance", ProcessInstanceResource.class);
  router.attach("/processInstance/{processInstanceId}/diagram", ProcessInstanceDiagramResource.class);
  router.attach("/process-definition/{processDefinitionId}/form", ProcessDefinitionFormResource.class);
  
  router.attach("/tasks", TasksResource.class);
  router.attach("/tasks-summary", TasksSummaryResource.class);
  router.attach("/task/{taskId}", TaskResource.class);
  router.attach("/task/{taskId}/form", TaskFormResource.class);
  router.attach("/task/{taskId}/{operation}", TaskOperationResource.class);
  
  router.attach("/form/{taskId}/properties", TaskPropertiesResource.class);
  
  router.attach("/deployments", DeploymentsResource.class);
  router.attach("/deployment", DeploymentUploadResource.class);
  router.attach("/deployments/delete", DeploymentsDeleteResource.class);
  router.attach("/deployment/{deploymentId}", DeploymentDeleteResource.class);
  
  router.attach("/management/jobs", JobsResource.class);
  router.attach("/management/job/{jobId}", JobResource.class);
  router.attach("/management/job/{jobId}/execute", JobExecuteResource.class);
  router.attach("/management/jobs/execute", JobsExecuteResource.class);
  
  router.attach("/management/tables", TablesResource.class);
  router.attach("/management/table/{tableName}", TableResource.class);
  router.attach("/management/table/{tableName}/data", TableDataResource.class);
  
  authenticator.setNext(router);
  
  return authenticator;
}
 
開發者ID:logicalhacking,項目名稱:SecureBPMN,代碼行數:73,代碼來源:ActivitiRestApplication.java


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