Package org.apache.jetspeed.security

Examples of org.apache.jetspeed.security.SecurityException


  public User getUser(String username) throws SecurityException
  {
      User user = (User)getPrincipal(username);
      if (null == user)
      {
          throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, username));
      }
      return user;
  }
View Full Code Here


                "addRole(java.lang.String)");

        // Check if role already exists.
        if (roleExists(roleFullPathName))
        {
            throw new SecurityException(SecurityException.ROLE_ALREADY_EXISTS.create(roleFullPathName));
        }

        RolePrincipal rolePrincipal = new RolePrincipalImpl(roleFullPathName);
        String fullPath = rolePrincipal.getFullPath();
        // Add the preferences.
        Preferences preferences = Preferences.userRoot().node(fullPath);
        if (log.isDebugEnabled())
        {
            log.debug("Added role preferences node: " + fullPath);
        }
        try
        {
            if ((null != preferences) && preferences.absolutePath().equals(fullPath))
            {
                // Add role principal.
                roleSecurityHandler.setRolePrincipal(rolePrincipal);
                if (log.isDebugEnabled())
                {
                    log.debug("Added role: " + fullPath);
                }
            }
        }
        catch (SecurityException se)
        {
            KeyedMessage msg =
                SecurityException.UNEXPECTED.create("RoleManager.addRole",
                                                    "RoleSecurityHandler.setRolePrincipal("+rolePrincipal.getName()+")",
                                                    se.getMessage());
            log.error(msg, se);

            // Remove the preferences node.
            try
            {
                preferences.removeNode();
            }
            catch (BackingStoreException bse)
            {
                bse.printStackTrace();
            }
            throw new SecurityException(msg, se);
        }
    }
View Full Code Here

                KeyedMessage msg =
                    SecurityException.UNEXPECTED.create("RoleManager.removeRole",
                                                        "RoleSecurityHandler.removeRolePrincipal("+RolePrincipalImpl.getPrincipalNameFromFullPath((String) roles[i])+")",
                                                        e.getMessage());
                log.error(msg, e);
                throw new SecurityException(msg, e);
            }
            // Remove preferences
            Preferences rolePref = Preferences.userRoot().node((String) roles[i]);
            try
            {
                rolePref.removeNode();
            }
            catch (BackingStoreException bse)
            {
                KeyedMessage msg =
                    SecurityException.UNEXPECTED.create("RoleManager.removeRole",
                                                        "Preferences.removeNode("+roles[i]+")",
                                                        bse.getMessage());
                log.error(msg, bse);
                throw new SecurityException(msg, bse);
            }
        }
    }
View Full Code Here

        String fullPath = RolePrincipalImpl.getFullPathFromPrincipalName(roleFullPathName);

        Principal rolePrincipal = roleSecurityHandler.getRolePrincipal(roleFullPathName);
        if (null == rolePrincipal)
        {
            throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(roleFullPathName));
        }
        Preferences preferences = Preferences.userRoot().node(fullPath);
        Role role = new RoleImpl(rolePrincipal, preferences);
        return role;
    }
View Full Code Here

        // Get the role principal to add to user.
        Principal rolePrincipal = roleSecurityHandler.getRolePrincipal(roleFullPathName);
        if (null == rolePrincipal)
        {
            throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(roleFullPathName));
        }
        // Check that user exists.
        Principal userPrincipal = atnProviderProxy.getUserPrincipal(username);
        if (null == userPrincipal)
        {
            throw new SecurityException(SecurityException.USER_DOES_NOT_EXIST.create(username));
        }
        // Get the user roles.
        Set rolePrincipals = securityMappingHandler.getRolePrincipals(username);
        // Add role to user.
        if (!rolePrincipals.contains(rolePrincipal))
View Full Code Here

        // Check that user exists.
        Principal userPrincipal = atnProviderProxy.getUserPrincipal(username);
        if (null == userPrincipal)
        {
            throw new SecurityException(SecurityException.USER_DOES_NOT_EXIST.create(username));
        }
        // Get the role principal to remove.
        Principal rolePrincipal = roleSecurityHandler.getRolePrincipal(roleFullPathName);
        if (null != rolePrincipal)
        {
View Full Code Here

        // Get the role principal to add to group.
        Principal rolePrincipal = roleSecurityHandler.getRolePrincipal(roleFullPathName);
        if (null == rolePrincipal)
        {
            throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(roleFullPathName));
        }
        securityMappingHandler.setRolePrincipalInGroup(groupFullPathName, roleFullPathName);
    }
View Full Code Here

    public void setPassword(String userName, String oldPassword, String newPassword) throws SecurityException
    {
        InternalUserPrincipal internalUser = securityAccess.getInternalUserPrincipal(userName, false);
        if (null == internalUser)
        {
            throw new SecurityException(SecurityException.USER_DOES_NOT_EXIST.create(userName));
        }
       
        Collection credentials = internalUser.getCredentials();
        if (null == credentials)
        {
View Full Code Here

                securityAccess.setInternalUserPrincipal(internalUser, false);
            }
        }
        else
        {
            throw new SecurityException(SecurityException.USER_DOES_NOT_EXIST.create(userName));
        }
    }
View Full Code Here

                securityAccess.setInternalUserPrincipal(internalUser, false);
            }
        }
        else
        {
            throw new SecurityException(SecurityException.USER_DOES_NOT_EXIST.create(userName));
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.security.SecurityException

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.