Examples of FetchRequest


Examples of org.openid4java.message.ax.FetchRequest

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

Examples of org.openid4java.message.ax.FetchRequest

            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

Examples of org.openid4java.message.ax.FetchRequest

        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

Examples of org.openid4java.message.ax.FetchRequest

         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

Examples of org.openid4java.message.ax.FetchRequest

            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

Examples of org.openid4java.message.ax.FetchRequest

                    sreg.addAttribute(key.substring("openid.sreg.".length()), true); // required
                }
            }

            /* Attribute Exchange */
            FetchRequest fetch = null;
            if( bypassAX == false ){
                fetch = FetchRequest.createFetchRequest();
                Map<String, String> axmap = axstore.getMap();
                Set axentries = axmap.entrySet();
                Iterator axit = axentries.iterator();
                while( axit.hasNext() ){
                    Map.Entry<String, String> entry = (Map.Entry<String,String>)axit.next();
                    String key = (String)entry.getKey(); //Label
                    String value = (String)entry.getValue(); //Type URI
                    if( request.getParameter(key) != null ){
                        logger.info( key + ":" + request.getParameter(key) );
                        if( "on".compareTo( request.getParameter(key) ) == 0)
                            // .,:\n are not allowed in the alias
                            fetch.addAttribute(key.replaceAll("[.,:\n]","-"), value, false); // required
                    }
                }
            }

            /* Do the actual work */
 
View Full Code Here

Examples of org.openid4java.message.ax.FetchRequest

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

Examples of org.openid4java.message.ax.FetchRequest

   * @throws IdentityException
   */
  public MessageExtension getMessageExtension(OpenIDAuthenticationRequest request)
      throws IdentityException {

    FetchRequest fetchReq = null;
    OpenIDAxAttribute attr = null;

    try {
      fetchReq = FetchRequest.createFetchRequest();
      if (request != null && request.getRequiredClaims() != null
          && request.getRequiredClaims().size() > 0) {
        for (Object requiredClaim : request.getRequiredClaims()) {
          if (requiredClaim instanceof OpenIDAxAttribute) {
            attr = (OpenIDAxAttribute) requiredClaim;
            fetchReq.addAttribute(attr.getAttributeName(), attr.getNamespace(), true);
          }
        }
      }
      if (request != null && request.getOptionalClaims() != null
          && request.getOptionalClaims().size() > 0) {
        for (Object optionalClaim : request.getOptionalClaims()) {
          if (optionalClaim instanceof OpenIDAxAttribute) {
            attr = (OpenIDAxAttribute) optionalClaim;
            fetchReq.addAttribute(attr.getAttributeName(), attr.getNamespace(), false);
          }
        }
      }
    } catch (MessageException e) {
      log.error("Error while creating the message extension for OpenIDAttributeExchange", e);
View Full Code Here

Examples of org.openid4java.message.ax.FetchRequest

        }

        if (extensions instanceof FetchRequest) {
          Map required = null;
          Map optional = null;
          FetchRequest fetchRequest = null;

          fetchRequest = (FetchRequest) extensions;

          // Get the required attributes as requested by the RP.
          required = fetchRequest.getAttributes(true);
          optional = fetchRequest.getAttributes();

          if (optional != null && !optional.isEmpty()) {
            Iterator iterator = optional.entrySet().iterator();
            Entry entry = null;
            while (iterator.hasNext()) {
View Full Code Here

Examples of org.openid4java.message.ax.FetchRequest

      }

      if (extensions instanceof FetchRequest) {
        Map required = null;
        Map optional = null;
        FetchRequest fetchRequest = null;
        Map<String, OpenIDClaimDTO> claimValues = null;

        fetchRequest = (FetchRequest) extensions;

        // Get the required attributes as requested by the RP.
        required = fetchRequest.getAttributes(true);
        optional = fetchRequest.getAttributes();

        if (optional != null && !optional.isEmpty()) {
          Iterator iterator = optional.entrySet().iterator();
          Entry entry = null;
          while (iterator.hasNext()) {
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.