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

Java DiscoveryException类代码示例

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

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



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

示例1: reconnectToMxID

import org.openid4java.discovery.DiscoveryException; //导入依赖的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);
	}
}
 
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:21,代码来源:OpenIDHandler.java


示例2: clientIdentification

import org.openid4java.discovery.DiscoveryException; //导入依赖的package包/类
@POST
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response clientIdentification(InitialID id) throws DiscoveryException, Exception {
	try {
		if (personService.authenticate(id.getUserID(), id.getPassWord())) {
			GluuCustomPerson user = personService.getPersonByUid(id.getUserID());
			postLogin(user);
			return Response.ok().build();
		} else {
			return Response.status(401).entity("Not Authorized").build();
		}
	} catch (Exception ex) {
		log.error("an error occured", ex);
		return Response.status(401).entity("Not Authorized").build();
	}
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:18,代码来源:OxChooserWebService.java


示例3: verifyDiscovered

import org.openid4java.discovery.DiscoveryException; //导入依赖的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: setEndpoint1

import org.openid4java.discovery.DiscoveryException; //导入依赖的package包/类
public void setEndpoint1(String op1Endpoint) throws DiscoveryException
{
    URL url;
    try
    {
        url = new URL(op1Endpoint);

        _op1Endpoint = url;
    }
    catch (MalformedURLException e)
    {
        throw new DiscoveryException(
                "Invalid openid.server URL: " + op1Endpoint);
    }

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


示例5: setEndpoint2

import org.openid4java.discovery.DiscoveryException; //导入依赖的package包/类
public void setEndpoint2(String op2Endpoint) throws DiscoveryException
{
    URL url;
    try
    {
        url = new URL(op2Endpoint);

        _op2Endpoint = url;

    } catch (MalformedURLException e)
    {
        throw new DiscoveryException(
                "Invalid openid2.provider URL: " + op2Endpoint);
    }

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


示例6: parseDocument

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


示例7: discover

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


示例8: testInvalidUrl

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


示例9: testMultipleXrdsLocationInHtml

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


示例10: testHtmlHeadElementsNoHead

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


示例11: testHtmlHeadElementsExtraHeadInBody

import org.openid4java.discovery.DiscoveryException; //导入依赖的package包/类
public void testHtmlHeadElementsExtraHeadInBody() {
    try
    {
        YadisResult result = _resolver.discover("http://localhost:" +_servletPort + "/?html=extraheadinbody",
            10, Collections.singleton("http://example.com/"));

        assertTrue("Discovery should have ignored a html/body/head; " +
                   " we only care about spurious html/head's", result.getEndpoints().size() == 1);

    }
    catch (DiscoveryException e)
    {
        fail("Discovery should have ignored a html/body/head; " +
                   " we only care about spurious html/head's");
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:17,代码来源:YadisResolverTest.java


示例12: testEmptyHtml

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


示例13: testXrdsSizeExceeded

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


示例14: login

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


示例15: parseHtml

import org.openid4java.discovery.DiscoveryException; //导入依赖的package包/类
public void parseHtml(String htmlData, HtmlResult result)
        throws DiscoveryException
{
    if (DEBUG)
        _log.debug("Parsing HTML data:\n" + htmlData);

    HTMLDocumentImpl doc = this.parseDocument(htmlData);

    NodeList heads = doc.getElementsByTagName("head");
    if (heads.getLength() != 1)
        throw new DiscoveryException(
                "HTML response must have exactly one HEAD element, "
                        + "found " + heads.getLength() + " : "
                        + heads.toString(),
                OpenIDException.DISCOVERY_HTML_PARSE_ERROR);

    HTMLHeadElement head = (HTMLHeadElement) doc.getHead();
    NodeList linkElements = head.getElementsByTagName("LINK");
    for (int i = 0, len = linkElements.getLength(); i < len; i++)
    {
        HTMLLinkElement linkElement = (HTMLLinkElement) linkElements.item(i);
        setResult(linkElement.getRel(), linkElement.getHref(), result);
    }

    if (DEBUG)
        _log.debug("HTML discovery result:\n" + result);
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:28,代码来源:CyberNekoDOMHtmlParser.java


示例16: discoverHtml

import org.openid4java.discovery.DiscoveryException; //导入依赖的package包/类
/**
 * Performs HTML discovery on the supplied URL identifier.
 *
 * @param identifier        The URL identifier.
 * @param httpFetcher       {@link HttpFetcher} object to use for placing the call.
 * @return                  List of DiscoveryInformation entries discovered
 *                          obtained from the URL Identifier.
 */
public List discoverHtml(UrlIdentifier identifier, HttpFetcher httpFetcher)
    throws DiscoveryException
{
    // initialize the results of the HTML discovery
    HtmlResult result = new HtmlResult();

    HttpRequestOptions requestOptions = httpFetcher.getRequestOptions();
    requestOptions.setContentType("text/html");

    try
    {
        HttpResponse resp = httpFetcher.get(identifier.toString(), requestOptions);

        if (HttpStatus.SC_OK != resp.getStatusCode())
            throw new DiscoveryException( "GET failed on " +
                identifier.toString() +
                " Received status code: " + resp.getStatusCode(),
                OpenIDException.DISCOVERY_HTML_GET_ERROR);

        result.setClaimed( new UrlIdentifier(resp.getFinalUri()) );

        if (resp.getBody() == null)
            throw new DiscoveryException(
                    "No HTML data read from " + identifier.toString(),
            OpenIDException.DISCOVERY_HTML_NODATA_ERROR);

        HTML_PARSER.parseHtml(resp.getBody(), result);
    }
    catch (IOException e)
    {
        throw new DiscoveryException("Fatal transport error: ",
                OpenIDException.DISCOVERY_HTML_GET_ERROR, e);
    }

    _log.info("HTML discovery completed on: " + identifier);

    return extractDiscoveryInformation(result);
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:47,代码来源:HtmlResolver.java


示例17: getDiscoveredInformation

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


示例18: retrieveXrdsDocument

import org.openid4java.discovery.DiscoveryException; //导入依赖的package包/类
/**
 * Tries to retrieve the XRDS document via a GET call on XRDS location
 * provided in the result parameter.
 *
 * @param result        The YadisResult object containing a valid XRDS location.
 *                      It will be further populated with the Yadis discovery results.
 * @param cache        The HttpClient object to use for placing the call
 * @param maxRedirects
 */
private void retrieveXrdsDocument(YadisResult result, int maxRedirects, Set serviceTypes)
    throws DiscoveryException {

    _httpFetcher.getRequestOptions().setMaxRedirects(maxRedirects);

    try {
        HttpResponse resp = _httpFetcher.get(result.getXrdsLocation().toString());

        if (resp == null || HttpStatus.SC_OK != resp.getStatusCode())
            throw new YadisException("GET failed on " + result.getXrdsLocation(),
                    OpenIDException.YADIS_GET_ERROR);

        // update xrds location, in case redirects were followed
        result.setXrdsLocation(resp.getFinalUri(), OpenIDException.YADIS_GET_INVALID_RESPONSE);

        Header contentType = resp.getResponseHeader("content-type");
        if ( contentType != null && contentType.getValue() != null)
            result.setContentType(contentType.getValue());

        if (resp.isBodySizeExceeded())
            throw new YadisException(
                "More than " + _httpFetcher.getRequestOptions().getMaxBodySize() +
                " bytes in HTTP response body from " + result.getXrdsLocation(),
                OpenIDException.YADIS_XRDS_SIZE_EXCEEDED);
        result.setEndpoints(XRDS_PARSER.parseXrds(resp.getBody(), serviceTypes));

    } catch (IOException e) {
        throw new YadisException("Fatal transport error: " + e.getMessage(),
                OpenIDException.YADIS_GET_TRANSPORT_ERROR, e);
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:41,代码来源:YadisResolver.java


示例19: discover

import org.openid4java.discovery.DiscoveryException; //导入依赖的package包/类
public List discover(XriIdentifier xri) throws DiscoveryException
{
    try
    {
    	ResolverFlags flags = new ResolverFlags();
    	flags.setCid(true);
    	flags.setRefs(true);
    	ResolverState state = new ResolverState();
        XRDS xrds = _openXriResolver.resolveAuthToXRDS(
        		new XRI(xri.getIdentifier()), flags, state);

        if (DEBUG) _log.debug("Retrieved XRDS:\n" + xrds.dump());

        XRD xrd = xrds.getFinalXRD();

        if (! xrd.getStatus().getCID().equals(Status.CID_VERIFIED))
        {
        	_log.error("Unverified CanonicalID: " + xrd.getCanonicalID() + " of: " + xri.getIdentifier());
        	throw new RuntimeException("Unverified CanonicalID: " + xrd.getCanonicalID() + " of: " + xri.getIdentifier());
        }

        CanonicalID canonical = xrd.getCanonicalID();
        if (canonical == null) throw new RuntimeException("Missing CanonicalID of: " + xri.getIdentifier());
        
        _log.info("XRI resolution succeeded on " + xri.toString());

        return extractDiscoveryInformation(xrds, xri, _openXriResolver);

    }
    catch (Exception e)
    {
        throw new DiscoveryException(
                "Cannot resolve XRI: " + xri, e);
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:36,代码来源:LocalXriResolver.java


示例20: testParseHtml

import org.openid4java.discovery.DiscoveryException; //导入依赖的package包/类
/**
 * Test method for
 * {@link org.openid4java.discovery.html.CyberNekoDOMHtmlParser#parseHtml(java.lang.String, org.openid4java.discovery.html.HtmlResult)}
 * .
 * 
 * @throws IOException
 * @throws DiscoveryException
 */
public void testParseHtml() throws IOException, DiscoveryException
{
    String htmlData = IOUtils.toString(this.getClass().getResourceAsStream(
            "identityPage.html"));
    HtmlResult result = new HtmlResult();
    parser.parseHtml(htmlData, result);
    assertEquals("http://www.example.com:8080/openidserver/users/myusername", result
            .getDelegate1());
    System.out.println(result.getOP1Endpoint());
    assertEquals("http://www.example.com:8080/openidserver/openid.server", result
            .getOP1Endpoint().toExternalForm());
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:21,代码来源:CyberNekoDOMHtmlParserTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ConsumerException类代码示例发布时间:2022-05-21
下一篇:
Java JettyEmbeddedServletContainerFactory类代码示例发布时间: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