Package org.apache.jetspeed.security.om

Examples of org.apache.jetspeed.security.om.InternalUserPrincipal


      Vector temp = new Vector();
     
      Iterator itRemotePrincipal = ssoPrincipal.getRemotePrincipals().iterator();
      while (itRemotePrincipal.hasNext())
      {
        InternalUserPrincipal rp  = (InternalUserPrincipal)itRemotePrincipal.next();
        if (rp != null)
        {
          temp.add(rp.getFullPath());
        }
      }
     
      if (temp.size() > 0)
      {
View Full Code Here


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

      {
          // Check if the the current user has a credential for the site
   
      // 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);
     
      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 principal information
      //remotePrincipal.setFullPath("/sso/" + ssoSite.getSiteId() + "/user/"+ principalName + "/" + remoteUser);
     
      InternalCredential credential = (InternalCredential)remotePrincipal.getCredentials().iterator().next();
         
      // New credential object
       if ( credential != null)
        // Remove credential and principal from mapping
         credential.setValue(this.scramble(pwd));
View Full Code Here

   * returns the credentials for a given user
   */
  private SSOContext  getCredential(SSOSite ssoSite, String fullPath)
  {
    InternalCredential credential = null;
    InternalUserPrincipal remotePrincipal = null;
    //  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 )
        return null// no entry
   
    Collection remoteForPrincipals = getRemotePrincipalsForPrincipal(principalsForSite, fullPath);
       
    if ( remoteForPrincipals == null)
        return null// no entry
   
    // Get remote Principal that matches the site and the principal
    if ((remotePrincipal = findRemoteMatch(remoteForPrincipals, remoteForSite)) == null )
    {
        return null// No entry
    }
    else
    {
        // Has an entry
      if ( remotePrincipal.getCredentials() != null)
        credential = (InternalCredential)remotePrincipal.getCredentials().iterator().next();
     
      // Error checking  -- should have a credential at this point
      if ( credential == null)
      {
//        System.out.println("Warning: Remote User " + remotePrincipal.getFullPath() + " doesn't have a credential");
        return null;
      }
    }
   
    //  Create new context
    String name = stripPrincipalName(remotePrincipal.getFullPath());
   
    SSOContext context = new SSOContextImpl(credential.getPrincipalId(), name, this.unscramble(credential.getValue()));
   
    return context;
  }
View Full Code Here

  {
      // Iterate over the lists and find match
      Iterator itRemoteForPrincipals = remoteForPrincipals.iterator();
      while ( itRemoteForPrincipals.hasNext())
      {
          InternalUserPrincipal remoteForPrincipal = (InternalUserPrincipal)itRemoteForPrincipals.next();
         
          // Find a match in the site list
          Iterator itRemoteForSite = remoteForSite.iterator();
        while ( itRemoteForSite.hasNext())
        {
            InternalUserPrincipal tmp = (InternalUserPrincipal)itRemoteForSite.next();
           
            if ( tmp.getPrincipalId() == remoteForPrincipal.getPrincipalId() )
                return remoteForPrincipal;
        }
      }
      // No match found
      return null;
View Full Code Here

                {
                  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

    {
        List list = new ArrayList();
        Iterator principals = site.getRemotePrincipals().iterator();
        while (principals.hasNext())
        {
            InternalUserPrincipal remotePrincipal = (InternalUserPrincipal)principals.next();
            Iterator creds = remotePrincipal.getCredentials().iterator();
            while (creds.hasNext())
            {
                InternalCredential cred = (InternalCredential) creds.next();
                SSOContext context = new SSOContextImpl(remotePrincipal.getPrincipalId(),
                                                stripPrincipalName(remotePrincipal.getFullPath()),
                                                cred.getValue(),
                                                stripPortalPrincipalName(remotePrincipal.getFullPath()));
                list.add(context);
            }
        }
        return list;
    }
View Full Code Here

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

      Vector temp = new Vector();
     
      Iterator itRemotePrincipal = ssoPrincipal.getRemotePrincipals().iterator();
      while (itRemotePrincipal.hasNext())
      {
        InternalUserPrincipal rp  = (InternalUserPrincipal)itRemotePrincipal.next();
        if (rp != null)
        {
          temp.add(rp.getFullPath());
        }
      }
     
      if (temp.size() > 0)
      {
View Full Code Here

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

TOP

Related Classes of org.apache.jetspeed.security.om.InternalUserPrincipal

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.