Package org.openid4java.message.ax

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


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

   * @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

        }

        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

      }

      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

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

            if (verified != null) {
                AuthSuccess authSuccess = (AuthSuccess) verification
                        .getAuthResponse();

                if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
                    FetchRequest fetchResp = (FetchRequest) authSuccess
                            .getExtension(AxMessage.OPENID_NS_AX);

                    MessageExtension ext = authSuccess
                            .getExtension(AxMessage.OPENID_NS_AX);
                    if (ext instanceof FetchRequest) {
                        // FetchRequest fetchReq = (FetchRequest) ext;
                        Map<String, String> required = fetchResp
                                .getAttributes(true);
                        axRequired.putAll(required);
                        Map<String, String> optional = fetchResp
                                .getAttributes(false);
                        axOptional.putAll(optional);
                    }
                }
View Full Code Here

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

        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);
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", // attribute alias
                "http://schema.openid.net/contact/email", // type URI
                true); // required
            // attach the extension to the authentication request
            authReq.addExtension(fetch);
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.