Package org.openid4java.message

Examples of org.openid4java.message.AuthRequest


                " OP-specific ID: " + delegate);

        if (! discovered.isVersion2())
            returnToUrl = insertConsumerNonce(discovered.getOPEndpoint().toString(), returnToUrl);

        AuthRequest authReq = AuthRequest.createAuthRequest(claimedId, delegate,
                ! discovered.isVersion2(), returnToUrl, handle, realm, _realmVerifier);

        authReq.setOPEndpoint(discovered.getOPEndpoint());

        // ignore the immediate flag for OP-directed identifier selection
        if (! AuthRequest.SELECT_ID.equals(claimedId))
            authReq.setImmediate(_immediateAuth);

        return authReq;
    }
View Full Code Here


      // 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);

      // Simple registration example
      addSimpleRegistrationToAuthRequest(httpReq, authReq);

      // Attribute exchange example
      addAttributeExchangeToAuthRequest(httpReq, authReq);

      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()
View Full Code Here

            // 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 = null;

            String returnToUrl = httpReq.getRequestURL().toString();
            authReq = manager.authenticate(discovered, returnToUrl);
           
            String destinationUrl = authReq.getDestinationUrl(true);
            HttpClient client = new HttpClient();
            GetMethod request = new GetMethod(destinationUrl);
            client.executeMethod(request);
            String body = request.getResponseBodyAsString();
            String[] paramValues = body.split("\n");
View Full Code Here

                directResponse(resp, responseText);
                return;
            }
         
            // --- process an authentication request ---
            AuthRequest authReq = null;
            try {
                authReq = AuthRequest.createAuthRequest(request, manager.getRealmVerifier());
            } catch (Exception ex) {
              throw new ServletException(ex);
            }

            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,
View Full Code Here

      tempUser.setOpenIDDiscoveryInformationMemento(memento);
      tempUser.setSessionToken(sessionToken);
      userDao.saveOrUpdate(tempUser);

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

      // Build the FetchRequest containing the information to be copied
      // from the OpenID provider
      FetchRequest fetch = FetchRequest.createFetchRequest();
      // Attempt to decode each entry
      if (identifier.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 (identifier.startsWith(YAHOO_ENDPOINT)) {
        fetch.addAttribute("email", "http://axschema.org/contact/email", true);
        fetch.addAttribute("fullname", "http://axschema.org/namePerson", true);
      } else { // works for myOpenID
        fetch.addAttribute("fullname", "http://schema.openid.net/namePerson", true);
        fetch.addAttribute("email", "http://schema.openid.net/contact/email", true);
      }

      // Attach the extension to the authentication request
      authReq.addExtension(fetch);

      // Redirect the user to their OpenId server authentication process
      return Response
        .seeOther(URI.create(authReq.getDestinationUrl(true)))
        .build();

    } catch (MessageException e1) {
      log.error("MessageException:", e1);
    } catch (DiscoveryException e1) {
View Full Code Here

        return discovered;
    }

    public String getURLToAuthenticate(DiscoveryInformation discoveryInformation, String callbackURL) throws OpenIDException {
        AuthRequest authReq = consumerManager.authenticate(discoveryInformation, callbackURL);
        return authReq.getDestinationUrl(true);
    }
View Full Code Here

            openIdProviderRequest.get().setParameterList(parameterList);
            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

            openIdRequest.setDiscoveryInformation(discovered);

            String realm = relyingPartyBean.get().getRealm();
            String returnTo = relyingPartyBean.get().getServiceURL(
                    OpenIdService.OPEN_ID_SERVICE) + "?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) {
            log.warn("Authentication failed", e);
            openIdRelyingPartySpi.get().loginFailed(e.getMessage(),
View Full Code Here

           
            //// 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)  {
            e.printStackTrace();
        }
       
        return null;
View Full Code Here

    @SuppressWarnings("deprecation")
    @Test
    public void beginConsumptionCreatesExpectedSessionData() throws Exception {
        ConsumerManager mgr = mock(ConsumerManager.class);
        AuthRequest authReq = mock(AuthRequest.class);
        DiscoveryInformation di = mock(DiscoveryInformation.class);

        when(mgr.authenticate(any(DiscoveryInformation.class), anyString(), anyString())).thenReturn(authReq);
        when(mgr.associate(anyList())).thenReturn(di);
View Full Code Here

TOP

Related Classes of org.openid4java.message.AuthRequest

Copyright © 2018 www.massapicom. 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.