Package org.openid4java.message

Examples of org.openid4java.message.AuthRequest


  }

  public void redirect(String openId) {
    discoveryInformation = performDiscovery(openId);

    AuthRequest authRequest = createOpenIdAuthRequest();

    RequestCycle.get().setRedirect(false);
    WicketUtils.getResponse().redirect(authRequest.getDestinationUrl(true));
  }
View Full Code Here


  private AuthRequest createOpenIdAuthRequest() {
    try {
      ConsumerManager consumerManager = OpenIdSession.get().getConsumerManager();

      AuthRequest auth = consumerManager.authenticate(discoveryInformation, OpenIdSession.get()
          .getOpenIdReturnUrl());

      if (discoveryInformation.getTypes().contains(AxMessage.OPENID_NS_AX)) {
        FetchRequest fetch = FetchRequest.createFetchRequest();
        fetch.addAttribute("email", "http://axschema.org/contact/email", true);
        fetch.addAttribute("fullname", "http://axschema.org/namePerson", false);
        fetch.addAttribute("firstname", "http://axschema.org/namePerson/first", false);
        fetch.addAttribute("lastname", "http://axschema.org/namePerson/last", false);
        auth.addExtension(fetch);
      } else if (discoveryInformation.getTypes().contains(SRegMessage.OPENID_NS_SREG)) {
        SRegRequest sregReq = SRegRequest.createFetchRequest();

        sregReq.addAttribute("fullname", true);
        sregReq.addAttribute("email", true);

        auth.addExtension(sregReq);
      }

      return auth;
    } catch (MessageException e) {
      throw new WicketRuntimeException("failed to create OpenID AuthRequest", e);
View Full Code Here

      DiscoveryInformation discovered = providerInfo.get();

      // obtain a AuthRequest message to be sent to the OpenID provider
      try
      {
         AuthRequest authReq = consumerManager.authenticate(discovered,
               adapter.getReturnURL());

         // Attribute Exchange example: fetching the 'email' attribute
         FetchRequest fetch = FetchRequest.createFetchRequest();
         SRegRequest sregReq = SRegRequest.createFetchRequest();

         OpenIDAttributeMap amap = adapter.getAttributeMap();
        
         if ("1".equals(amap.get("nickname")))
         {
            // fetch.addAttribute("nickname",
            // "http://schema.openid.net/contact/nickname", false);
            sregReq.addAttribute("nickname", false);
         }
        
         if ("1".equals(amap.get("email")))
         {
            fetch.addAttribute("email",OpenIDConstants.EMAIL.url(), false);
            sregReq.addAttribute("email", false);
         }
        
         if ("1".equals(amap.get("fullname")))
         {
            fetch.addAttribute("fullname",OpenIDConstants.FULLNAME.url(), false);
            sregReq.addAttribute("fullname", false);
         }
         if ("1".equals(amap.get("dob")))
         {
            fetch.addAttribute("dob",OpenIDConstants.DOB.url(), true);
            sregReq.addAttribute("dob", false);
         }
        
         if ("1".equals(amap.get("gender")))
         {
            fetch.addAttribute("gender",OpenIDConstants.GENDER.url(), false);
            sregReq.addAttribute("gender", false);
         }
        
         if ("1".equals(amap.get("postcode")))
         {
            fetch.addAttribute("postcode",OpenIDConstants.POSTCODE.url(), false);
            sregReq.addAttribute("postcode", false);
         }
        
         if ("1".equals(amap.get("country")))
         {
            fetch.addAttribute("country",OpenIDConstants.COUNTRY.url(), false);
            sregReq.addAttribute("country", false);
         }
        
         if ("1".equals(amap.get("language")))
         {
            fetch.addAttribute("language", OpenIDConstants.LANGUAGE.url(),false);
            sregReq.addAttribute("language", false);
         }
        
         if ("1".equals(amap.get("timezone")))
         {
            fetch.addAttribute("timezone", OpenIDConstants.TIMEZONE.url(), false);
            sregReq.addAttribute("timezone", false);
         }
        
        
         // attach the extension to the authentication request
         if (!sregReq.getAttributes().isEmpty())
         {
             authReq.addExtension(sregReq);
         }

         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
            adapter.sendToProvider(1, authReq.getDestinationUrl(true), null);
            return false;
         }
         else
         {
             // Option 2: HTML FORM Redirection (Allows payloads >2048 bytes)
            adapter.sendToProvider(2, authReq.getDestinationUrl(false),
                  authReq.getParameterMap());
         }
      }
      catch (MessageException e)
      {
         throw new OpenIDMessageException(e);
View Full Code Here

  }

  public void redirect(String openId) {
    discoveryInformation = performDiscovery(openId);

    AuthRequest authRequest = createOpenIdAuthRequest();

    WicketUtils.performTemporaryRedirect(authRequest.getDestinationUrl(true));
  }
View Full Code Here

  private AuthRequest createOpenIdAuthRequest() {
    try {
      ConsumerManager consumerManager = OpenIdSession.get().getConsumerManager();

      AuthRequest auth = consumerManager.authenticate(discoveryInformation, OpenIdSession.get()
          .getOpenIdReturnUrl());

      if (discoveryInformation.getTypes().contains(AxMessage.OPENID_NS_AX)) {
        FetchRequest fetch = FetchRequest.createFetchRequest();
        fetch.addAttribute("email", "http://axschema.org/contact/email", true);
        fetch.addAttribute("fullname", "http://axschema.org/namePerson", false);
        fetch.addAttribute("firstname", "http://axschema.org/namePerson/first", false);
        fetch.addAttribute("lastname", "http://axschema.org/namePerson/last", false);
        auth.addExtension(fetch);
      } else if (discoveryInformation.getTypes().contains(SRegMessage.OPENID_NS_SREG)) {
        SRegRequest sregReq = SRegRequest.createFetchRequest();

        sregReq.addAttribute("fullname", true);
        sregReq.addAttribute("email", true);

        auth.addExtension(sregReq);
      }

      return auth;
    } catch (MessageException e) {
      throw new WicketRuntimeException("failed to create OpenID AuthRequest", e);
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();

      // Using axschema
      fetch.addAttribute("emailax", "http://axschema.org/contact/email",
          true);

      fetch.addAttribute("firstnameax",
          "http://axschema.org/namePerson/first", true);

      fetch.addAttribute("lastnameax",
          "http://axschema.org/namePerson/last", true);

      fetch.addAttribute("fullnameax", "http://axschema.org/namePerson",
          true);

      fetch.addAttribute("email",
          "http://schema.openid.net/contact/email", true);

      // Using schema.openid.net (for compatibility)
      fetch.addAttribute("firstname",
          "http://schema.openid.net/namePerson/first", true);

      fetch.addAttribute("lastname",
          "http://schema.openid.net/namePerson/last", true);

      fetch.addAttribute("fullname",
          "http://schema.openid.net/namePerson", true);

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

  }

  public void redirect(String openId) {
    discoveryInformation = performDiscovery(openId);

    AuthRequest authRequest = createOpenIdAuthRequest();

    RequestCycle.get().setRedirect(false);
    WicketUtils.getResponse().redirect(authRequest.getDestinationUrl(true));
  }
View Full Code Here

  private AuthRequest createOpenIdAuthRequest() {
    try {
      ConsumerManager consumerManager = OpenIdSession.get().getConsumerManager();

      AuthRequest auth = consumerManager.authenticate(discoveryInformation, OpenIdSession.get()
          .getOpenIdReturnUrl());

      if (discoveryInformation.getTypes().contains(AxMessage.OPENID_NS_AX)) {
        FetchRequest fetch = FetchRequest.createFetchRequest();
        fetch.addAttribute("email", "http://axschema.org/contact/email", true);
        fetch.addAttribute("fullname", "http://axschema.org/namePerson", false);
        fetch.addAttribute("firstname", "http://axschema.org/namePerson/first", false);
        fetch.addAttribute("lastname", "http://axschema.org/namePerson/last", false);
        auth.addExtension(fetch);
      } else if (discoveryInformation.getTypes().contains(SRegMessage.OPENID_NS_SREG)) {
        SRegRequest sregReq = SRegRequest.createFetchRequest();

        sregReq.addAttribute("fullname", true);
        sregReq.addAttribute("email", true);

        auth.addExtension(sregReq);
      }

      return auth;
    } catch (MessageException e) {
      throw new WicketRuntimeException("failed to create OpenID AuthRequest", e);
View Full Code Here

                    String authReturnToURL = openIDRealmURL+"/"+OpenIDConstants.OPEN_ID_AUTHENTICATED_REQUEST+"?"+OpenIDConstants.OPEN_ID_RETURN+"="+returnPath;
                    String authRedirectURL = null;
                    try
                    {
                        // authentication request
                        AuthRequest authRequest = providerOpenIDConsumerManager.authenticate(discovered, authReturnToURL, openIDRealmURL);
                        // request attribute exchange data
                        FetchRequest axRequest = FetchRequest.createFetchRequest();
                        axRequest.addAttribute("email", "http://axschema.org/contact/email", true);
                        axRequest.addAttribute("fullname", "http://axschema.org/namePerson", true);
                        axRequest.addAttribute("lastname", "http://axschema.org/namePerson/last", true);
                        axRequest.addAttribute("firstname", "http://axschema.org/namePerson/first", true);
                        axRequest.addAttribute("nickname", "http://axschema.org/namePerson/friendly", true);
                        authRequest.addExtension(axRequest);
                        // request simple registration data
                        SRegRequest sregRequest = SRegRequest.createFetchRequest();
                        sregRequest.addAttribute("email", true);
                        sregRequest.addAttribute("fullname", true);
                        sregRequest.addAttribute("nickname", true);
                        authRequest.addExtension(sregRequest);
                        // authentication redirect
                        authRedirectURL = authRequest.getDestinationUrl(true);
                    }
                    catch (OpenIDException oide)
                    {
                        throw new RuntimeException("Unexpected OpenID authentication request exception: "+oide, oide);
                    }
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", // attribute alias
              "http://schema.openid.net/contact/email", // type URI
              true); // required
      // attach the extension to the authentication request
      authReq.addExtension(fetch);

      // example using Simple Registration to fetching the 'email' attribute
      SRegRequest sregReq = SRegRequest.createFetchRequest();
      sregReq.addAttribute("email", true);
      authReq.addExtension(sregReq);

      // 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 false;
      /*
       * } else { // Option 2: HTML FORM Redirection (Allows payloads >2048 bytes)
       *
       * // RequestDispatcher dispatcher = //
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.