剛開始使用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進行測試時它仍然無效。
任何想法是什麼問題?
您是否在應用程序註冊的安全設置中將「訪問限制」映射到UserLogin SecurityCheck? –
是的。它被映射。 – Amon
難道是因爲我在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