当前位置: 首页>>代码示例>>Java>>正文


Java DiscoveryInformation.hasClaimedIdentifier方法代码示例

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


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

示例1: 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

示例2: authenticate

import org.openid4java.discovery.DiscoveryInformation; //导入方法依赖的package包/类
/**
 * Builds a authentication request message for the user specified in the
 * discovery information provided as a parameter.
 *
 * @param discovered        A DiscoveryInformation endpoint from the list
 *                          obtained by performing dicovery on the
 *                          User-supplied OpenID identifier.
 * @param returnToUrl       The URL on the Consumer site where the OpenID
 *                          Provider will return the user after generating
 *                          the authentication response. <br>
 *                          Null if the Consumer does not with to for the
 *                          End User to be returned to it (something else
 *                          useful will have been performed via an
 *                          extension). <br>
 *                          Must not be null in OpenID 1.x compatibility
 *                          mode.
 * @param realm             The URL pattern that will be presented to the
 *                          user when he/she will be asked to authorize the
 *                          authentication transaction. Must be a super-set
 *                          of the @returnToUrl.
 * @return                  Authentication request message to be sent to the
 *                          OpenID Provider.
 */
public AuthRequest authenticate(DiscoveryInformation discovered,
                                String returnToUrl, String realm)
        throws MessageException, ConsumerException
{
    if (discovered == null)
        throw new ConsumerException("Authentication cannot continue: " +
                "no discovery information provided.");

    Association assoc =
            _associations.load(discovered.getOPEndpoint().toString());

    if (assoc == null)
    {
        associate(discovered, _maxAssocAttempts);
        assoc = _associations.load(discovered.getOPEndpoint().toString());
    }

    String handle = assoc != null ?
            assoc.getHandle() : Association.FAILED_ASSOC_HANDLE;

    // get the Claimed ID and Delegate ID (aka OP-specific identifier)
    String claimedId, delegate;
    if (discovered.hasClaimedIdentifier())
    {
        claimedId = discovered.getClaimedIdentifier().getIdentifier();
        delegate = discovered.hasDelegateIdentifier() ?
                   discovered.getDelegateIdentifier() : claimedId;
    }
    else
    {
        claimedId = AuthRequest.SELECT_ID;
        delegate = AuthRequest.SELECT_ID;
    }

    // stateless mode disabled ?
    if ( !_allowStateless && Association.FAILED_ASSOC_HANDLE.equals(handle))
        throw new ConsumerException("Authentication cannot be performed: " +
                "no association available and stateless mode is disabled");

    _log.info("Creating authentication request for" +
            " OP-endpoint: " + discovered.getOPEndpoint() +
            " claimedID: " + claimedId +
            " OP-specific ID: " + delegate);

    if (! discovered.isVersion2())
        returnToUrl = insertConsumerNonce(discovered.getOPEndpoint().toString(), returnToUrl);

    AuthRequest authReq = AuthRequest.createAuthRequest(claimedId, delegate,
            ! discovered.isVersion2(), returnToUrl, handle, realm, _realmVerifier);

    authReq.setOPEndpoint(discovered.getOPEndpoint());

    // ignore the immediate flag for OP-directed identifier selection
    if (! AuthRequest.SELECT_ID.equals(claimedId))
        authReq.setImmediate(_immediateAuth);

    return authReq;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:82,代码来源:ConsumerManager.java


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