我正在尝试在iOS中使用IBM MobileFirst Platform Foundation 6.3和Xamarin实现基于适配器的身份验证。
我遵循了关于如何设置customSecurityTest的IBM文档,在authenticationConfig.xml中添加了领域和等效的loginModule。然后,我设置了2个适配器过程:
authenticateUser
与securityTest="wl_unprotected"
以及另一个HelloFromServer
与实际进行用户身份验证的securityTest="SingleStepAuthAdapter"
,并执行WL.Server.setActiveUser("SingleStepAuthRealm", userIdentity)
来创建用户身份
然后,我使用Xamarin Studio创建了一个iOS应用程序。尝试调用HelloFromServer
,正如预期的那样,它在HandleChallenge
方法中运行我的ChallengeHandler模块,但在尝试调用服务器上的authenticateUser
过程时,它用另一个authRequired=TRUE
进行响应。
有人有同样的问题吗?
-
您没有提供任何可以检查错误的有用实现代码——添加适配器身份验证实现以及质询处理程序的客户端代码。
-
虽然我没有Xamarin的经验,但应该注意的是,为了开始,你可以:
- 使用与基于适配器的身份验证教程中相同的精确实现。也就是说,实现在适配器文件、项目配置等方面
- 遵循本机iOS实现,同样基于教程
MFP Studio项目和本机iOS项目可以从这里下载。
如果您重复获取authRequired=true
,则看起来您没有从HandleChallenge
函数通知服务器成功。您可以参考组件随附的样品附带的CustomChallengeHandler.cs
。这是为了处理基于表单的挑战而编写的。您可以修改它来处理基于适配器的身份验证的领域。
因此,以下是您需要进行的更改
1) 您应该在ChallengeHandler类中实现GetAdapterAuthenticationParameters
方法。
例如,
public AdapterAuthenticationInfo AdapterAuthenticationParameters = new AdapterAuthenticationInfo();
....
public override AdapterAuthenticationInfo GetAdapterAuthenticationParameters ()
{
return AdapterAuthenticationParameters;
}
2) 在ChallengeHandler类的HandleChallenge
函数中,设置isAuthRequired = true
。例如,
if (challenge.ResponseJSON["authRequired"] == true)
{
WorklightProcedureInvocationData invocationData = new WorklightProcedureInvocationData("DemoAdapter",
"submitAuthentication" , new object[1]); // Add the parameters you want to pass to the adapter
AdapterAuthenticationParameters.InvocationData = invocationData;
AdapterAuthenticationParameters.RequestOptions = null;
isAdapterAuth = true;
}
else
{
isAdapterAuth = false;
authSuccess = true;
}