Examples of AuthRequest


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 = 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

Examples of org.openid4java.message.AuthRequest

                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

Examples of org.openid4java.message.AuthRequest

      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

Examples of org.openid4java.message.AuthRequest

        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

Examples of org.openid4java.message.AuthRequest

            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

Examples of org.openid4java.message.AuthRequest

            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

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

Examples of org.openid4java.message.AuthRequest

    @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

Examples of org.openid4java.message.AuthRequest

        }

        DiscoveryInformation information = consumerManager.associate(discoveries);
        req.getSession().setAttribute(DISCOVERY_INFO_KEY, information);

        AuthRequest authReq;

        try {
            authReq = consumerManager.authenticate(information, returnToUrl, realm);

            logger.debug("Looking up attribute fetch list for identifier: " + identityUrl);

            List<OpenIDAttribute> attributesToFetch = attributesToFetchFactory.createAttributeList(identityUrl);

            if (!attributesToFetch.isEmpty()) {
                req.getSession().setAttribute(ATTRIBUTE_LIST_KEY, attributesToFetch);
                FetchRequest fetchRequest = FetchRequest.createFetchRequest();
                for (OpenIDAttribute attr : attributesToFetch) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Adding attribute " + attr.getType() + " to fetch request");
                    }
                    fetchRequest.addAttribute(attr.getName(), attr.getType(), attr.isRequired(), attr.getCount());
                }
                authReq.addExtension(fetchRequest);
            }
        } catch (MessageException e) {
            throw new OpenIDConsumerException("Error processing ConsumerManager authentication", e);
        } catch (ConsumerException e) {
            throw new OpenIDConsumerException("Error processing ConsumerManager authentication", e);
        }

        return authReq.getDestinationUrl(true);
    }
View Full Code Here

Examples of org.openid4java.message.AuthRequest

    public ConstructedRequest constructRequest(String providerId, String responseUrl) throws OpenIdException {
        String discoveryId = getDiscoveryId(providerId);

        DiscoveryInformation discoveryInfo = getDiscoveryInfo(discoveryId, providerId);

        AuthRequest request = createRequest(discoveryInfo, responseUrl);

        addExtensions(request, discoveryInfo, providerId, discoveryId);

        return createConstructedRequest(request, discoveryInfo, providerId, discoveryId);
    }
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.