本文整理汇总了Java中org.openid4java.consumer.ConsumerException类的典型用法代码示例。如果您正苦于以下问题:Java ConsumerException类的具体用法?Java ConsumerException怎么用?Java ConsumerException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConsumerException类属于org.openid4java.consumer包,在下文中一共展示了ConsumerException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: login
import org.openid4java.consumer.ConsumerException; //导入依赖的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
示例2: getOpenIDFilter
import org.openid4java.consumer.ConsumerException; //导入依赖的package包/类
/**
* @return filter
*/
@Provides
public OpenIDAuthFilter getOpenIDFilter() {
if (openidFilter == null) {
openidFilter = new OpenIDAuthFilter("/" + OpenIDAuthFilter.OPENID_ACTION);
try {
openidFilter.setConsumer(new OpenID4JavaConsumer(new SimpleAxFetchListFactory()));
} catch (ConsumerException ex) {
LoggerFactory.getLogger(SecurityModule.class).error(null, ex);
}
openidFilter.setReturnToUrlParameters(Collections.singleton(Config.getConfigParam("security.returnto", "/")));
openidFilter.setAuthenticationSuccessHandler(getSuccessHandler());
openidFilter.setAuthenticationFailureHandler(getFailureHandler());
openidFilter.setRememberMeServices(getRemembeMeServices());
}
return openidFilter;
}
开发者ID:Erudika,项目名称:para,代码行数:20,代码来源:SecurityModule.java
示例3: init
import org.openid4java.consumer.ConsumerException; //导入依赖的package包/类
public void init(FilterConfig config) throws ServletException {
super.init(config);
try
{
this.manager = new ConsumerManager();
} catch (ConsumerException ex) {
throw new ServletException(ex);
}
manager.setAssociations(new InMemoryConsumerAssociationStore());
manager.setNonceVerifier(new InMemoryNonceVerifier(5000));
manager.setMinAssocSessEnc(AssociationSessionType.DH_SHA256);
manager.setImmediateAuth(true);
}
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:14,代码来源:OpenIdFilter.java
示例4: OpenIdAuthenticator
import org.openid4java.consumer.ConsumerException; //导入依赖的package包/类
/**
* Creates a new instance of OpenIdAuthenticator.
*/
public OpenIdAuthenticator()
{
try
{
m_oManager = new ConsumerManager();
}
catch (ConsumerException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:16,代码来源:OpenIdAuthenticator.java
示例5: prepareAuthenticationUrl
import org.openid4java.consumer.ConsumerException; //导入依赖的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
示例6: requestHandler
import org.openid4java.consumer.ConsumerException; //导入依赖的package包/类
@Path("/Request")
@GET
@POST
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response requestHandler(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam("idRequest") String idReq) throws Exception {
try {
byte[] decodedIdreq = Base64.decodeBase64(idReq);
IdentityRequest idRequest = (IdentityRequest) jsonToObject(decodedIdreq, IdentityRequest.class);
log.debug("openid_identifier_operation : ", idRequest.getIdentifier());
log.debug("instantiating manager");
log.debug("manager instantiated ");
String returnToUrl = idRequest.getReturnToUrl();
log.debug("getting list of discoveries");
List discoveries = manager.discover(idRequest.getIdentifier());
log.debug("retrieving descovered");
DiscoveryInformation discovered = manager.associate(discoveries);
log.debug("saving request");
request.getSession().setAttribute("openid-disc", discovered);
log.debug("instantiating AuthRequest");
AuthRequest authReq = manager.authenticate(discovered, returnToUrl, idRequest.getRealm());
FetchRequest fetch = FetchRequest.createFetchRequest();
if (idRequest.getAxschema().contains("axschema")) {
fetch.addAttribute("nickname", "http://axschema.org/namePerson/friendly", true);
fetch.addAttribute("fullname", "http://axschema.org/namePerson", true);
fetch.addAttribute("email", "http://axschema.org/contact/email", true);
fetch.addAttribute("gender", "http://axschema.org/person/gender", true);
fetch.addAttribute("language", "http://axschema.org/pref/language", true);
fetch.addAttribute("timezone", "http://axschema.org/pref/timezone", true);
fetch.addAttribute("image", "http://axschema.org/media/image/default", true);
} else {
fetch.addAttribute("firstname", "http://schema.openid.net/namePerson/first", true);
fetch.addAttribute("lastname", "http://schema.openid.net/namePerson/last", true);
fetch.addAttribute("email", "http://schema.openid.net/contact/email", true);
fetch.addAttribute("country", "http://axschema.org/contact/country/home", true);
fetch.addAttribute("language", "http://axschema.org/pref/language", true);
}
log.debug("adding fetch data");
authReq.addExtension(fetch);
log.debug("redirecting");
response.sendRedirect(authReq.getDestinationUrl(true));
log.debug("reterning build");
return Response.ok().build();
} catch (ConsumerException e) {
log.debug("Error occured : ", e.getMessage(), " ", e.getCause());
OxChooserError error = new OxChooserError();
error.setDescription("An Error occured , request didnt go through.");
return Response.status(400).entity(error).build();
} finally {
identity.logout();
}
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:64,代码来源:OxChooserWebService.java
示例7: showOpenIDForm
import org.openid4java.consumer.ConsumerException; //导入依赖的package包/类
public Resolution showOpenIDForm()
throws ConsumerException, MessageException, DiscoveryException, MalformedURLException {
ConsumerManager manager = new ConsumerManager();
// perform discovery on the user-supplied identifier
List discoveries = manager.discover(openIdUrl);
// attempt to associate with the OpenID provider
// and retrieve one service endpoint for authentication
DiscoveryInformation discovered = manager.associate(discoveries);
UrlBuilder urlBuilder = new UrlBuilder(context.getLocale(), context.getActionPath(), false);
urlBuilder.setEvent("handleOpenIDLogin");
urlBuilder.addParameter("returnUrl", returnUrl);
urlBuilder.addParameter("cancelReturnUrl", cancelReturnUrl);
URL url = new URL(context.getRequest().getRequestURL().toString());
String port = url.getPort() > 0 ? ":" + url.getPort() : "";
String baseUrl = url.getProtocol() + "://" + url.getHost() + port;
String urlString = baseUrl + context.getRequest().getContextPath() + urlBuilder;
// obtain a AuthRequest message to be sent to the OpenID provider
AuthRequest authReq = manager.authenticate(discovered, urlString, baseUrl);
// store the discovery information in the user's session for later use
// leave out for stateless operation / if there is no session
HttpSession session = context.getRequest().getSession();
session.setAttribute(OPENID_DISCOVERED, discovered);
session.setAttribute(OPENID_CONSUMER_MANAGER, manager);
String destinationUrl = authReq.getDestinationUrl(true);
if(destinationUrl.length() > 2000) {
if(authReq.isVersion2()) {
openIdDestinationUrl = authReq.getDestinationUrl(false);
openIdParameterMap = authReq.getParameterMap();
return new ForwardResolution("/m/openid/pageactions/openid/openIDFormRedirect.jsp");
} else {
SessionMessages.addErrorMessage("Cannot login, payload too big and OpenID version 2 not supported.");
return new ForwardResolution(getLoginPage());
}
} else {
return new RedirectResolution(destinationUrl, false);
}
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:45,代码来源:OpenIdLoginAction.java
示例8: OpenIdConsumer
import org.openid4java.consumer.ConsumerException; //导入依赖的package包/类
public OpenIdConsumer(String returnToUrl) throws ConsumerException {
this.manager = new ConsumerManager();
this.returnToUrl = returnToUrl;
}
开发者ID:faramir,项目名称:ZawodyWeb,代码行数:5,代码来源:OpenIdConsumer.java
示例9: OpenIdImpl
import org.openid4java.consumer.ConsumerException; //导入依赖的package包/类
public OpenIdImpl(final Properties props) throws ConsumerException,
Exception {
manager = new ConsumerManager();
discovered = null;
this.id = props.getProperty("id");
}
开发者ID:3pillarlabs,项目名称:socialauth,代码行数:7,代码来源:OpenIdImpl.java
注:本文中的org.openid4java.consumer.ConsumerException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论