本文整理汇总了Java中org.openid4java.consumer.ConsumerManager.discover方法的典型用法代码示例。如果您正苦于以下问题:Java ConsumerManager.discover方法的具体用法?Java ConsumerManager.discover怎么用?Java ConsumerManager.discover使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openid4java.consumer.ConsumerManager
的用法示例。
在下文中一共展示了ConsumerManager.discover方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reconnectToMxID
import org.openid4java.consumer.ConsumerManager; //导入方法依赖的package包/类
private void reconnectToMxID() {
LOG.info("Starting OpenId handler ... OpenIDReturnURL = " + OPENID_RETURN_URL + "; OpenIdProvider: " + OPENID_PROVIDER);
try {
manager = new ConsumerManager();
manager.setAssociations(new InMemoryConsumerAssociationStore());
manager.setNonceVerifier(new InMemoryNonceVerifier(5000));
manager.setMinAssocSessEnc(AssociationSessionType.DH_SHA256);
manager.getRealmVerifier().setEnforceRpId(true);
discoveries = manager.discover(OPENID_PROVIDER);
discovered = manager.associate(discoveries);
started = true;
LOG.info("Starting OpenId handler ... DONE");
} catch (DiscoveryException e) {
LOG.error("Failed to discover OpenId service: " + e.getMessage(), e);
}
}
示例2: testEmptyUri
import org.openid4java.consumer.ConsumerManager; //导入方法依赖的package包/类
public void testEmptyUri() throws Exception
{
// empty string is a valid java.net.URI...
YadisResult yadis = _resolver.discover("http://localhost:" + _servletPort + "/?headers=simplexrds&xrds=malformedxrds6",
10, Collections.singleton("http://example.com/"));
assertTrue("XRDS with an empty URI is valid; Yadis should have succeeded",
yadis.getEndpoints().size() > 0);
// also run through Discovery.extractDiscoveryInformation()
ConsumerManager manager = new ConsumerManager();
List results = manager.discover("http://localhost:" +
_servletPort + "/?headers=simplexrds&xrds=malformedxrds6");
assertEquals("No discovery information should have been returned for an empty URI",
0, results.size());
}
示例3: reconnectToMxID
import org.openid4java.consumer.ConsumerManager; //导入方法依赖的package包/类
private void reconnectToMxID() {
log.info("Starting OpenId handler ... OpenIDReturnURL = " + OpenIDReturnURL + "; OpenIdProvider: " + OPENID_PROVIDER);
try {
manager = new ConsumerManager();
manager.setAssociations(new InMemoryConsumerAssociationStore());
manager.setNonceVerifier(new InMemoryNonceVerifier(5000));
manager.setMinAssocSessEnc(AssociationSessionType.DH_SHA256);
manager.getRealmVerifier().setEnforceRpId(true);
discoveries = manager.discover(OPENID_PROVIDER);
discovered = manager.associate(discoveries);
started = true;
log.info("Starting OpenId handler ... DONE");
} catch (Exception e) {
log.error("Failed to discover OpenId service: " + e.getMessage(), e);
}
}
示例4: prepareAuthenticationUrl
import org.openid4java.consumer.ConsumerManager; //导入方法依赖的package包/类
/**
* Prepares open ID authentication URL.
*
* @param openIdIdentifier the open ID identifier to authenticate
* @param siteUrl the site URL
* @param returnViewName the return view name
* @return the authentication URL
* @throws DiscoveryException if discovery exception occurs.
* @throws MessageException if message exception occurs.
* @throws ConsumerException if consume exception occurs.
*/
public static String prepareAuthenticationUrl(final String openIdIdentifier, final String siteUrl
, final String returnViewName)
throws DiscoveryException, MessageException, ConsumerException {
if (UI.getCurrent().getSession().getAttribute(ConsumerManager.class) == null) {
UI.getCurrent().getSession().setAttribute(ConsumerManager.class, new ConsumerManager());
}
final ConsumerManager manager = UI.getCurrent().getSession().getAttribute(ConsumerManager.class);
final String returnURL = siteUrl + returnViewName;
final List discoveries = manager.discover(openIdIdentifier);
final DiscoveryInformation discovered = manager.associate(discoveries);
UI.getCurrent().getSession().setAttribute(DiscoveryInformation.class, discovered);
final AuthRequest authReq = manager.authenticate(discovered, returnURL);
return authReq.getDestinationUrl(true);
}
示例5: showOpenIDForm
import org.openid4java.consumer.ConsumerManager; //导入方法依赖的package包/类
public Resolution showOpenIDForm()
throws ConsumerException, MessageException, DiscoveryException, MalformedURLException {
ConsumerManager manager = new ConsumerManager();
// perform discovery on the user-supplied identifier
List discoveries = manager.discover(openIdUrl);
// attempt to associate with the OpenID provider
// and retrieve one service endpoint for authentication
DiscoveryInformation discovered = manager.associate(discoveries);
UrlBuilder urlBuilder = new UrlBuilder(context.getLocale(), context.getActionPath(), false);
urlBuilder.setEvent("handleOpenIDLogin");
urlBuilder.addParameter("returnUrl", returnUrl);
urlBuilder.addParameter("cancelReturnUrl", cancelReturnUrl);
URL url = new URL(context.getRequest().getRequestURL().toString());
String port = url.getPort() > 0 ? ":" + url.getPort() : "";
String baseUrl = url.getProtocol() + "://" + url.getHost() + port;
String urlString = baseUrl + context.getRequest().getContextPath() + urlBuilder;
// obtain a AuthRequest message to be sent to the OpenID provider
AuthRequest authReq = manager.authenticate(discovered, urlString, baseUrl);
// store the discovery information in the user's session for later use
// leave out for stateless operation / if there is no session
HttpSession session = context.getRequest().getSession();
session.setAttribute(OPENID_DISCOVERED, discovered);
session.setAttribute(OPENID_CONSUMER_MANAGER, manager);
String destinationUrl = authReq.getDestinationUrl(true);
if(destinationUrl.length() > 2000) {
if(authReq.isVersion2()) {
openIdDestinationUrl = authReq.getDestinationUrl(false);
openIdParameterMap = authReq.getParameterMap();
return new ForwardResolution("/m/openid/pageactions/openid/openIDFormRedirect.jsp");
} else {
SessionMessages.addErrorMessage("Cannot login, payload too big and OpenID version 2 not supported.");
return new ForwardResolution(getLoginPage());
}
} else {
return new RedirectResolution(destinationUrl, false);
}
}