• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DiscoveryInformation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openid4java.discovery.DiscoveryInformation的典型用法代码示例。如果您正苦于以下问题:Java DiscoveryInformation类的具体用法?Java DiscoveryInformation怎么用?Java DiscoveryInformation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DiscoveryInformation类属于org.openid4java.discovery包,在下文中一共展示了DiscoveryInformation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: retrieveCredentials

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
@Override
protected OpenIdCredentials retrieveCredentials(final WebContext context) throws HttpAction {
    final String mode = context.getRequestParameter(OPENID_MODE);
    // cancelled authentication
    if (CommonHelper.areEquals(mode, CANCEL_MODE)) {
        logger.debug("authentication cancelled");
        return null;
    }

    // parameters list returned by the provider
    final ParameterList parameterList = new ParameterList(context.getRequestParameters());

    // retrieve the previously stored discovery information
    final DiscoveryInformation discoveryInformation = (DiscoveryInformation) context
            .getSessionAttribute(getDiscoveryInformationSessionAttributeName());

    // create credentials
    final OpenIdCredentials credentials = new OpenIdCredentials(discoveryInformation, parameterList, getName());
    logger.debug("credentials: {}", credentials);
    return credentials;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:22,代码来源:BaseOpenIdClient.java


示例2: verifyNonce

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
/**
 * Verifies the nonce in an authentication response.
 *
 * @param authResp      The authentication response containing the nonce
 *                      to be verified.
 * @param discovered    The discovery information associated with the
 *                      authentication transaction.
 * @return              True if the nonce is valid, false otherwise.
 */
public boolean verifyNonce(AuthSuccess authResp,
                           DiscoveryInformation discovered)
{
    String nonce = authResp.getNonce();

    if (nonce == null) // compatibility mode
        nonce = extractConsumerNonce(authResp.getReturnTo(),
                discovered.getOPEndpoint().toString());

    if (nonce == null) return false;

    // using the same nonce verifier for both server and consumer nonces
    return (NonceVerifier.OK == _nonceVerifier.seen(
            discovered.getOPEndpoint().toString(), nonce));
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:25,代码来源:ConsumerManager.java


示例3: verifyDiscovered

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
/**
 * Verifies the dicovery information matches the data received in a
 * authentication response from an OpenID Provider.
 *
 * @param authResp      The authentication response to be verified.
 * @param discovered    The discovery information obtained earlier during
 *                      the discovery stage, associated with the
 *                      identifier(s) in the request. Stateless operation
 *                      is assumed if null.
 * @return              The discovery information associated with the
 *                      claimed identifier, that can be used further in
 *                      the verification process. Null if the discovery
 *                      on the claimed identifier does not match the data
 *                      in the assertion.
 */
private DiscoveryInformation verifyDiscovered(AuthSuccess authResp,
                                    DiscoveryInformation discovered)
        throws DiscoveryException
{
    if (authResp == null || authResp.getIdentity() == null)
    {
        _log.info("Assertion is not about an identifier");
        return null;
    }

    if (authResp.isVersion2())
        return verifyDiscovered2(authResp, discovered);
    else
        return verifyDiscovered1(authResp, discovered);
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:31,代码来源:ConsumerManager.java


示例4: login

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
@Override
public String login() throws LogicException {
    try {
        // perform discovery on the user-supplied identifier
        List<?> discoveries = consumerManager.discover("http://steamcommunity.com/openid");

        // attempt to associate with the OpenID provider
        // and retrieve one service endpoint for authentication
        DiscoveryInformation discovered = consumerManager.associate(discoveries);

        // store the discovery information in the user's session for later use
        // leave out for stateless operation / if there is no session
        getSession().setAttribute("discovered", discovered);

        // obtain a AuthRequest message to be sent to the OpenID provider

        AuthRequest authReq = consumerManager.authenticate(discovered, getServletContext().getInitParameter("callback.url"));
        String result = authReq.getDestinationUrl(true);
        return result;
    } catch (MessageException | ConsumerException | DiscoveryException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:rkfg,项目名称:ns2gather,代码行数:25,代码来源:NS2GServiceImpl.java


示例5: authorizationRequest

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
/**
 * Send authorization request to OpenID server
 * @param userSuppliedString - OpenID username/login
 * @param req - current request object
 * @param res - current response object
 * @return - true if sent, false if error
 * @throws IOException - other problem
 */
public boolean authorizationRequest(String userSuppliedString, HttpServletRequest req, HttpServletResponse res) throws IOException {
    try {
        List discoveries = manager.discover(userSuppliedString);

        DiscoveryInformation discovered = manager.associate(discoveries);

        req.getSession().setAttribute("openid-disc", discovered);

        AuthRequest authReq = manager.authenticate(discovered, returnToUrl);
        SRegRequest sregReq = SRegRequest.createFetchRequest();

        sregReq.addAttribute("email", true);
        sregReq.addAttribute("fullname", true);
        authReq.addExtension(sregReq);

        res.sendRedirect(authReq.getDestinationUrl(true));

        return true;
    } catch (OpenIDException ex) {
        // logger.error("Exception in authRequest with '" + userSuppliedString + "'", ex);
    }

    return false;
}
 
开发者ID:faramir,项目名称:ZawodyWeb,代码行数:33,代码来源:OpenIdConsumer.java


示例6: processOpenIdAnswer

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
@RequestMapping(value = "/", method = POST)
public void processOpenIdAnswer(HttpServletRequest request, HttpServletResponse response)
    throws Exception {

    String handle = request.getParameter(HANDLE_PARAM);
    boolean isImmediateRequest = request.getParameterMap().containsKey(IMMEDIATE_PARAM);

    String returnUrl = request.getRequestURL().toString() + ANSWER_PAGE;

    // perform discovery on the user-supplied identifier
    List discoveries = manager.discover(handle);

    // attempt to associate with the OpenID provider
    // and retrieve one service endpoint for authentication
    DiscoveryInformation discovered = manager.associate(discoveries);

    // store the discovery information in the user's session
    request.getSession().setAttribute(DISCOVERY_SESSION_KEY, discovered);

    // obtain a AuthRequest message to be sent to the OpenID provider
    AuthRequest authReq = manager.authenticate(discovered, returnUrl);
    authReq.setImmediate(isImmediateRequest);

    // since our service uses OpenId Version two this should to it
    response.sendRedirect(authReq.getDestinationUrl(true));
}
 
开发者ID:patka,项目名称:cognitor,代码行数:27,代码来源:ConsumerController.java


示例7: retrieveRedirectAction

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
protected RedirectAction retrieveRedirectAction(final WebContext context) throws HttpAction {
    final String userIdentifier = getUser(context);
    CommonHelper.assertNotBlank("openIdUser", userIdentifier);

    try {
        // perform discovery on the user-supplied identifier
        final List discoveries = this.consumerManager.discover(userIdentifier);

        // attempt to associate with the OpenID provider
        // and retrieve one service endpoint for authentication
        final DiscoveryInformation discoveryInformation = this.consumerManager.associate(discoveries);

        // save discovery information in session
        context.setSessionAttribute(getDiscoveryInformationSessionAttributeName(), discoveryInformation);

        // create authentication request to be sent to the OpenID provider
        final AuthRequest authRequest = this.consumerManager.authenticate(discoveryInformation,
                computeFinalCallbackUrl(context));

        // create fetch request for attributes
        final FetchRequest fetchRequest = getFetchRequest();
        if (fetchRequest != null) {
            authRequest.addExtension(fetchRequest);
        }

        final String redirectionUrl = authRequest.getDestinationUrl(true);
        logger.debug("redirectionUrl: {}", redirectionUrl);
        return RedirectAction.redirect(redirectionUrl);
    } catch (final OpenIDException e) {
        throw new TechnicalException("OpenID exception", e);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:35,代码来源:BaseOpenIdClient.java


示例8: retrieveUserProfile

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
@Override
protected U retrieveUserProfile(final OpenIdCredentials credentials, final WebContext context) throws HttpAction {
    final ParameterList parameterList = credentials.getParameterList();
    final DiscoveryInformation discoveryInformation = credentials.getDiscoveryInformation();
    logger.debug("parameterList: {}", parameterList);
    logger.debug("discoveryInformation: {}", discoveryInformation);

    try {
        // verify the response
        final VerificationResult verification = this.consumerManager.verify(computeFinalCallbackUrl(context), parameterList,
                discoveryInformation);

        // examine the verification result and extract the verified identifier
        final Identifier verified = verification.getVerifiedId();
        if (verified != null) {
            final AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();
            logger.debug("authSuccess: {}", authSuccess);

            final U profile = createProfile(authSuccess);
            profile.setId(verified.getIdentifier());
            logger.debug("profile: {}", profile);
            return profile;
        }
    } catch (final OpenIDException e) {
        throw new TechnicalException("OpenID exception", e);
    }

    final String message = "No verifiedId found";
    throw new TechnicalException(message);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:31,代码来源:BaseOpenIdClient.java


示例9: OpenIdCredentials

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
public OpenIdCredentials(final DiscoveryInformation discoveryInformation, final ParameterList parameterList,
                         final String clientName) {
    this.discoveryInformation = discoveryInformation;
    this.parameterList = parameterList;
    setClientName(clientName);
    
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:OpenIdCredentials.java


示例10: getDiscoveredInformation

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
public List getDiscoveredInformation(Set targetTypes) throws DiscoveryException
{
    List result = new ArrayList();

    if (hasEndpoints()) 
    {
        XrdsServiceEndpoint endpoint;
        Iterator endpointsIter = _endpoints.iterator();
        while (endpointsIter.hasNext()) {
            endpoint = (XrdsServiceEndpoint) endpointsIter.next();
            Iterator typesIter = endpoint.getTypes().iterator();
            while (typesIter.hasNext()) {
                String type = (String) typesIter.next();
                if (!targetTypes.contains(type)) continue;
                try {
                    result.add(new DiscoveryInformation(
                        new URL(endpoint.getUri()),
                        DiscoveryInformation.OPENID_SIGNON_TYPES.contains(type) ?
                            new UrlIdentifier(_normalizedUrl) : null,
                        DiscoveryInformation.OPENID2.equals(type) ? endpoint.getLocalId() :
                        DiscoveryInformation.OPENID1_SIGNON_TYPES.contains(type) ? endpoint.getDelegate() : null,
                        type,
                        endpoint.getTypes()));
                } catch (MalformedURLException e) {
                    throw new YadisException("Invalid endpoint URL discovered: " + endpoint.getUri(), OpenIDException.YADIS_INVALID_URL);
                }
            }
        }
    }
    return result;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:32,代码来源:YadisResult.java


示例11: testPerferredAssociation

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
public void testPerferredAssociation() throws Exception {
	manager.setPrefAssocSessEnc(AssociationSessionType.DH_SHA1);
	DiscoveryInformation disc = new DiscoveryInformation(new URL(server.createAbsoluteUrl("/op/endpoint")), null);
	DiscoveryInformation info = manager.associate(Collections.singletonList(disc));
	assertEquals(1,server.getRequestParams().size());
	Map request = (Map)server.getRequestParams().get(0);
	assertEquals(manager.getPrefAssocSessEnc().getAssociationType(),((String[])request.get("openid.assoc_type"))[0]);
	assertEquals(manager.getPrefAssocSessEnc().getSessionType(),((String[])request.get("openid.session_type"))[0]);
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:10,代码来源:ConsumerManagerTest.java


示例12: testXrdsOpenidDelegate

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
public void testXrdsOpenidDelegate() throws Exception
{
    List result;
    try
    {
        result = _resolver.discover("http://localhost:" + _servletPort + "/?headers=simplexrds&xrds=xrdsdelegate");
        assertEquals("Should have discovered one endpoint: ", result.size(), 1);
        DiscoveryInformation info = (DiscoveryInformation) result.get(0);
        assertNotNull("Should have discovered an openid:Delegate.", info.getDelegateIdentifier());
    }
    catch (DiscoveryException e)
    {
        fail("Discovery failed on xrdsdelegate: " + e.getMessage());
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:16,代码来源:YadisResolverTest.java


示例13: init

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
private State init(
    HttpServletRequest req,
    final String openidIdentifier,
    final SignInMode mode,
    final boolean remember,
    final String returnToken) {
  final List<?> list;
  try {
    list = manager.discover(openidIdentifier);
  } catch (DiscoveryException e) {
    log.error("Cannot discover OpenID " + openidIdentifier, e);
    return null;
  }
  if (list == null || list.isEmpty()) {
    return null;
  }

  final String contextUrl = urlProvider.get(req);
  final DiscoveryInformation discovered = manager.associate(list);
  final UrlEncoded retTo = new UrlEncoded(contextUrl + RETURN_URL);
  retTo.put(P_MODE, mode.name());
  if (returnToken != null && returnToken.length() > 0) {
    retTo.put(P_TOKEN, returnToken);
  }
  if (remember) {
    retTo.put(P_REMEMBER, "1");
  }
  if (discovered.hasClaimedIdentifier()) {
    retTo.put(P_CLAIMED, discovered.getClaimedIdentifier().getIdentifier());
  }
  return new State(discovered, retTo, contextUrl);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:33,代码来源:OpenIdServiceImpl.java


示例14: prepareAuthenticationUrl

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的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);
}
 
开发者ID:bubblecloud,项目名称:ilves,代码行数:26,代码来源:OpenIdUtil.java


示例15: getVerificationResult

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
/**
 * Gets verification result based on session and request parameters. This should be called when
 * processing the OpenId return request.
 * @param siteUrl the site URL
 * @param returnViewName the return view name
 *
 * @return the verification result
 * @throws DiscoveryException if discovery exception occurs.
 * @throws MessageException if message exception occurs.
 * @throws AssociationException if association exception occurs.
 */
public static VerificationResult getVerificationResult(final String siteUrl
        , final String returnViewName) throws MessageException, DiscoveryException,
        AssociationException {
    final ConsumerManager consumerManager = UI.getCurrent().getSession().getAttribute(ConsumerManager.class);
    final DiscoveryInformation discovered = UI.getCurrent().getSession().getAttribute(
            DiscoveryInformation.class);
    UI.getCurrent().getSession().setAttribute(ConsumerManager.class, null);
    UI.getCurrent().getSession().setAttribute(DiscoveryInformation.class, null);

    final HttpServletRequest request = ((VaadinServletRequest) VaadinService.getCurrentRequest())
            .getHttpServletRequest();

    final StringBuffer urlBuilder = new StringBuffer(siteUrl + returnViewName);
    final String queryString = request.getQueryString();
    if (queryString != null) {
        urlBuilder.append('?');
        urlBuilder.append(queryString);
    }
    final String requestUrl = urlBuilder.toString();

    final ParameterList openidResp = new ParameterList(request.getParameterMap());

    // verify the response
    return consumerManager.verify(requestUrl,
            openidResp, discovered);
}
 
开发者ID:bubblecloud,项目名称:ilves,代码行数:38,代码来源:OpenIdUtil.java


示例16: verifyResponse

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
public Identifier verifyResponse(Request httpReq, Map<Object, Object> model, ParameterList params)
		throws ServletException {
	try {
		
		// extract the parameters from the authentication response
           // (which comes in as a HTTP request from the OpenID provider)
           ParameterList parameterList = new ParameterList(httpReq.params());
           parameterList.addParams(params);
		
		// retrieve the previously stored discovery information
		DiscoveryInformation discovered = httpReq.session().attribute("openid-disc");

		// extract the receiving URL from the HTTP request
		StringBuffer receivingURL = httpReq.raw().getRequestURL();
		String queryString = httpReq.queryString();
		if (queryString != null && queryString.length() > 0)
			receivingURL.append("?").append(queryString);

		// verify the response; ConsumerManager needs to be the same
		// (static) instance used to place the authentication request
		VerificationResult verification = manager.verify(receivingURL.toString(), parameterList, discovered);

		// examine the verification result and extract the verified
		// identifier
		Identifier verified = verification.getVerifiedId();
		if (verified != null) {
			AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();

			receiveAttributeExchange(model, authSuccess);
			return verified; // success
		}
	} catch (OpenIDException e) {
		// present error to the user
		throw new ServletException(e);
	}
	return null;
}
 
开发者ID:AveryRegier,项目名称:club-tracker,代码行数:38,代码来源:ConsumerService.java


示例17: showAnswer

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
@RequestMapping(value = "/openidAnswer", method = GET)
public ModelAndView showAnswer(HttpServletRequest request) throws Exception {
    ParameterList response = new ParameterList(request.getParameterMap());

    // retrieve the previously stored discovery information
    DiscoveryInformation discovered =
            (DiscoveryInformation) request.getSession().getAttribute(DISCOVERY_SESSION_KEY);

    // extract the receiving URL from the HTTP request
    StringBuffer receivingURL = request.getRequestURL();
    String queryString = request.getQueryString();
    if (queryString != null && queryString.length() > 0) {
        receivingURL.append("?").append(request.getQueryString());
    }

    // verify the response
    VerificationResult verification = manager.verify(
            receivingURL.toString(),
            response, discovered);

    // examine the verification result and extract the verified identifier
    Identifier identifier = verification.getVerifiedId();
    ModelAndView modelAndView = new ModelAndView("answer");
    modelAndView.addObject("identifier", identifier);
    if (identifier != null) {
        modelAndView.addObject("uniqueId", getUniqueId(identifier.getIdentifier()));
    } else {
        modelAndView.addObject("uniqueId", "no Id received");
    }
    return modelAndView;
}
 
开发者ID:patka,项目名称:cognitor,代码行数:32,代码来源:ConsumerController.java


示例18: getDiscoveryInformation

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
public DiscoveryInformation getDiscoveryInformation() {
    return this.discoveryInformation;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:4,代码来源:OpenIdCredentials.java


示例19: getDiscoveryInformation

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
public DiscoveryInformation getDiscoveryInformation() {
    return discoveryInformation;
}
 
开发者ID:wso2-extensions,项目名称:identity-agent-sso,代码行数:4,代码来源:SSOAgentSessionBean.java


示例20: setDiscoveryInformation

import org.openid4java.discovery.DiscoveryInformation; //导入依赖的package包/类
public void setDiscoveryInformation(DiscoveryInformation discoveryInformation) {
    this.discoveryInformation = discoveryInformation;
}
 
开发者ID:wso2-extensions,项目名称:identity-agent-sso,代码行数:4,代码来源:SSOAgentSessionBean.java



注:本文中的org.openid4java.discovery.DiscoveryInformation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AmazonCloudFormation类代码示例发布时间:2022-05-21
下一篇:
Java FillPath类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap