我的网址@开发: http: //192.168.0.1 :8888/com.company.MyEntryPoint/MyEntrypoint.html 我的网址@现场环境:http ://www.example.com/com.company.MyEntryPoint/MyEntrypoint.html
我需要用户使用开放 ID 进行身份验证,这就是我希望我的领域的方式:*.company.MyEntryPoint
我写了一个简单的代码来指定领域:
AuthRequest authReq =
manager.authenticate(
discovered,
returnToUrl,
"*.company.MyEntryPoint"
);
这没用。例外:
org.openid4java.message.MessageException: 0x301: Realm verification failed (2) for: *.company.MyEntryPoint
at org.openid4java.message.AuthRequest.validate(AuthRequest.java:354)
at org.openid4java.message.AuthRequest.createAuthRequest(AuthRequest.java:101)
at org.openid4java.consumer.ConsumerManager.authenticate(ConsumerManager.java:1073)
在我尝试的所有组合中,奇怪的是,以下方法有效:
AuthRequest authReq =
manager.authenticate(
discovered,
returnToUrl,
"http://localhost:8888/com.capgent.MyEntryPoint"
);
这并不能解决我的问题,而是使它复杂化:)
根据google和open id spec它应该可以工作
完整的代码片段:
List discoveries = manager.discover(clientUrl);
DiscoveryInformation discovered = manager.associate(discoveries);
AuthRequest authReq = manager.authenticate(discovered, returnToUrl,"*.company.MyEntryPoint");
FetchRequest fetch = FetchRequest.createFetchRequest();
fetch.addAttribute("email", "http://schema.openid.net/contact/email", true);
fetch.addAttribute("country", "http://axschema.org/contact/country/home", true);
fetch.addAttribute("firstname", "http://axschema.org/namePerson/first", true);
fetch.addAttribute("lastname", "http://axschema.org/namePerson/last", true);
fetch.addAttribute("language", "http://axschema.org/pref/language", true);
authReq.addExtension(fetch);
String returnStr;
if (!discovered.isVersion2())
{
returnStr = authReq.getDestinationUrl(true);
}
else
{
returnStr = authReq.getDestinationUrl(false);
}
我在这里做错了什么?