本文整理汇总了Java中org.openid4java.discovery.DiscoveryException类的典型用法代码示例。如果您正苦于以下问题:Java DiscoveryException类的具体用法?Java DiscoveryException怎么用?Java DiscoveryException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DiscoveryException类属于org.openid4java.discovery包,在下文中一共展示了DiscoveryException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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();
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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");
}
}
示例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());
}
}
示例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());
}
}
示例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;
}
}
示例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);
}