Examples of SSOSite


Examples of org.apache.jetspeed.sso.SSOSite

  /* (non-Javadoc)
   * @see org.apache.jetspeed.sso.SSOProvider#hasSSOCredentials(javax.security.auth.Subject, java.lang.String)
   */
  public boolean hasSSOCredentials(Subject subject, String site) {
    // Initialization
    SSOSite ssoSite = getSSOSiteObject(site);
   
    if ( ssoSite == null)
    {
      return false// no entry for site
    }
   
    // Get the principal from the subject
    BasePrincipal principal = (BasePrincipal)SecurityHelper.getBestPrincipal(subject, UserPrincipal.class);
    String fullPath = principal.getFullPath();
   
       
    // Get remotePrincipals for Site and match them with the Remote Principal for the Principal attached to site
    Collection remoteForSite    = ssoSite.getRemotePrincipals();
    Collection principalsForSite  = ssoSite.getPrincipals()// Users
   
    // If any of them don't exist just return
    if (principalsForSite == null || remoteForSite== null )
        return false// no entry
   
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOSite

   */
  public SSOContext getCredentials(Subject subject, String site)
      throws SSOException {
   
    // Initialization
    SSOSite ssoSite = getSSOSiteObject(site);
   
    if ( ssoSite == null)
      throw new SSOException(SSOException.NO_CREDENTIALS_FOR_SITE)// no entry for site
   
    // Get the principal from the subject
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOSite

   */
  public void addCredentialsForSite(Subject subject, String remoteUser, String site, String pwd)
      throws SSOException {
   
    // Check if an entry for the site already exists otherwise create a new one
    SSOSite ssoSite = getSSOSiteObject(site);
    if (ssoSite == null)
    {
      // Create a new site
      ssoSite = new SSOSiteImpl();
      ssoSite.setSiteURL(site);
      ssoSite.setName(site);
      ssoSite.setCertificateRequired(false);
      ssoSite.setAllowUserSet(true);
      // By default we use ChallengeResponse Authentication
      ssoSite.setChallengeResponseAuthentication(true);
      ssoSite.setFormAuthentication(false);
     
      // Store the site so that we get a valid SSOSiteID
      try
           {
               getPersistenceBrokerTemplate().store(ssoSite);
            }
           catch (Exception e)
           {
             e.printStackTrace();
              throw new SSOException(SSOException.FAILED_STORING_SITE_INFO_IN_DB + e.toString() );
           }
    }
   
    // Get the Principal information (logged in user)
    String fullPath = ((BasePrincipal)SecurityHelper.getBestPrincipal(subject, UserPrincipal.class)).getFullPath();
    String principalName = ((BasePrincipal)SecurityHelper.getBestPrincipal(subject, UserPrincipal.class)).getName();
   
    // Add an entry for the principal to the site if it doesn't exist
    SSOPrincipal principal = this.getPrincipalForSite(ssoSite, fullPath);
   
    if (principal == null )
    {
        principal = getSSOPrincipal(fullPath);
        ssoSite.addPrincipal(principal);
    }
    else
    {
        // Check if the entry the user likes to update exists already
        Collection remoteForSite = ssoSite.getRemotePrincipals();
        Collection principalsForSite = ssoSite.getPrincipals();
       
        if ( remoteForSite != null && principalsForSite != null)
        {
            Collection remoteForPrincipals = this.getRemotePrincipalsForPrincipal(principalsForSite, fullPath);
            if ( remoteForPrincipals != null)
            {
              if (findRemoteMatch(remoteForPrincipals, remoteForSite) != null )
              {
                  // Entry exists can't to an add has to call update
                  throw new SSOException(SSOException.REMOTE_PRINCIPAL_EXISTS_CALL_UPDATE);
              }
            }
        }
    }
   
    if (principal == null)
      throw new SSOException(SSOException.FAILED_ADDING_PRINCIPAL_TO_MAPPING_TABLE_FOR_SITE);
   
    // Create a remote principal and credentials
    InternalUserPrincipalImpl remotePrincipal = new InternalUserPrincipalImpl(remoteUser);
   
    /*
     * The RemotePrincipal (class InternalUserPrincipal) will have a fullPath that identifies the entry as an SSO credential.
     * The entry has to be unique for a site and principal  (GROUP -or- USER ) an therefore it needs to be encoded as following:
     * The convention for the path is the following: /sso/SiteID/{user|group}/{user name | group name}/remote user name
     */
    if ( fullPath.indexOf("/group/") > -1)
        remotePrincipal.setFullPath("/sso/" + ssoSite.getSiteId() + "/group/"+  principalName + "/" + remoteUser);
    else
        remotePrincipal.setFullPath("/sso/" + ssoSite.getSiteId() + "/user/"+ principalName + "/" + remoteUser);
   
    // New credential object for remote principal
     InternalCredentialImpl credential =
            new InternalCredentialImpl(remotePrincipal.getPrincipalId(),
                this.scramble(pwd), 0, DefaultPasswordCredentialImpl.class.getName());
    
     if ( remotePrincipal.getCredentials() == null)
       remotePrincipal.setCredentials(new ArrayList(0));
    
    remotePrincipal.getCredentials().add( credential);
   
    // Add it to Principals remotePrincipals list
    principal.addRemotePrincipal(remotePrincipal);

    // Update the site remotePrincipals list
    ssoSite.getRemotePrincipals().add(remotePrincipal);
   
      
    // Update database and reset cache
     try
         {
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOSite

      throws SSOException {
   
    // Initailization
    InternalUserPrincipal remotePrincipal = null;
    //Get the site
    SSOSite ssoSite = getSSOSiteObject(site);
    if (ssoSite == null)
    {
      throw new SSOException(SSOException.NO_CREDENTIALS_FOR_SITE);
    }
   
    // Get the Principal information
    String fullPath = ((BasePrincipal)SecurityHelper.getBestPrincipal(subject, UserPrincipal.class)).getFullPath();
   
    try
    {
      //  Get remotePrincipals for Site and match them with the Remote Principal for the Principal attached to site
      Collection principalsForSite = ssoSite.getPrincipals();
      Collection remoteForSite = ssoSite.getRemotePrincipals();
     
      // If any of them don't exist just return
      if (principalsForSite == null || remoteForSite== null )
          throw new SSOException(SSOException.NO_CREDENTIALS_FOR_SITE);
     
      Collection remoteForPrincipals = getRemotePrincipalsForPrincipal(principalsForSite, fullPath);
     
      if ( remoteForPrincipals == null)
          throw new SSOException(SSOException.NO_CREDENTIALS_FOR_SITE);
     
      // Get remote Principal that matches the site and the principal
      if ((remotePrincipal = findRemoteMatch(remoteForPrincipals, remoteForSite)) == null )
      {
          throw new SSOException(SSOException.NO_CREDENTIALS_FOR_SITE);
      }

      // Update assocation tables
      ssoSite.getRemotePrincipals().remove(remotePrincipal);
     
      if (remoteForPrincipals.remove(remotePrincipal) == true)
     
      // Update the site
      getPersistenceBrokerTemplate().store(ssoSite);
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOSite

      // Update the credential
      //     Initailization
      InternalUserPrincipal remotePrincipal = null;
     
      //Get the site
      SSOSite ssoSite = getSSOSiteObject(site);
      if (ssoSite == null)
      {
        throw new SSOException(SSOException.NO_CREDENTIALS_FOR_SITE);
      }
     
      // Get the Principal information
      String fullPath = ((BasePrincipal)SecurityHelper.getBestPrincipal(subject, UserPrincipal.class)).getFullPath();
     
      //  Get remotePrincipals for Site and match them with the Remote Principal for the Principal attached to site
      Collection principalsForSite  = ssoSite.getPrincipals();
      Collection remoteForSite    = ssoSite.getRemotePrincipals();
     
      // If any of them don't exist just return
      if (principalsForSite == null || remoteForSite== null )
          throw new SSOException(SSOException.NO_CREDENTIALS_FOR_SITE);
     
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOSite

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

Examples of org.apache.jetspeed.sso.SSOSite

            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

Examples of org.apache.jetspeed.sso.SSOSite

            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

Examples of org.apache.jetspeed.sso.SSOSite

        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

Examples of org.apache.jetspeed.sso.SSOSite

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