Package org.apache.jetspeed.security.om

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


    public void removePermission(Permission permission) throws SecurityException
    {
        ArgUtil.notNull(new Object[] { permission }, new String[] { "permission" },
                "removePermission(java.security.Permission)");

        InternalPermission internalPermission = getInternalPermission(permission);
        if (null != internalPermission)
        {
            // clear the whole ThreadLocal permissions cache
            permissionsCache.set(null);
            try
View Full Code Here


                throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(principal.getName()));
            }
            // must/should be GroupPrincipal
            throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(principal.getName()));
        }
        InternalPermission internalPermission = getInternalPermission(permission);
        if (null == internalPermission)
        {
            throw new SecurityException(SecurityException.PERMISSION_DOES_NOT_EXIST.create(permission.getName()));
        }
View Full Code Here

     * @see org.apache.jetspeed.security.PermissionManager#permissionExists(java.security.Permission)
     */
    public boolean permissionExists(Permission permission)
    {
        boolean permissionExists = true;
        InternalPermission internalPermission = getInternalPermission(permission);
        if (null == internalPermission)
        {
            permissionExists = false;
        }
        return permissionExists;
View Full Code Here

                boolean revokePermission = false;
                ArrayList newInternalPermissions = new ArrayList();
                Iterator internalPermissionsIter = internalPermissions.iterator();
                while (internalPermissionsIter.hasNext())
                {
                    InternalPermission internalPermission = (InternalPermission) internalPermissionsIter.next();
                    if (!((internalPermission.getClassname().equals(permission.getClass().getName()))
                            && (internalPermission.getName().equals(permission.getName())) && (internalPermission.getActions()
                            .equals(permission.getActions()))))
                    {
                        newInternalPermissions.add(internalPermission);
                    }
                    else
View Full Code Here

        Criteria filter = new Criteria();
        filter.addEqualTo("classname", permission.getClass().getName());
        filter.addEqualTo("name", permission.getName());
        filter.addEqualTo("actions", permission.getActions());
        Query query = QueryFactory.newQuery(InternalPermissionImpl.class, filter);
        InternalPermission internalPermission = (InternalPermission) getPersistenceBrokerTemplate().getObjectByQuery(query);
        return internalPermission;
    }
View Full Code Here

        Iterator iter = internalPermissions.iterator();
        try
        {
            while (iter.hasNext())
            {
                InternalPermission internalPermission = (InternalPermission)iter.next();
                Class permissionClass = Class.forName(internalPermission.getClassname());
                Class[] parameterTypes = { String.class, String.class };
                Constructor permissionConstructor = permissionClass.getConstructor(parameterTypes);
                Object[] initArgs = { internalPermission.getName(), internalPermission.getActions() };
                Permission permission = (Permission) permissionConstructor.newInstance(initArgs);           
                permissions.add(permission);
            }
        }
        catch (Exception e)
View Full Code Here

   
    public int updatePermission(Permission permission, Collection principals)
    throws SecurityException
    {
        int count = 0;
        InternalPermission internal = getInternalPermission(permission);
        Iterator iter = principals.iterator();
        Collection newPrincipals = new LinkedList();
        while (iter.hasNext())
        {
            Principal principal = (Principal)iter.next();
            String fullPath = SecurityHelper.getPreferencesFullPath(principal);
            InternalPrincipal internalPrincipal = getInternalPrincipal(fullPath);
            newPrincipals.add(internalPrincipal);           
        }
        internal.setPrincipals(newPrincipals);
        internal.setModifiedDate(new Timestamp(System.currentTimeMillis()));
        try
        {           
            getPersistenceBrokerTemplate().store(internal);           
        }
        catch (Exception e)
View Full Code Here

    }
   
    public Collection getPrincipals(Permission permission)
    {
        Collection result = new LinkedList();       
        InternalPermission internalPermission = this.getInternalPermission(permission);
        if (internalPermission == null)
        {
            return result;
        }
        Iterator principals = internalPermission.getPrincipals().iterator();
        while (principals.hasNext())
        {
            InternalPrincipal internalPrincipal = (InternalPrincipal)principals.next();           
            Principal principal =
                SecurityHelper.createPrincipalFromFullPath(internalPrincipal.getFullPath());
View Full Code Here

    public boolean equals(Object object)
    { 
        if (!(object instanceof InternalPermission))
            return false;

        InternalPermission p = (InternalPermission) object;
        boolean isEqual =
            ((p.getClassname().equals(this.getClassname())) && (p.getName().equals(this.getName())) && (p.getActions().equals(this.getActions())));
        return isEqual;
    }
View Full Code Here

    private Permissions appendSecurityPermissions(Collection omPermissions, Permissions permissions)
    {    
        Iterator internalPermissionsIter = omPermissions.iterator();
        while (internalPermissionsIter.hasNext())
        {
            InternalPermission internalPermission = (InternalPermission) internalPermissionsIter.next();
            Permission permission = null;
            try
            {
                Class permissionClass = Class.forName(internalPermission.getClassname());
                Class[] parameterTypes = { String.class, String.class };
                Constructor permissionConstructor = permissionClass.getConstructor(parameterTypes);
                Object[] initArgs = { internalPermission.getName(), internalPermission.getActions() };
                permission = (Permission) permissionConstructor.newInstance(initArgs);
                if(!Collections.list(permissions.elements()).contains(permission))
                {
                    permissions.add(permission);
                }
View Full Code Here

TOP

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

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.