Package org.openid4java.discovery

Examples of org.openid4java.discovery.DiscoveryInformation


    @RequestMapping(value = "/openidAnswer", method = GET)
    public ModelAndView showAnswer(HttpServletRequest request) throws Exception {
        ParameterList response = new ParameterList(request.getParameterMap());

        // retrieve the previously stored discovery information
        DiscoveryInformation discovered =
                (DiscoveryInformation) request.getSession().getAttribute(DISCOVERY_SESSION_KEY);

        // extract the receiving URL from the HTTP request
        StringBuffer receivingURL = request.getRequestURL();
        String queryString = request.getQueryString();
View Full Code Here


            // perform discovery on the user-supplied identifier
            List discoveries = manager.discover(openId);

            // attempt to associate with the OpenID provider
            // and retrieve one service endpoint for authentication
            DiscoveryInformation discovered = manager.associate(discoveries);

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

      if(discoveries.size() == 0)
         throw new OpenIDConsumerException("No open id endpoints discovered");
     
      // attempt to associate with the OpenID provider
      // and retrieve one service endpoint for authentication
      DiscoveryInformation discovered = consumerManager.associate(discoveries);
     
      // store the discovery information in the user's session for later use
      // leave out for stateless operation / if there is no session
      if(lifeCycle != null)
      {
View Full Code Here

   @SuppressWarnings("unchecked")
   public boolean authenticate(OpenIDProtocolAdapter adapter, OpenIDProviderInformation providerInfo)
   throws OpenIDDiscoveryException,
   OpenIDConsumerException, OpenIDMessageException, OpenIDProtocolException
   {  
      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);
View Full Code Here

      ParameterList responselist = new ParameterList(parameterMap);
     
      if(lifeCycle == null)
         throw new IllegalStateException("Lifecycle not found");
     
      DiscoveryInformation discovered =
         (DiscoveryInformation) lifeCycle.getAttributeValue(CONST.OPENID_DISC.get());
     
      // verify the response; ConsumerManager needs to be the same
      // (static) instance used to place the authentication request
      try
View Full Code Here

    // perform discovery on the user-supplied identifier
    List discoveries = _manager.discover(userSuppliedString);

    // attempt to associate with the OpenID provider
    // and retrieve one service endpoint for authentication
    DiscoveryInformation discovered = _manager.associate(discoveries);

    // the next section will figure out where we go next, if anywhere.
    WOActionResults results = null;

    if (discovered != null)
    {
      // store the discovery information in the user's session
      session.setObjectForKey(discovered, EROpenIDManager.DISCOVERY_INFO_KEY);

      // configure the return_to URL where your application will receive
      // the authentication responses from the OpenID provider
      String returnToUrl = _delegate.returnToUrl(request, context);

      // obtain a AuthRequest message to be sent to the OpenID provider
      AuthRequest authReq = _manager.authenticate(discovered, returnToUrl, realm);

      // add the message extensions
      List<MessageExtension> exts = _delegate.createFetchMessageExtensions(userSuppliedString, request, context);
      for (MessageExtension ext : exts) {
        // attach the extension to the authentication request
        EROpenIDManager.log.debug("Authentication request extension: " + ext);
        authReq.addExtension(ext);
      }

      if (!discovered.isVersion2()) {
        WORedirect redirect = new WORedirect(context);
        String url = authReq.getDestinationUrl(true);
        EROpenIDManager.log.debug("Request URL: " + url);
        redirect.setUrl(url);
        results = redirect;
View Full Code Here

      responseParameters.set(new Parameter(formValueKey, formValue));
      EROpenIDManager.log.debug("Response parameter: " + formValueKey + " => " + formValue);
    }

    // retrieve the previously stored discovery information
    DiscoveryInformation discovered = (DiscoveryInformation) session.objectForKey(EROpenIDManager.DISCOVERY_INFO_KEY);

    // extract the receiving URL from the HTTP request

    String receivingUrl = _delegate.rewriteReceivingUrl(request, context);
View Full Code Here

      if(discoveries.size() == 0)
         throw new OpenIDConsumerException("No open id endpoints discovered");
     
      // attempt to associate with the OpenID provider
      // and retrieve one service endpoint for authentication
      DiscoveryInformation discovered = consumerManager.associate(discoveries);
     
      // store the discovery information in the user's session for later use
      // leave out for stateless operation / if there is no session
      if(lifeCycle != null)
      {
View Full Code Here

   @SuppressWarnings("unchecked")
   public boolean authenticate(OpenIDProtocolAdapter adapter, OpenIDProviderInformation providerInfo)
   throws OpenIDDiscoveryException,
   OpenIDConsumerException, OpenIDMessageException, OpenIDProtocolException
   {  
      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);
View Full Code Here

      ParameterList responselist = new ParameterList(parameterMap);
     
      if(lifeCycle == null)
         throw new IllegalStateException("Lifecycle not found");
     
      DiscoveryInformation discovered =
         (DiscoveryInformation) lifeCycle.getAttributeValue(CONST.OPENID_DISC.get());
     
      // verify the response; ConsumerManager needs to be the same
      // (static) instance used to place the authentication request
      try
View Full Code Here

TOP

Related Classes of org.openid4java.discovery.DiscoveryInformation

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.