2017-03-14 47 views

回答

1

您不需要註銷以設置活動用戶&您可以在用戶通過使用API​​ setActiveUser進行身份驗證後立即在適配器中設置活動用戶。

關於setActiveUsergetActiveUser的詳細信息可以找到API的here

以下代碼是關於如何在適用於Mobilefirst 8.0註冊Sample的適配器中執行此操作的示例。

public void authorize(Set<String> scope, Map<String, Object> credentials, HttpServletRequest request, AuthorizationResponse response) { 
    PersistentAttributes attributes = registrationContext.getRegisteredProtectedAttributes(); 
    if (attributes.get("pinCode") != null){ 
     // Is there a user currently active? 
     if (!userLogin.isLoggedIn()){ 
      // If not, set one here. 
      authorizationContext.setActiveUser(userLogin.getRegisteredUser()); 
     } 
     setState(SUCCESS_STATE); 
     response.addSuccess(scope, getExpiresAt(), this.getName()); 
    } else { 
     setState(STATE_EXPIRED); 
     Map <String, Object> failure = new HashMap<String, Object>(); 
     failure.put("failure", "User is not enrolled"); 
     response.addFailure(getName(), failure); 
    } 
} 

欲瞭解更多信息,請訪問通過this tutorial

相關問題