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

Java OpenIDException类代码示例

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

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



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

示例1: createIndirectError

import org.openid4java.OpenIDException; //导入依赖的package包/类
public static IndirectError createIndirectError(OpenIDException e,
                                                String msg, String returnTo,
                                                boolean compatibility)
{
    IndirectError err = new IndirectError(e, msg, returnTo, compatibility);

    try
    {
        err.validate();
    }
    catch (MessageException ex)
    {
        _log.error("Invalid " + (compatibility? "OpenID1" : "OpenID2") +
                   " indirect error message created for message: " + msg);
    }

    _log.debug("Created indirect error message:\n" + err.keyValueFormEncoding());

    return err;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:21,代码来源:IndirectError.java


示例2: validate

import org.openid4java.OpenIDException; //导入依赖的package包/类
public void validate() throws MessageException
{
    if (! MODE_CHKAUTH.equals(getParameterValue("openid.mode")))
    {
        throw new MessageException(
            "Invalid openid.mode in verification request: "
            + getParameterValue("openid.mode"),
            OpenIDException.VERIFY_ERROR);
    }

    set("openid.mode", MODE_IDRES);

    if (DEBUG) _log.debug("Delegating verification request validity check " +
                          "to auth response...");

    super.validate();

    set("openid.mode", MODE_CHKAUTH);
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:20,代码来源:VerifyRequest.java


示例3: createDirectError

import org.openid4java.OpenIDException; //导入依赖的package包/类
public static DirectError createDirectError(OpenIDException e, String msg, boolean compatibility)
{
    DirectError err = new DirectError(e, msg, compatibility);

    try
    {
        err.validate();
    }
    catch (MessageException ex)
    {
        _log.error("Invalid " + (compatibility? "OpenID1" : "OpenID2") +
                   " direct error message created for message: " + msg);
    }

    _log.debug("Created direct error message:\n" + err.keyValueFormEncoding());

    return err;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:19,代码来源:DirectError.java


示例4: validate

import org.openid4java.OpenIDException; //导入依赖的package包/类
/**
 * Checks the validity of the extension.
 * <p>
 * Used when constructing a extension from a parameter list.
 *
 * @throws MessageException if the PapeRequest is not valid.
 */
public void validate() throws MessageException
{
    if (! _parameters.hasParameter("preferred_auth_policies"))
    {
        throw new MessageException(
            "preferred_auth_policies is required in a PAPE request.",
            OpenIDException.PAPE_ERROR);
    }

    Iterator it = _parameters.getParameters().iterator();
    while (it.hasNext())
    {
        String paramName = ((Parameter) it.next()).getKey();
        if (! PAPE_FIELDS.contains(paramName) && ! paramName.startsWith(PapeMessage.AUTH_LEVEL_NS_PREFIX))
        {
            throw new MessageException(
                "Invalid parameter name in PAPE request: " + paramName,
                OpenIDException.PAPE_ERROR);
        }
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:29,代码来源:PapeRequest.java


示例5: parseDocument

import org.openid4java.OpenIDException; //导入依赖的package包/类
private HTMLDocumentImpl parseDocument(String htmlData) throws DiscoveryException
{
    OpenID4JavaDOMParser parser = new OpenID4JavaDOMParser();
    try
    {
        parser.parse(OpenID4JavaDOMParser.createInputSource(htmlData));
    }
    catch (Exception e)
    {
        throw new DiscoveryException("Error parsing HTML message",
        		OpenIDException.DISCOVERY_HTML_PARSE_ERROR, e);
    }

    if (parser.isIgnoredHeadStartElement())
    {
        throw new DiscoveryException(
                "HTML response must have exactly one HEAD element.",
                OpenIDException.DISCOVERY_HTML_PARSE_ERROR);
    }

    return (HTMLDocumentImpl) parser.getDocument();
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:23,代码来源:CyberNekoDOMHtmlParser.java


示例6: parseDocument

import org.openid4java.OpenIDException; //导入依赖的package包/类
private HTMLDocumentImpl parseDocument(String htmlData) throws YadisException
{
    OpenID4JavaDOMParser parser = new OpenID4JavaDOMParser();
    try
    {
        parser.parse(OpenID4JavaDOMParser.createInputSource(htmlData));
    }
    catch (Exception e)
    {
        throw new YadisException("Error parsing HTML message",
                OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE, e);
    }

    if (parser.isIgnoredHeadStartElement())
    {
            throw new YadisException("HTML response must have exactly one HEAD element.",
                            OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE);
    }

    return (HTMLDocumentImpl) parser.getDocument();
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:22,代码来源:CyberNekoDOMYadisHtmlParser.java


示例7: urlFromString

import org.openid4java.OpenIDException; //导入依赖的package包/类
/**
 * Constructs a URL object from a string;
 * needed by the YadisURL(String) constructor
 *
 * @param urlString         URL-type identifier in string format
 * @return                  URL object
 * @throws YadisException   if the provided string is not a valid URL
 */
private static URL urlFromString(String urlString) throws YadisException
{
    URL url;

    try
    {
        url = new URL(urlString);
    }
    catch (MalformedURLException e)
    {
        throw new YadisException("Invalid URL: " + urlString,
                OpenIDException.YADIS_INVALID_URL, e);
    }

    return url;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:25,代码来源:YadisUrl.java


示例8: discover

import org.openid4java.OpenIDException; //导入依赖的package包/类
public YadisResult discover(String url, int maxRedirects, HttpFetcher httpFetcher, Set serviceTypes)
    throws DiscoveryException
{
    YadisUrl yadisUrl = new YadisUrl(url);

    // try to retrieve the Yadis Descriptor URL with a HEAD call first
    YadisResult result = retrieveXrdsLocation(yadisUrl, false, maxRedirects, serviceTypes);

    // try GET 
    if (result.getXrdsLocation() == null)
        result = retrieveXrdsLocation(yadisUrl, true, maxRedirects, serviceTypes);

    if (result.getXrdsLocation() != null)
    {
        retrieveXrdsDocument(result, maxRedirects, serviceTypes);
    }
    else if (result.hasEndpoints())
    {
        // report the yadis url as the xrds location
        result.setXrdsLocation(url, OpenIDException.YADIS_INVALID_URL);
    }

    _log.info("Yadis discovered " + result.getEndpointCount() + " endpoints from: " + url);
    return result;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:26,代码来源:YadisResolver.java


示例9: getHtmlMeta

import org.openid4java.OpenIDException; //导入依赖的package包/类
/**
 * Parses the HTML input stream and scans for the Yadis XRDS location
 * in the HTML HEAD Meta tags.
 *
 * @param input             input data stream
 * @return String           the XRDS location URL, or null if not found
 * @throws YadisException   on parsing errors or Yadis protocal violations
 */
private String getHtmlMeta(String input) throws YadisException
{
    String xrdsLocation;

    if (input == null)
        throw new YadisException("Cannot download HTML message",
                OpenIDException.YADIS_HTMLMETA_DOWNLOAD_ERROR);

    xrdsLocation = YADIS_HTML_PARSER.getHtmlMeta(input);
    if (DEBUG)
    {
        _log.debug("input:\n" + input);
        _log.debug("xrdsLocation: " + xrdsLocation);
    }
    return xrdsLocation;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:25,代码来源:YadisResolver.java


示例10: testInvalidUrl

import org.openid4java.OpenIDException; //导入依赖的package包/类
public void testInvalidUrl()
{
    try
    {
        _resolver.discover("bla.com");

        fail("Should have failed with error code " +
             OpenIDException.YADIS_INVALID_URL);
    }
    catch (DiscoveryException expected)
    {
        assertEquals(expected.getMessage(),
                OpenIDException.YADIS_INVALID_URL, expected.getErrorCode());
    }

}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:17,代码来源:YadisResolverTest.java


示例11: testHeadTransportError

import org.openid4java.OpenIDException; //导入依赖的package包/类
public void testHeadTransportError() throws Exception
{
    _server.stop();

    try
    {
        _resolver.discover("http://localhost:" + _servletPort +
                           "/?servertopped");

        fail("Should have failed with error code " +
             OpenIDException.YADIS_HEAD_TRANSPORT_ERROR);
    }
    catch (YadisException expected)
    {
        assertEquals(expected.getMessage(),
                OpenIDException.YADIS_HEAD_TRANSPORT_ERROR, expected.getErrorCode());
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:19,代码来源:YadisResolverTest.java


示例12: testMultipleXrdsLocationInHtml

import org.openid4java.OpenIDException; //导入依赖的package包/类
public void testMultipleXrdsLocationInHtml()
{
    try
    {
        _resolver.discover("http://localhost:" +
            _servletPort + "/?html=multiplexrdslocation");

        fail("Should have failed with error code " +
             OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE);
    }
    catch (DiscoveryException expected)
    {
        assertEquals(expected.getMessage(),
            OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE, expected.getErrorCode());
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:17,代码来源:YadisResolverTest.java


示例13: testHtmlHeadElementsNoHead

import org.openid4java.OpenIDException; //导入依赖的package包/类
public void testHtmlHeadElementsNoHead()
{
    try
    {
        _resolver.discover("http://localhost:" +
            _servletPort + "/?html=nohead");

        fail("Should have failed with error code " +
            OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE);
    }
    catch (DiscoveryException expected)
    {
        assertEquals(expected.getMessage(),
            OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE, expected.getErrorCode());
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:17,代码来源:YadisResolverTest.java


示例14: testEmptyHtml

import org.openid4java.OpenIDException; //导入依赖的package包/类
public void testEmptyHtml()
{
    try
    {
        _resolver.discover("http://localhost:" +
            _servletPort + "/?html=empty");

        fail("Should have failed with error code " +
            OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE);
    }
    catch (DiscoveryException expected)
    {
        assertEquals(expected.getMessage(),
            OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE, expected.getErrorCode());
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:17,代码来源:YadisResolverTest.java


示例15: testGetError

import org.openid4java.OpenIDException; //导入依赖的package包/类
public void testGetError() throws Exception
{
    try
    {
        _resolver.discover("http://localhost:" +
            _servletPort + "/?html=nonexistantfile");

        fail("Should have failed with error code " +
            OpenIDException.YADIS_GET_ERROR);
    }
    catch (YadisException expected)
    {
        assertEquals(expected.getMessage(),
            OpenIDException.YADIS_GET_ERROR, expected.getErrorCode());
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:17,代码来源:YadisResolverTest.java


示例16: testXrdsSizeExceeded

import org.openid4java.OpenIDException; //导入依赖的package包/类
public void testXrdsSizeExceeded()
{
    HttpRequestOptions requestOptions = new HttpRequestOptions();
    requestOptions.setMaxBodySize(10);

    HttpFetcher cache = new HttpCache();
    cache.setDefaultRequestOptions(requestOptions);

    YadisResolver resolver = new YadisResolver(cache);

    try
    {
        resolver.discover("http://localhost:" +
            _servletPort + "/?headers=simpleheaders");

        fail("Should have failed with error code " +
            OpenIDException.YADIS_XRDS_SIZE_EXCEEDED);
    }
    catch (DiscoveryException expected)
    {
        assertEquals(expected.getMessage(),
            OpenIDException.YADIS_XRDS_SIZE_EXCEEDED, expected.getErrorCode());
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:25,代码来源:YadisResolverTest.java


示例17: authorizationRequest

import org.openid4java.OpenIDException; //导入依赖的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


示例18: retrieveRedirectAction

import org.openid4java.OpenIDException; //导入依赖的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


示例19: retrieveUserProfile

import org.openid4java.OpenIDException; //导入依赖的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


示例20: IndirectError

import org.openid4java.OpenIDException; //导入依赖的package包/类
protected IndirectError(OpenIDException e, String msg, String returnTo, boolean compatibility)
{
    set("openid.mode", "error");
    set("openid.error", msg);
    _destinationUrl = returnTo;
    _exception = e;

    if (! compatibility)
        set("openid.ns", OPENID2_NS);
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:11,代码来源:IndirectError.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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