Package org.apache.jetspeed.sso

Examples of org.apache.jetspeed.sso.SSOSite


    public void addSiteChallengeResponse(String siteName, String siteUrl, String realm)
    throws SSOException
    {
      try
        {
            SSOSite ssoSite = new SSOSiteImpl();
            ssoSite.setSiteURL(siteUrl);
            ssoSite.setName(siteName);
            ssoSite.setCertificateRequired(false);
            ssoSite.setAllowUserSet(true);
            ssoSite.setRealm(realm);
            ssoSite.setChallengeResponseAuthentication(true);
             getPersistenceBrokerTemplate().store(ssoSite);
            this.mapSite.put(siteUrl, ssoSite);           
        }
        catch (Exception e)
        {
View Full Code Here


    public void addSite(String siteName, String siteUrl)
    throws SSOException
    {
        try
        {
            SSOSite ssoSite = new SSOSiteImpl();
            ssoSite.setSiteURL(siteUrl);
            ssoSite.setName(siteName);
            ssoSite.setCertificateRequired(false);
            ssoSite.setAllowUserSet(true);           
            getPersistenceBrokerTemplate().store(ssoSite);
            this.mapSite.put(siteUrl, ssoSite);           
        }
        catch (Exception e)
        {
View Full Code Here

        int numberOfSites = sites.length;
       
        // Do all the logins for the site
        for (int i=0; i<numberOfSites; i++)
        {
          SSOSite site = sites[i];
         
          if (site != null)
          {
            Iterator itRemotePrincipals = site.getRemotePrincipals().iterator();
            while (itRemotePrincipals.hasNext() )
            {
              InternalUserPrincipal remotePrincipal = (InternalUserPrincipal)itRemotePrincipals.next();
                  if (remotePrincipal != null)
                  {
                    InternalCredential credential = null;
                    if ( remotePrincipal.getCredentials() != null)
                      credential = (InternalCredential)remotePrincipal.getCredentials().iterator().next();
                   
                    if (credential != null)
                    {
                      if (log.isInfoEnabled())
                        log.info("SSOComponent -- Remote Principal ["+stripPrincipalName(remotePrincipal.getFullPath())+"] has credential ["+this.unscramble(credential.getValue())+ "]");
                     
                      client.getState().setCredentials(
                            site.getRealm(),
                                  urlObj.getHost(),
                                  new UsernamePasswordCredentials(stripPrincipalName(remotePrincipal.getFullPath())this.unscramble(credential.getValue()))
                              );
                     
                      // Build URL if it's Form authentication
                      StringBuffer siteURL = new StringBuffer(site.getSiteURL());
                    
                    // Check if it's form based or ChallengeResponse
                    if (site.isFormAuthentication())
                    {
                      siteURL.append("?").append(site.getFormUserField()).append("=").append(stripPrincipalName(remotePrincipal.getFullPath())).append("&").append(site.getFormPwdField()).append("=").append(this.unscramble(credential.getValue()));
                    }
                     
                      get = new GetMethod(siteURL.toString());
 
                            // Tell the GET method to automatically handle authentication. The
                            // method will use any appropriate credentials to handle basic
                            // authentication requests.  Setting this value to false will cause
                            // any request for authentication to return with a status of 401.
                            // It will then be up to the client to handle the authentication.
                            get.setDoAuthentication( true );
                            try {
                                // execute the GET
                                int status = client.executeMethod( get );
                               
                                if (log.isInfoEnabled() )
                                    log.info("Accessing site [" + site.getSiteURL() + "]. HTTP Status [" +status+ "]" );
                               
                                /*
                             * If the destination URL and the SSO url match
                             * use the authentication process but return immediately
                             * the result page.
                             */
                                if( destUrl.compareTo(site.getSiteURL()) == 0 && numberOfSites == 1)
                                {
                                  if (log.isInfoEnabled() )
                                    log.info("SSO Component --SSO Site and destination URL match. Go and get the content." );
                                 
                                  //try
View Full Code Here

    {
        List resultSetTitleList = new ArrayList();
        List resultSetTypeList = new ArrayList();
        try
        {
            SSOSite site = null;
            Iterator principals = null;
            List list = null;
            resultSetTypeList.add(String.valueOf(Types.VARCHAR));
            resultSetTitleList.add("Principal");
            resultSetTypeList.add(String.valueOf(Types.VARCHAR));
View Full Code Here

            else if (delete != null && !(isEmpty(delete)))
            {
                try
                {
                    String siteName = (String)PortletMessaging.receive(request, "site", "selectedUrl");                                           
                    SSOSite site = sso.getSite(siteName);
                    User user = null;
                    try
                    {
                        user = userManager.getUser(delete);  
                    }
                    catch(SecurityException se)
                    {
                        // User doesn't exist -- maybe a group
                        user =null;
                    }
                   
                    if ( site != null )
                    {
                        /*
                       * If the user is null try to remove a group
                       */
                      if ( user != null)
                      {
                          // Remove USER
                          Subject subject = user.getSubject();
                          sso.removeCredentialsForSite(subject, site.getSiteURL());
                          this.clearBrowserIterator(request);
                      }
                      else
                      {
                          // Try group removal
                          String fullPath = "/group/" + delete;
                          sso.removeCredentialsForSite(fullPath, site.getSiteURL());
                          this.clearBrowserIterator(request);
                     
                   }
                }
                catch (SSOException e)
                {
                    publishStatusMessage(request, "SSODetails", "status", e, "Could not remove credentials");
                }
            }
            else if (add != null)
            {
                // Roger: here is the principal type
                String principalType = request.getParameter("principal.type")//group user
                String portalPrincipal = request.getParameter("portal.principal");               
                String remotePrincipal = request.getParameter("remote.principal");
                String remoteCredential = request.getParameter("remote.credential");
               
                // The principal type can benull if the user just typed the name instead of
                // using the choosers.
               
                if (principalType == null || principalType.length() == 0 )
                    principalType = "user";
               
                if (!(isEmpty(remotePrincipal) || isEmpty(remotePrincipal) || isEmpty(remoteCredential)))
                {
                    try
                    {
                        String siteName = (String)PortletMessaging.receive(request, "site", "selectedUrl");                       
                        SSOSite site = sso.getSite(siteName);
                        Subject subject = null;
                        String groupFullPath = null;
                       
                        if (principalType.compareTo("user") == 0)
                        {
                            User user = userManager.getUser(portalPrincipal);   
                            subject = user.getSubject();
                        }
                        else
                        {
                            // Create fullPath
                            groupFullPath = "/group/" + portalPrincipal;
                          }
                       
                        if (site != null && (subject != null || groupFullPath != null) )
                        {
                            if (subject != null )
                                sso.addCredentialsForSite(subject, remotePrincipal, site.getSiteURL(), remoteCredential);
                            else
                                sso.addCredentialsForSite(groupFullPath, remotePrincipal, site.getSiteURL(), remoteCredential);
                           
                            this.clearBrowserIterator(request);
                        }
                    }
                    catch (SSOException e)
View Full Code Here

            List list = new ArrayList();
            while (sites.hasNext())
            {
                List row = new ArrayList(2);
                SSOSite site = (SSOSite)sites.next();
                row.add(0, site.getSiteURL());                    
                row.add(1, site.getName());
                list.add(row);
            }           
            BrowserIterator iterator = new DatabaseBrowserIterator(
                    list, resultSetTitleList, resultSetTypeList,
                    windowSize);
View Full Code Here

        if (request.getPortletMode() == PortletMode.VIEW)
        {
            String selectedSite = request.getParameter("ssoSite");
            if (selectedSite != null)
            {
                SSOSite site = sso.getSite(selectedSite);
                if (site != null)
                {
                    PortletMessaging.publish(request, "site", "selectedUrl", selectedSite);
                    PortletMessaging.publish(request, "site", "selectedName", site.getName());
                    PortletMessaging.publish(request, "site", "change", selectedSite);
                    PortletMessaging.publish(request, "site", "realm", site.getRealm());
                    PortletMessaging.publish(request, "site", "idField", site.getFormUserField());
                    PortletMessaging.publish(request, "site", "pwdField", site.getFormPwdField());
                }
            }
            String refresh = request.getParameter("sso.refresh");
            String save = request.getParameter("sso.save");
            String neue = request.getParameter("sso.new");
            String delete = request.getParameter("ssoDelete");
           
            if (refresh != null)
            {
                this.clearBrowserIterator(request);
            }
            else if (neue != null)
            {
                PortletMessaging.cancel(request, "site", "selected");
                PortletMessaging.cancel(request, "site", "selectedUrl");     
                PortletMessaging.cancel(request, "site", "realm");
                PortletMessaging.cancel(request, "site", "idField");
                PortletMessaging.cancel(request, "site", "pwdField");
            }
            else if (delete != null && (!(isEmpty(delete))))
            {
                try
                {
                    SSOSite site = null;
                    site = sso.getSite(delete);
                    if (site != null)
                    {
                        sso.removeSite(site);
                        this.clearBrowserIterator(request);
                        PortletMessaging.cancel(request, "site", "selected");
                        PortletMessaging.cancel(request, "site", "selectedUrl");  
                        PortletMessaging.cancel(request, "site", "realm");
                        PortletMessaging.cancel(request, "site", "idField");
                        PortletMessaging.cancel(request, "site", "pwdField");
                    }
                }
                catch (SSOException e)
                {
                    publishStatusMessage(request, "SSOBrowser", "status", e, "Could not remove site");
                }
            }
            else if (save != null)
            {
                String siteName = request.getParameter("site.name");               
                String siteUrl = request.getParameter("site.url");
               
                String siteRealm = request.getParameter("site.realm");               
                String siteFormID = request.getParameter("site.form_field_ID");
                String siteFormPWD = request.getParameter("site.form_field_PWD");
                
                if (!(isEmpty(siteName) || isEmpty(siteUrl)))
                {
                    try
                    {
                        SSOSite site = null;
                        String old = (String)PortletMessaging.receive(request, "site", "selectedUrl");
                        if (old != null)
                        {
                            site = sso.getSite(old);
                        }
                        else
                        {
                            site = sso.getSite(siteUrl);
                        }                       
                        if (site != null)
                        {
                            site.setName(siteName);
                            site.setSiteURL(siteUrl);
                            site.setRealm(siteRealm);
                            if (siteFormID != null && siteFormID.length() > 0
                              && siteFormPWD != null && siteFormPWD.length() > )
                            {
                              // Form authentication
                              site.setFormAuthentication(true);
                              site.setFormUserField(siteFormID);
                              site.setFormPwdField(siteFormPWD);
                            }
                            else
                            {
                              //Challenge response authentication
                              site.setChallengeResponseAuthentication(true);
                            }
                           
                            sso.updateSite(site);
                            this.clearBrowserIterator(request);
                            PortletMessaging.publish(request, "site", "selectedName", siteName);
View Full Code Here

       * given user site url combination
       */
      String proxyID = fullPath + "_" + SSOSite;
     
      // Get the site
      SSOSite ssoSite = getSSOSiteObject(SSOSite);
   
    if ( ssoSite != null)
    {
      SSOSite[] sites = new SSOSite[1];
      sites[0] = ssoSite;
View Full Code Here

      SSOSite[] ssoSites = new SSOSite[siteSize];
     
      Iterator itSites = sites.iterator();
      while(itSites.hasNext())
      {
        SSOSite ssoSite = (SSOSite)itSites.next();
        if (ssoSite != null)
        {
          ssoSites[siteIndex] = ssoSite;
          siteIndex++;
        }
View Full Code Here

    }
   

    public void setRealmForSite(String site, String realm) throws SSOException
    {
      SSOSite ssoSite = getSSOSiteObject(site);
   
    if ( ssoSite != null)
    {
      try
      {
        ssoSite.setRealm(realm);
        getPersistenceBrokerTemplate().store(ssoSite);
      }
      catch (Exception e)
      {
        throw new SSOException("Failed to set the realm for site [" + site + "] Error" +e );
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.sso.SSOSite

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.