Examples of SSOPrincipal


Examples of org.apache.jetspeed.sso.SSOPrincipal

     * @return
     */
    public Collection getCookiesForUser(String fullPath)
    {
      // Get the SSO user identified by the fullPath
      SSOPrincipal ssoPrincipal = this.getSSOPrincipal(fullPath);
     
      // For each remote user we'll get the cookie
      Vector temp = new Vector();
     
      Iterator itRemotePrincipal = ssoPrincipal.getRemotePrincipals().iterator();
      while (itRemotePrincipal.hasNext())
      {
        InternalUserPrincipal rp  = (InternalUserPrincipal)itRemotePrincipal.next();
        if (rp != null)
        {
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOPrincipal

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

Examples of org.apache.jetspeed.sso.SSOPrincipal

   * getPrincipalForSite()
   * returns a principal that matches the full path for the site or creates a new entry if it doesn't exist
   */
  private SSOPrincipal getPrincipalForSite(SSOSite ssoSite, String fullPath)
  {
    SSOPrincipal principal = null;
    Collection principalsForSite = ssoSite.getPrincipals();
   
    if ( principalsForSite != null)
    {
      Iterator itPrincipals = principalsForSite.iterator();
      while (itPrincipals.hasNext() && principal == null)
      {
        SSOPrincipal tmp  = (SSOPrincipal)itPrincipals.next();
        if (      tmp != null
               && tmp.getFullPath().compareToIgnoreCase(fullPath) == 0 )
          principal = tmp;  // Found existing entry
      }
    }
   
    return principal;
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOPrincipal

  }
 
  private SSOPrincipal getSSOPrincipal(String fullPath)
  {
      // FInd if the principal exists in the SECURITY_PRINCIPAL table
      SSOPrincipal principal = null;
     
    Criteria filter = new Criteria();      
      filter.addEqualTo("fullPath", fullPath);
     
      QueryByCriteria query = QueryFactory.newQuery(SSOPrincipalImpl.class, filter);
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOPrincipal

      {
        Iterator itPrincipalsForSite = principalsForSite.iterator();
        while (itPrincipalsForSite.hasNext())
        {
            String principalFullPath = null;
            SSOPrincipal principal = (SSOPrincipal)itPrincipalsForSite.next();
            principalFullPath = principal.getFullPath();
           
            /* If the Principal is for a Group expand the Group and check if the user identified
            * by the fullPath is a member of the Group. If the user is a member of the Group
            * return the remote Credentials for the current Principal.
            */
            if ( principalFullPath.indexOf("/group/") == -1)
            {
                // USER
                if ( principalFullPath.compareToIgnoreCase(fullPath) == 0)
                    return principal.getRemotePrincipals();
            }
            else
            {
                /* GROUP
                 * If the full path is for a group (delete/add) just return the the list of remotePrincipals
                 * For a lookup (hasCredentials) the user needs to be mapped against each member of the group
                */
                if ( principalFullPath.compareToIgnoreCase(fullPath) == 0)
                    return principal.getRemotePrincipals();
               
                /* Expand the Group and find a match */
              InternalGroupPrincipal  groupPrincipal = getGroupPrincipals(principalFullPath);
             
              // Found Group that matches the name
              if (groupPrincipal != null)
                {
                  Collection usersInGroup = groupPrincipal.getUserPrincipals();
                  Iterator itUsers = usersInGroup.iterator();
                    while (itUsers.hasNext())
                    {
                        InternalUserPrincipal user = (InternalUserPrincipal)itUsers.next();
                        if (user.getFullPath().compareToIgnoreCase(fullPath) == 0)
                        {
                            // User is member of the group
                            return principal.getRemotePrincipals();
                        }
                    }
                }
            } 
        }
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOPrincipal

     * @return
     */
    public Collection getCookiesForUser(String fullPath)
    {
      // Get the SSO user identified by the fullPath
      SSOPrincipal ssoPrincipal = this.getSSOPrincipal(fullPath);
     
      // For each remote user we'll get the cookie
      Vector temp = new Vector();
     
      Iterator itRemotePrincipal = ssoPrincipal.getRemotePrincipals().iterator();
      while (itRemotePrincipal.hasNext())
      {
        InternalUserPrincipal rp  = (InternalUserPrincipal)itRemotePrincipal.next();
        if (rp != null)
        {
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOPrincipal

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

Examples of org.apache.jetspeed.sso.SSOPrincipal

   * getPrincipalForSite()
   * returns a principal that matches the full path for the site or creates a new entry if it doesn't exist
   */
  private SSOPrincipal getPrincipalForSite(SSOSite ssoSite, String fullPath)
  {
    SSOPrincipal principal = null;
    Collection principalsForSite = ssoSite.getPrincipals();
   
    if ( principalsForSite != null)
    {
      Iterator itPrincipals = principalsForSite.iterator();
      while (itPrincipals.hasNext() && principal == null)
      {
        SSOPrincipal tmp  = (SSOPrincipal)itPrincipals.next();
        if (      tmp != null
               && tmp.getFullPath().compareToIgnoreCase(fullPath) == 0 )
          principal = tmp;  // Found existing entry
      }
    }
   
    return principal;
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOPrincipal

  }
 
  private SSOPrincipal getSSOPrincipal(String fullPath)
  {
      // FInd if the principal exists in the SECURITY_PRINCIPAL table
      SSOPrincipal principal = null;
     
    Criteria filter = new Criteria();      
      filter.addEqualTo("fullPath", fullPath);
     
      QueryByCriteria query = QueryFactory.newQuery(SSOPrincipalImpl.class, filter);
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOPrincipal

      {
        Iterator itPrincipalsForSite = principalsForSite.iterator();
        while (itPrincipalsForSite.hasNext())
        {
            String principalFullPath = null;
            SSOPrincipal principal = (SSOPrincipal)itPrincipalsForSite.next();
            principalFullPath = principal.getFullPath();
           
            /* If the Principal is for a Group expand the Group and check if the user identified
            * by the fullPath is a member of the Group. If the user is a member of the Group
            * return the remote Credentials for the current Principal.
            */
            if ( principalFullPath.indexOf("/group/") == -1)
            {
                // USER
                if ( principalFullPath.compareToIgnoreCase(fullPath) == 0)
                    return principal.getRemotePrincipals();
            }
            else
            {
                /* GROUP
                 * If the full path is for a group (delete/add) just return the the list of remotePrincipals
                 * For a lookup (hasCredentials) the user needs to be mapped against each member of the group
                */
                if ( principalFullPath.compareToIgnoreCase(fullPath) == 0)
                    return principal.getRemotePrincipals();
               
                /* Expand the Group and find a match */
              InternalGroupPrincipal  groupPrincipal = getGroupPrincipals(principalFullPath);
             
              // Found Group that matches the name
              if (groupPrincipal != null)
                {
                  Collection usersInGroup = groupPrincipal.getUserPrincipals();
                  Iterator itUsers = usersInGroup.iterator();
                    while (itUsers.hasNext())
                    {
                        InternalUserPrincipal user = (InternalUserPrincipal)itUsers.next();
                        if (user.getFullPath().compareToIgnoreCase(fullPath) == 0)
                        {
                            // User is member of the group
                            return principal.getRemotePrincipals();
                        }
                    }
                }
            } 
        }
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.