Examples of SSOPrincipal


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;
   
    if ( ssoSite.getPrincipals() != null)
    {
      Iterator itPrincipals = ssoSite.getPrincipals().iterator();
      while (itPrincipals.hasNext() && principal == null)
      {
        SSOPrincipal tmp  = (SSOPrincipal)itPrincipals.next();
        if (      tmp != null
               && tmp.getFullPath().compareToIgnoreCase(fullPath) == 0
               && tmp.getSiteID() == ssoSite.getSiteId())
          principal = tmp;  // Found existing entry
      }
    }
   
    return principal;
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOPrincipal

  }
 
  private SSOPrincipal getSSOPrincipa(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

    if (site.getPrincipals() != null)
    {
      Iterator itPrincipals = site.getPrincipals().iterator();
      while (itPrincipals.hasNext())
      {
        SSOPrincipal tmp = (SSOPrincipal)itPrincipals.next();
        if (         tmp.getFullPath().compareToIgnoreCase(fullPath) == 0
                && tmp.getSiteID() == site.getSiteId())
        {
          // Found -- get the remotePrincipal
          Collection collRemotePrincipals = tmp.getRemotePrincipals() ;
          if (collRemotePrincipals != null)
          {
         
            Iterator itRemotePrincipals = collRemotePrincipals.iterator();
            if  (itRemotePrincipals.hasNext())
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOPrincipal

          return null;
     
      Iterator itPrincipalsForSite = principalsForSite.iterator();
      while (itPrincipalsForSite.hasNext())
      {
          SSOPrincipal principal = (SSOPrincipal)itPrincipalsForSite.next();
          if ( principal.getFullPath().compareToIgnoreCase(fullPath) == 0)
              return principal.getRemotePrincipals();
      }
      return null;
  }
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
      Criteria remoteUserFilter = new Criteria();
      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

  public void removeCredentialsForSite(Subject subject, String site)
      throws SSOException {
   
    // Initailization
    InternalUserPrincipal remotePrincipal = null;
    SSOPrincipal principal = null;
   
    //Get the site
    SSOSite ssoSite = getSSOSiteObject(site);
    if (ssoSite == null)
    {
View Full Code Here

Examples of org.apache.jetspeed.sso.SSOPrincipal

      return null// No principals for this site
   
    Iterator ixPrincipals = principals.iterator();
    while (ixPrincipals.hasNext())
    {
      SSOPrincipal principal = (SSOPrincipal)ixPrincipals.next();
      if (         principal != null
              && principal.getFullPath().compareToIgnoreCase(fullPath) == 0 )
      {
        // Found Principal -- extract remote principals
        return principal.getRemotePrincipals();
      }
    }
   
    // Principal is not in list
    return null;
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
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.