Examples of AuthRequest


Examples of org.openid4java.message.AuthRequest

        AuthRequestHelper helper = consumerHelper.getAuthRequestHelper(openId, returnToUrl);
        addAttributes(helper);

        HttpSession session = request.getSession();
        AuthRequest authReq = helper.generateRequest();
        authReq.setRealm(realm);

        UiMessageRequest uiExtension = new UiMessageRequest();
        uiExtension.setIconRequest(true);
        authReq.addExtension(uiExtension);

        session.setAttribute("discovered", helper.getDiscoveryInformation());
        return authReq;
    }
View Full Code Here

Examples of org.openid4java.message.AuthRequest

    if (state == null) {
      cb.onSuccess(new DiscoveryResult(DiscoveryResult.Status.NO_PROVIDER));
      return;
    }

    final AuthRequest aReq;
    try {
      aReq = manager.authenticate(state.discovered, state.retTo.toString());
      aReq.setRealm(state.contextUrl);

      if (requestRegistration(aReq)) {
        final SRegRequest sregReq = SRegRequest.createFetchRequest();
        sregReq.addAttribute("fullname", true);
        sregReq.addAttribute("email", true);
        aReq.addExtension(sregReq);

        final FetchRequest fetch = FetchRequest.createFetchRequest();
        fetch.addAttribute("FirstName", SCHEMA_FIRSTNAME, true);
        fetch.addAttribute("LastName", SCHEMA_LASTNAME, true);
        fetch.addAttribute("Email", SCHEMA_EMAIL, true);
        aReq.addExtension(fetch);
      }

      if (0 <= papeMaxAuthAge) {
        final PapeRequest pape = PapeRequest.createPapeRequest();
        pape.setMaxAuthAge(papeMaxAuthAge);
        aReq.addExtension(pape);
      }
    } catch (MessageException e) {
      log.error("Cannot create OpenID redirect for " + openidIdentifier, e);
      cb.onSuccess(new DiscoveryResult(DiscoveryResult.Status.ERROR));
      return;
    } catch (ConsumerException e) {
      log.error("Cannot create OpenID redirect for " + openidIdentifier, e);
      cb.onSuccess(new DiscoveryResult(DiscoveryResult.Status.ERROR));
      return;
    }

    cb.onSuccess(new DiscoveryResult(aReq.getDestinationUrl(false), //
        aReq.getParameterMap()));
  }
View Full Code Here

