Package org.openid4java.message.ax

Examples of org.openid4java.message.ax.FetchRequest


  private void addAttributeExchangeToAuthRequest(HttpServletRequest httpReq,
      AuthRequest authReq) throws MessageException {
    String[] aliases = httpReq.getParameterValues("alias");
    String[] typeUris = httpReq.getParameterValues("typeUri");
    String[] counts = httpReq.getParameterValues("count");
    FetchRequest fetch = FetchRequest.createFetchRequest();
    for (int i = 0, l = typeUris == null ? 0 : typeUris.length; i < l; i++) {
      String typeUri = typeUris[i];
      if (StringUtils.isNotBlank(typeUri)) {
        String alias = aliases[i];
        boolean required = httpReq.getParameter("required" + i) != null;
        int count = NumberUtils.toInt(counts[i], 1);
        fetch.addAttribute(alias, typeUri, required, count);
      }
    }
    authReq.addExtension(fetch);
  }
View Full Code Here


        DiscoveryInformation discovered = _consumerManager.associate(discoveries);

        // store the discovery information in the session for later use
        session.setAttribute("discovered", discovered);

        FetchRequest fetch = FetchRequest.createFetchRequest();

        for (String typeUri : _attributes.keySet())
        {
            fetch.addAttribute(_attributes.get(typeUri), typeUri, false);
        }

        AuthRequest req = _consumerManager.authenticate(discovered, return_to);
        req.addExtension(fetch);
View Full Code Here

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

            } catch (MessageException e) {
                throw new RuntimeException(e);
            }

            if (ext instanceof FetchRequest) {
                FetchRequest fetchRequest = (FetchRequest) ext;

                List<OpenIdRequestedAttribute> requestedAttributes = new LinkedList<OpenIdRequestedAttribute>();
                handleAttributeRequests(fetchRequest, requestedAttributes, false);
                handleAttributeRequests(fetchRequest, requestedAttributes, true);
                openIdProviderRequest.get().setRequestedAttributes(requestedAttributes);
View Full Code Here

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

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

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

        String[] attributes = StringUtils.split(definition);
        if (attributes == null || attributes.length == 0) {
            return null;
        }

        FetchRequest fetch = FetchRequest.createFetchRequest();

        //parse the definition by tokenizing it to get the resulting attribute-specific config
        //
        //e.g. for a value of
        //
        //     "email, firstName[required=true], lastName"
        //
        // the resulting token array would equal
        //
        //     { "email", "firstName[required=true]", "lastName" }
        //
        for (String attribute : attributes) {
            //strip the name and extract any attribute-specific config between brackets [ ]
            String[] nameAndConfig = attribute.split("\\[", 2);
            String name = nameAndConfig[0];
            String config = null;

            if (nameAndConfig.length == 2) {
                config = nameAndConfig[1];
                //if there was an open bracket, there was a close bracket, so strip it too:
                config = config.substring(0, config.length() - 1);
            }

            AttributeDefinition ad = toDefinition(name, config);

            try {
                fetch.addAttribute(ad.getName(), ad.getUri(), ad.isRequired(), ad.getCount());
            } catch (MessageException e) {
                throw new OpenIdException("Unable to correctly add 'fetch' attribute.", e);
            }
        }
View Full Code Here

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

            throw new RuntimeException(e);
         }

         if (ext instanceof FetchRequest)
         {
            FetchRequest fetchRequest = (FetchRequest) ext;

            List<OpenIdRequestedAttribute> requestedAttributes = new LinkedList<OpenIdRequestedAttribute>();
            handleAttributeRequests(fetchRequest, requestedAttributes, false);
            handleAttributeRequests(fetchRequest, requestedAttributes, true);
            openIdProviderRequest.get().setRequestedAttributes(requestedAttributes);
View Full Code Here

TOP

Related Classes of org.openid4java.message.ax.FetchRequest

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.