Examples of AuthRequest


Examples of org.openid4java.message.AuthRequest

  /**
   * {@inheritDoc}
   */
  public void addRequiredAttributes(List<String> requiredAttributes) throws IdentityException {
    MessageExtension extensions = null;
    AuthRequest authRequest = null;

    try {
      authRequest = request.getAuthRequest();

      if (authRequest != null) {
        if (authRequest.hasExtension(FetchRequest.OPENID_NS_AX)) {
          extensions = authRequest.getExtension(FetchRequest.OPENID_NS_AX);
        } else if (authRequest.hasExtension(ExchangeAttributes.NS_AX)) {
          extensions = authRequest.getExtension(ExchangeAttributes.NS_AX);
        }

        if (extensions instanceof FetchRequest) {
          Map required = null;
          Map optional = null;
View Full Code Here

Examples of org.openid4java.message.AuthRequest

   * {@inheritDoc}
   */
  public MessageExtension getMessageExtension(String userId, String profileName)
      throws IdentityException {
    MessageExtension extensions = null;
    AuthRequest authRequest = null;
    FetchResponse fetchResponse = null;

    try {
      authRequest = request.getAuthRequest();
      if (authRequest.hasExtension(FetchRequest.OPENID_NS_AX)) {
        extensions = authRequest.getExtension(FetchRequest.OPENID_NS_AX);
      } else if (authRequest.hasExtension(IdentityConstants.OpenId.ExchangeAttributes.NS_AX)) {
        extensions = authRequest
            .getExtension(IdentityConstants.OpenId.ExchangeAttributes.NS_AX);
      }

      if (extensions instanceof FetchRequest) {
        Map required = null;
View Full Code Here

Examples of org.openid4java.message.AuthRequest

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

    MessageExtension message = null;
    PapeResponse papeResponse = null;
    AuthRequest authRequest = null;

    try {
      authRequest = request.getAuthRequest();

      if (authRequest != null) {
        message = authRequest.getExtension(PapeMessage.OPENID_NS_PAPE);

        if (message instanceof PapeRequest) {
          papeResponse = PapeResponse.createPapeResponse();
          if (request.isPhishingResistanceLogin()) {
            papeResponse.addAuthPolicy(PapeMessage.PAPE_POLICY_PHISHING_RESISTANT);
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) {
      handleDiscoveryFailed(resp);
      return;
    } 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 {
      handleDiscoverySucceeded_RedirectThroughGet(resp, authReq.getDestinationUrl(true));
    }
  }
View Full Code Here

Examples of org.openid4java.message.AuthRequest

      log.debug("Requesting AX country");
      helper.requestAxAttribute(Step2.AxSchema.LAST_NAME, true);
    }

    HttpSession session = req.getSession();
    AuthRequest authReq = null;
    try {
      authReq = helper.generateRequest();
      authReq.setRealm(realm);

      // add PAPE, if requested
      if (YES_STRING.equals(req.getParameter("reauth"))) {
        log.debug("Requesting PAPE reauth");
        PapeRequest pape = PapeRequest.createPapeRequest();
        pape.setMaxAuthAge(1);
        authReq.addExtension(pape);
      }

      session.setAttribute("discovered", helper.getDiscoveryInformation());
    } catch (DiscoveryException e) {
      StringBuffer errorMessage =
        new StringBuffer("Could not discover OpenID endpoint.");
      errorMessage.append("\n\n").append("Check if URL is valid: ");
      errorMessage.append(openId).append("\n\n");
      errorMessage.append("Stack Trace:\n");
      for (StackTraceElement s : e.getStackTrace()) {
        errorMessage.append(s.toString()).append('\n');
      }
      resp.sendError(400, errorMessage.toString());
      return;
    } 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

            getResponse().getCookieSettings().add(
                    new CookieSetting(DESCRIPTOR_COOKIE, sessionId));
            log.info("Setting DESCRIPTOR COOKIE");

            // obtain a AuthRequest message to be sent to the OpenID provider
            AuthRequest authReq = manager.authenticate(discovered,
                    returnToUrl.toString()); // TODO maybe add TIMESTAMP?
            // Domain wide realm add meta to main page
            // http://localhost:8080/oauth/xrds?returnTo=http://localhost:8080/oauth/openid_login\r\n
            // log.info("OpenID - REALM = " +
            // getReference().getHostIdentifier());
            // authReq.setRealm(getReference().getHostIdentifier().toString());
            log.info("OpenID - REALM = " + getReference().getBaseRef());
            authReq.setRealm(getReference().getBaseRef().toString());

            // Attribute Exchange - getting optional and required
            FetchRequest fetch = null;
            String[] optional = params.getValuesArray("ax_optional", true);
            for (String o : optional) {
                if (!ax.containsKey(o)) {
                    log.warning("Not supported AX extension : " + o);
                    continue;
                }
                if (fetch == null)
                    fetch = FetchRequest.createFetchRequest();
                fetch.addAttribute(o, ax.get(o), false);
            }

            String[] required = params.getValuesArray("ax_required", true);
            for (String r : required) {
                if (!ax.containsKey(r)) {
                    log.warning("Not supported AX extension : " + r);
                    continue;
                }
                if (fetch == null)
                    fetch = FetchRequest.createFetchRequest();
                fetch.addAttribute(r, ax.get(r), true);
            }

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

            if (!discovered.isVersion2()) {
                log.info("REDIRECTING TEMPORARY");
                // Option 1: GET HTTP-redirect to the OpenID Provider endpoint
                // The only method supported in OpenID 1.x
                // redirect-URL usually limited ~2048 bytes
                redirectTemporary(authReq.getDestinationUrl(true));
                return null;
            } else {
                // Option 2: HTML FORM Redirection (Allows payloads >2048 bytes)

                Form msg = new Form();
                for (Object key : authReq.getParameterMap().keySet()) {
                    msg.add(key.toString(),
                            authReq.getParameterValue(key.toString()));
                    log.info("Adding to form - key " + key.toString()
                            + " : value"
                            + authReq.getParameterValue(key.toString()));
                }

                // Redirector dispatcher = new Redirector(getContext(),
                // authReq.getOPEndpoint(),
                // Redirector.MODE_SERVER_OUTBOUND);
View Full Code Here

Examples of org.openid4java.message.AuthRequest

        response.getCookieSettings().add(
                new CookieSetting(OpenIdConsumer.DESCRIPTOR_COOKIE, sessionId));
        l.info("Setting DESCRIPTOR COOKIE");

        // obtain a AuthRequest message to be sent to the OpenID provider
        AuthRequest authReq = manager.authenticate(discovered, redir); // TODO
                                                                       // maybe
                                                                       // add
                                                                       // TIMESTAMP?;
        String ref = request.getResourceRef().getBaseRef().toString();
        l.info("OpenID - REALM = " + ref);
        authReq.setRealm(ref);

        // Attribute Exchange - getting optional and required
        FetchRequest fetch = null;
        // String[] optional = params.getValuesArray("ax_optional", true);
        for (AX o : this.optionalAttributes) {
            if (fetch == null)
                fetch = FetchRequest.createFetchRequest();
            fetch.addAttribute(o.toString(), ax.get(o), false);
        }

        // String[] required = params.getValuesArray("ax_required", true);
        for (AX r : this.requiredAttributes) {
            if (fetch == null)
                fetch = FetchRequest.createFetchRequest();
            fetch.addAttribute(r.toString(), ax.get(r), true);
        }

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

        if (!discovered.isVersion2()) {
            l.info("OpenId - Http Redirect");
            response.redirectTemporary(authReq.getDestinationUrl(true));

        } else {
            l.info("OpenId - HTML Form Redirect");
            Form msg = new Form();
            for (Object key : authReq.getParameterMap().keySet()) {
                msg.add(key.toString(),
                        authReq.getParameterValue(key.toString()));
                l.info("Adding to form - key " + key.toString() + " : value"
                        + authReq.getParameterValue(key.toString()));
            }
            response.setEntity(generateForm(authReq));
            // response.redirectTemporary(authReq.getDestinationUrl(true));
        }
View Full Code Here

Examples of org.openid4java.message.AuthRequest

      session.removeAttribute("parameterlist");
      session.setAttribute("authenticatedAndApproved", null);
    }

    // --- process an authentication request ---
    AuthRequest authReq = null;
    String opLocalId = null;

    try {
      authReq = AuthRequest.createAuthRequest(parameterList, manager.getRealmVerifier());
      // if the user chose a different claimed_id than the one in request
      if (userSelectedClaimedId != null && userSelectedClaimedId.equals(authReq.getClaimed())) {
        //opLocalId = "http://localhost:8081/idp4java/idp";//lookupLocalId(userSelectedClaimedId);
      }
    } catch (MessageException e) {
      e.printStackTrace();
      throw new ServletException(e);
    }

    // --- process an authentication request ---
    //messageResponse = manager.authResponse(parameterList, userSelectedId, userSelectedClaimedId, true);
    messageResponse = manager.authResponse(parameterList, opLocalId, opLocalId, true);
   

    if (messageResponse instanceof DirectError)
      return directResponse(response, messageResponse.keyValueFormEncoding());
    else {

            try {
        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", "someone@someplace.com");
                    FetchResponse fetchResp = FetchResponse.createFetchResponse(fetchReq, userDataExt);
                    // (alternatively) manually add attribute values
                    //fetchResp.addAttribute("email", "http://schema.openid.net/contact/email", email);
                    messageResponse.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", // attribute alias
                "http://schema.openid.net/contact/email", // type URI
                true); // required
            // attach the extension to the authentication request
            authReq.addExtension(fetch);

            // example using Simple Registration to fetching the 'email' attribute
            SRegRequest sregReq = SRegRequest.createFetchRequest();
            sregReq.addAttribute("email", true);
            authReq.addExtension(sregReq);

            if (! discovered.isVersion2() )
            {
                // Option 1: GET HTTP-redirect to the OpenID Provider endpoint
                // The only method supported in OpenID 1.x
                // redirect-URL usually limited ~2048 bytes
                httpResp.sendRedirect(authReq.getDestinationUrl(true));
                return null;
            }
            else
            {
                // Option 2: HTML FORM Redirection (Allows payloads >2048 bytes)

                //RequestDispatcher dispatcher =
                //        getServletContext().getRequestDispatcher("formredirection.jsp");
                //httpReq.setAttribute("prameterMap", response.getParameterMap());
                //httpReq.setAttribute("destinationUrl", response.getDestinationUrl(false));
                //dispatcher.forward(request, response);
                httpResp.sendRedirect(authReq.getDestinationUrl(true));
                return null;
            }
        }
        catch (OpenIDException e)
        {
View Full Code Here

Examples of org.openid4java.message.AuthRequest

            throws ServletException, IOException {
        String domain = req.getParameter("hd");
        if (domain != null) {
            // User attempting to login with provided domain, build and OpenID request and redirect
            try {
                AuthRequest authRequest = startAuthentication(domain, req);
                String url = authRequest.getDestinationUrl(true);
                resp.sendRedirect(url);
            } catch (OpenIDException e) {
                throw new ServletException("Error initializing OpenID request", e);
            }
        } else {
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.