Examples of org.openid4java.message.AuthRequest

            String userSelectedClaimedId = (String) userData.get(0);
            Boolean authenticatedAndApproved = (Boolean) userData.get(1);
            String email = (String) userData.get(2);

            // --- process an authentication request ---
            AuthRequest authReq =
                AuthRequest.createAuthRequest(request, manager.getRealmVerifier());

            String opLocalId = null;
            // if the user chose a different claimed_id than the one in request
            if (userSelectedClaimedId != null &&
                userSelectedClaimedId.equals(authReq.getClaimed()))
            {
                //opLocalId = lookupLocalId(userSelectedClaimedId);
            }

            response = manager.authResponse(request,
                    opLocalId,
                    userSelectedClaimedId,
                    authenticatedAndApproved.booleanValue(),
                    false); // Sign after we added extensions.

            if (response instanceof DirectError)
                return directResponse(httpResp, response.keyValueFormEncoding());
            else
            {
                if (authReq.hasExtension(AxMessage.OPENID_NS_AX))
                {
                    MessageExtension ext = authReq.getExtension(AxMessage.OPENID_NS_AX);
                    if (ext instanceof FetchRequest)
                    {
                        FetchRequest fetchReq = (FetchRequest) ext;
                        Map required = fetchReq.getAttributes(true);
                        //Map optional = fetchReq.getAttributes(false);
                        if (required.containsKey("email"))
                        {
                            Map userDataExt = new HashMap();
                            //userDataExt.put("email", userData.get(3));

                            FetchResponse fetchResp =
                                FetchResponse.createFetchResponse(fetchReq, userDataExt);
                            // (alternatively) manually add attribute values
                            fetchResp.addAttribute("email",
                                "http://schema.openid.net/contact/email", email);
                            response.addExtension(fetchResp);
                        }
                    }
                    else //if (ext instanceof StoreRequest)
                    {
                        throw new UnsupportedOperationException("TODO");
                    }
                }
                if (authReq.hasExtension(SRegMessage.OPENID_NS_SREG))
                {
                    MessageExtension ext = authReq.getExtension(SRegMessage.OPENID_NS_SREG);
                    if (ext instanceof SRegRequest)
                    {
                        SRegRequest sregReq = (SRegRequest) ext;
                        List required = sregReq.getAttributes(true);
                        //List optional = sregReq.getAttributes(false);
View Full Code Here

Examples of org.openid4java.message.AuthRequest

           
            //// store the discovery information in the user's session
            // httpReq.getSession().setAttribute("openid-disc", discovered);

            // obtain a AuthRequest message to be sent to the OpenID provider
            AuthRequest authReq = manager.authenticate(discovered, returnToUrl);

            // Attribute Exchange example: fetching the 'email' attribute
            FetchRequest fetch = FetchRequest.createFetchRequest();
            fetch.addAttribute("email",
                               "http://schema.openid.net/contact/email",   // type URI
                               true);                                      // required
           
            // attach the extension to the authentication request
            authReq.addExtension(fetch);

            return authReq.getDestinationUrl(true);
        } catch (OpenIDException e)  {
      log.warn(e);
        }
       
        return null;
View Full Code Here

Examples of org.openid4java.message.AuthRequest

            // save discovery information in session
            context.setSessionAttribute(getDiscoveryInformationSessionAttributeName(), discoveryInformation);

            final String contextualCallbackUrl = getContextualCallbackUrl(context);
            // create authentication request to be sent to the OpenID provider
            final AuthRequest authRequest = this.consumerManager.authenticate(discoveryInformation,
                    contextualCallbackUrl);

            // 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) {
            logger.error("OpenID exception", e);
            throw new TechnicalException("OpenID exception", e);
View Full Code Here

Examples of org.openid4java.message.AuthRequest

      if (request.getParameter(StaticConfig.DEBUG_ARGUMENT_KEY) != null) {
        returnUrl += "?" + StaticConfig.DEBUG_ARGUMENT_KEY + "="
            + request.getParameter(StaticConfig.DEBUG_ARGUMENT_KEY);
      }
      System.out.println("authenticate cookies");
      AuthRequest authReq = manager.authenticate(discovered, returnUrl, null);
      System.out.println("fetch request");
      FetchRequest fetch = FetchRequest.createFetchRequest();
      System.out.println("fetching attributes");
      fetch.addAttribute("oiFirstName", "http://schema.openid.net/namePerson/first", true);
      fetch.addAttribute("oiLastName", "http://schema.openid.net/namePerson/last", true);
      fetch.addAttribute("aFirstName", "http://axschema.org/namePerson/first", true);
      fetch.addAttribute("aLastName", "http://axschema.org/namePerson/last", true);
      fetch.addAttribute("aFullName", "http://axschema.org/namePerson", true);
      fetch.addAttribute("aNickName", "http://axschema.org/namePerson/friendly", true);
      fetch.addAttribute("oiNickName", "http://openid.net/schema/namePerson/friendly", true);
      fetch.addAttribute("aEmail", "http://axschema.org/contact/email", true);
      fetch.addAttribute("oiEmail", "http://schema.openid.net/contact/email", true);
     
      System.out.println("adding extension");
      authReq.addExtension(fetch);
      // redirect to OpenID for authentication
      System.out.println("sending redirect");
      response.sendRedirect(authReq.getDestinationUrl(true));
    } catch (OpenIDException e) {
      System.out.println("oid exception!");
      e.printStackTrace();
      throw new ServletException("Login string probably caused an error. loginString = " + loginString, e);
    }
View Full Code Here

Examples of simpleserver.Authenticator.AuthRequest

        if (name.contains(";")) {
          name = name.substring(0, name.indexOf(";"));
        }
        if (name.equals("Player") || !server.authenticator.isMinecraftUp) {
          AuthRequest req = server.authenticator.getAuthRequest(player.getIPAddress());
          if (req != null) {
            name = req.playerName;
            nameSet = server.authenticator.completeLogin(req, player);
          }
          if (req == null || !nameSet) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.