2017-02-16 45 views
0
創建

剛開始使用MFP 8,並創建了一個用戶登陸安全檢查指的是user authentication - security check和創建範圍access-resticted映射到用戶登陸安全檢查。MobileFirst 8(MFP 8)未經授權的訪問受保護的JavaScript適配器資源,沒有挑戰是從UserAuthenticationSecurityCheck

的用戶登陸是用來保護我的javascript適配器的資源,如:

< procedure name="getData" scope="access-restricted"/ > 

但是叫我的資源時getData了未經授權的錯誤,並沒有被用戶登陸安全檢查創建的挑戰。

期待下面的代碼來執行:

@Override 
protected Map<String, Object> createChallenge() { 
    System.out.println("---------------------CREATE-CHALLENGE---------------------"); 
    Map<String, Object> challenge = new HashMap<String, Object>(); 
    challenge.put("errorMsg", errorMsg); 
    return challenge; 
} 

@Override 
protected boolean validateCredentials(Map<String, Object> credentials) 
{ 
    if(credentials!=null && credentials.containsKey("username") && credentials.containsKey("password")) 
     { 
      String username = credentials.get("username").toString(); 
      String password = credentials.get("password").toString(); 
      if(!username.isEmpty() && !password.isEmpty() && username.equals(password)) 
       { 
        userId = username; 
        displayName = username; 

        //Optional RememberMe 
        if(credentials.containsKey("rememberMe")) 
         { 
          rememberMe = Boolean.valueOf(credentials.get("rememberMe").toString()); 
         }     
        return true; 
       } 
      else 
       { 
        errorMsg = "Wrong Credentials"; 
       } 
     } 
    else 
     { 
      errorMsg = "Credentials not set properly"; 
     } 
    return false; 
} 

還試圖執行從MobileFirst-揚鞭適配器的資源,開啓安全檢查,並被提示輸入用戶名密碼&。在回答挑戰時總是輸入不正確的用戶名&密碼,但基於上面的代碼,只要username.equal(密碼)的validateCredential應該是有效的,但在從Swagger進行測試時它仍然無效。

任何想法是什麼問題?

+0

您是否在應用程序註冊的安全設置中將「訪問限制」映射到UserLogin SecurityCheck? –

+0

是的。它被映射。 – Amon

+0

難道是因爲我在UserLogin adapter.xml中評論了「」?任何關係?我評論的原因是因爲它在構建適配器時導致錯誤。 [錯誤]無法執行目標com.ibm.mfp:adapter-maven-plugin:8.0.2017012516:在項目上構建(默認構建)MyJavaAdapter:適配器xml文件架構驗證遇到錯誤:[cvc-complex-type.2.4。 a:從元素'JAXRSApplicationClass'開始找到無效的內容。期望有一個'{securityCheckDefinition}'。] - > [Help 1] – Amon

回答

0

最有可能的原因是未能在MFP控制檯中的應用程序的安全配置中將UserLogin安全檢查映射到access-restricted範圍。

下面是步驟:

  • 轉到MFP控制檯
  • 地圖access-restricted範圍UserLogin安全檢查你的應用程序的安全選項卡,如圖所示範圍 - 元素映射部分

enter image description here

關於範圍映射的更多細節可以在here找到。

+0

範圍映射已創建。 – Amon

+0

@Amon請在您的服務器和客戶端之間共享wireshark網絡捕獲。 –

相關問題