Examples of AuthRequest


Examples of org.openid4java.message.AuthRequest

         openIdRequest.setDiscoveryInformation(discovered);

         String openIdServiceUrl = relyingPartyBean.getServiceURL(OpenIdService.OPEN_ID_SERVICE);
         String realm = relyingPartyBean.getRealm();
         String returnTo = openIdServiceUrl + "?dialogueId=" + dialogue.get().getId();
         AuthRequest authReq = openIdConsumerManager.authenticate(discovered, returnTo, realm);

         if (attributes != null && attributes.size() > 0)
         {
            FetchRequest fetch = FetchRequest.createFetchRequest();
            for (OpenIdRequestedAttribute attribute : attributes)
            {
               fetch.addAttribute(attribute.getAlias(), attribute.getTypeUri(), attribute.isRequired());
            }
            // attach the extension to the authentication request
            authReq.addExtension(fetch);
         }

         String url = authReq.getDestinationUrl(true);

         responseHandler.sendHttpRedirectToUserAgent(url, response);
      }
      catch (OpenIDException e)
      {
View Full Code Here

Examples of org.openid4java.message.AuthRequest

         openIdProviderRequest.get().setClaimedIdentifier(claimedIdentifier);

         MessageExtension ext = null;
         try
         {
            AuthRequest authReq = AuthRequest.createAuthRequest(parameterList, openIdServerManager.get().getRealmVerifier());
            if (authReq.hasExtension(AxMessage.OPENID_NS_AX))
            {
               ext = authReq.getExtension(AxMessage.OPENID_NS_AX);
            }
         }
         catch (MessageException e)
         {
            throw new RuntimeException(e);
View Full Code Here

Examples of org.openid4java.message.AuthRequest

                // fullReturnTo += "?" + SignIn.keyNextURL + "=" +
                //     URLEncoder.encode(nextURL, "utf-8");
            } catch(Exception ex) {
                System.err.println("parameter next cannot be url encoded.");
            }
            AuthRequest authReq = manager.authenticate(discovered, fullReturnTo);

            session.setAttribute(OPENID_CLAIMED_ID_SESSION, openid);

            /* add those extensions you want to test */
            if( bypassSRE == false )
                authReq.addExtension(sreg);
            if( bypassAX == false )
                authReq.addExtension(fetch);

            logger.info("Redirects to URL:" + authReq.getDestinationUrl(true));
            response.sendRedirect(authReq.getDestinationUrl(true));
        } catch (Exception e) {
            logger.severe(e.toString());
            succ = false;
        }

View Full Code Here

Examples of org.openid4java.message.AuthRequest

        }
        return ret;
    }
   
    public static AuthRequest createOpenIdAuthRequest(final DiscoveryInformation discoveryInformation, final String returnToUrl, final String endpoint) {
        AuthRequest ret = null;
        //
        try {
            // Create the AuthRequest object
            ret = getConsumerManager().authenticate(discoveryInformation, returnToUrl);
           
            final FetchRequest fetch = FetchRequest.createFetchRequest();
            if (endpoint.startsWith(GOOGLE_ENDPOINT)) {
                fetch.addAttribute("email", "http://axschema.org/contact/email", true);
                fetch.addAttribute("FirstName", "http://axschema.org/namePerson/first", true);
                fetch.addAttribute("LastName", "http://axschema.org/namePerson/last", true);
            } else if (endpoint.startsWith(YAHOO_ENDPOINT)) {
                fetch.addAttribute("email", "http://axschema.org/contact/email", true);
                fetch.addAttribute("Fullname", "http://axschema.org/namePerson", true);
            }
            ret.addExtension(fetch);
        } catch (Exception e) {
            final String message = "Exception occurred while building "
                    + "AuthRequest object!";
            throw new RuntimeException(message, e);
        }
View Full Code Here

Examples of org.openid4java.message.AuthRequest

    protected void doPost(final HttpServletRequest request, final HttpServletResponse response)
            throws ServletException, IOException {
        final String url = request.getParameter("openid");
        final DiscoveryInformation discoveryInformation = performDiscoveryOnUserSuppliedIdentifier(url);
        final InetAddress myLocalHost = InetAddress.getLocalHost();
        final AuthRequest authRequest = createOpenIdAuthRequest(discoveryInformation, "http://" + myLocalHost.getHostAddress() + ":8080/Software_Engineering_C/openid", url);
        response.sendRedirect(authRequest.getDestinationUrl(true));
    }
View Full Code Here

Examples of org.openid4java.message.AuthRequest

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

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

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

            session.setAttribute(IdentityConstants.OpenId.DISC, helper.getDiscoveryInformation());

            if (request.getRealm() != null && request.getRealm().trim().length() != 0) {
                authReq.setRealm(request.getRealm());
            }

            for (String type : request.getRequestTypes()) {
                authReq.addExtension(OpenIDExtensionFactory.getInstance().getExtension(type)
                        .getMessageExtension(request));
            }

            // Redirect to the OpenID provider server for authentication.
            String value = authReq.getDestinationUrl(true);
            return value;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            // Present error to the user
            throw new IdentityException(e.getMessage(), e);
View Full Code Here

Examples of org.openid4java.message.AuthRequest

  public AuthRequest generateRequest() throws DiscoveryException,
      MessageException, ConsumerException {
    DiscoveryInformation discovered = getDiscoveryInformation();

    // this a standard OpenID request
    AuthRequest authReq =
      consumerManager.authenticate(discovered, returnToUrl, null);
    if (axFetchRequest != null) {
      authReq.addExtension(axFetchRequest);
    }

    if (hybridOauthRequest != null) {
      authReq.addExtension(hybridOauthRequest);
    }

    if (uiRequest != null) {
      authReq.addExtension(uiRequest);
    }

    log.info(authReq);
    return authReq;
  }
View Full Code Here

Examples of org.openid4java.message.AuthRequest

    if (YES_STRING.equals(req.getParameter("lastName"))) {
      helper.requestAxAttribute(Step2.AxSchema.LAST_NAME, true);
    }

    HttpSession session = req.getSession();
    AuthRequest authReq = null;
    try {
      authReq = helper.generateRequest();
      authReq.setRealm(realm);
      session.setAttribute("discovered", helper.getDiscoveryInformation());
    } catch (DiscoveryException e) {
      throw new ServletException(e);
    } catch (MessageException e) {
      throw new ServletException(e);
    } catch (ConsumerException e) {
      throw new ServletException(e);
    }
    if (YES_STRING.equals(req.getParameter("usePost"))) {
      // using POST
      req.setAttribute("message", authReq);
      RequestDispatcher d =
        req.getRequestDispatcher("/WEB-INF/formredirection.jsp");
      d.forward(req, resp);
    } else {
      // using GET
      resp.sendRedirect(authReq.getDestinationUrl(true));
    }
  }
View Full Code Here

Examples of org.openid4java.message.AuthRequest

    /**
     * {@inheritDoc}
     */
    public void addRequiredAttributes(List<String> requiredAttributes) throws IdentityException {
        AuthRequest authRequest = null;
        MessageExtension extension = null;
        try {
            authRequest = request.getAuthRequest();
            if (authRequest != null) {  
                if (authRequest.hasExtension(SRegMessage.OPENID_NS_SREG)) {
                    extension = authRequest.getExtension(SRegMessage.OPENID_NS_SREG);
                } else if (authRequest.hasExtension(SRegMessage.OPENID_NS_SREG11)) {
                    extension = authRequest.getExtension(SRegMessage.OPENID_NS_SREG11);
                } else if (authRequest.hasExtension(AxMessage.OPENID_NS_AX)) {
                    extension = authRequest.getExtension(AxMessage.OPENID_NS_AX);
                }

                if (extension instanceof SRegRequest) {
                    SRegRequest sregReq = null;
                    List required = null;
View Full Code Here

Examples of org.openid4java.message.AuthRequest

     */
    public MessageExtension getMessageExtension(String userId, String profileName)
            throws IdentityException {

        MessageExtension extension = null;
        AuthRequest authRequest = null;
        SRegResponse response = null;

        try {
            authRequest = request.getAuthRequest();

            if (authRequest.hasExtension(SRegRequest.OPENID_NS_SREG)) {
                extension = authRequest.getExtension(SRegRequest.OPENID_NS_SREG);
            } else if (authRequest.hasExtension(SRegMessage.OPENID_NS_SREG11)) {
                extension = authRequest.getExtension(SRegMessage.OPENID_NS_SREG11);
            } else if (authRequest.hasExtension(AxMessage.OPENID_NS_AX)) {
                extension = authRequest.getExtension(AxMessage.OPENID_NS_AX);
            }

            if (log.isDebugEnabled()) {
                if (extension == null)
                    log.info("SReg extension is null");
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.