Changeset 4570

Show
Ignore:
Timestamp:
07/09/09 12:51:04 (8 months ago)
Author:
jmoore
Message:

SecuritySystem : Support for configurable permissions (ticket:1405)

It is now possible to set omero.security.default_permissions
at compile time (in source:trunk/etc/omero.properties) or via
OmeroConfig? (ticket:800) at runtime.

Location:
trunk
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/components/common/resources/ome/config.xml

    r3921 r4570  
    2828    on how this works. 
    2929    </description> 
     30 
     31    <bean id="permissionsContext" class="ome.system.PermissionsContext"> 
     32        <description> 
     33            Sets the value of the default permissions key based on the 
     34            PreferenceContext in the system properties to be loaded by 
     35            the ome.model.internal.Permissions class. 
     36        </description> 
     37        <constructor-arg ref="preferenceContext"/> 
     38    </bean> 
    3039 
    3140    <bean id="preferenceContext" class="ome.system.PreferenceContext"> 
  • trunk/components/model/src/ome/model/internal/Permissions.java

    r3486 r4570  
    11/* 
    2  * ome.model.internal.Permissions 
     2 *   $Id$ 
    33 * 
    44 *   Copyright 2006 University of Dundee. All rights reserved. 
     
    77package ome.model.internal; 
    88 
    9 // Java imports 
    109import java.io.IOException; 
    1110import java.io.ObjectInputStream; 
     
    1514import javax.persistence.Column; 
    1615 
    17 // Third-party libraries 
    18  
    19 // Application-internal dependencies 
    2016import ome.conditions.ApiUsageException; 
    2117import ome.model.IObject; 
     
    3531 * </p> 
    3632 *  
    37  * @see <a href="https://trac.openmicroscopy.org.uk/omero/ticket/180">ticket:180</a> 
     33 * @see <a 
     34 *      href="https://trac.openmicroscopy.org.uk/omero/ticket/180">ticket:180</a> 
    3835 */ 
    3936public class Permissions implements Serializable { 
     
    10299    /** 
    103100     * enumeration of flags which can be set on a {@link Permissions} instance. 
    104      * A {@link Flag#LOCKED} flag implies that the 
    105      * {@link Details#getOwner() owner}, {@link Details#getGroup() group}, and 
     101     * A {@link Flag#LOCKED} flag implies that the {@link Details#getOwner() 
     102     * owner}, {@link Details#getGroup() group}, and 
    106103     * {@link Details#getPermissions() permissions} for an {@link IObject} 
    107104     * instance may not be changed. {@link Flag#SOFT} implies that the given 
     
    186183 
    187184        Permissions p = new Permissions(EMPTY); 
    188         String regex = "([Rr_][Ww_]){3}"; 
     185        String regex = "([Rr_-][Ww_-]){3}"; 
    189186 
    190187        if (rwrwrw == null || !rwrwrw.matches(regex)) { 
     
    229226     * or empty rights are simply ignored. For example, <code> 
    230227     *   somePermissions().grant(USER,READ,WRITE,USE); 
    231      * </code> 
    232      * will guarantee that the current user has all rights on this entity. 
     228     * </code> will guarantee 
     229     * that the current user has all rights on this entity. 
    233230     */ 
    234231    public Permissions grant(Role role, Right... rights) { 
     
    245242     * or empty rights are simply ignored. For example, <code> 
    246243     *   new Permissions().revoke(WORLD,WRITE,USE); 
    247      * </code> 
    248      * will return a Permissions instance which cannot be altered or linked to 
    249      * by members of WORLD. 
     244     * </code> will return a 
     245     * Permissions instance which cannot be altered or linked to by members of 
     246     * WORLD. 
    250247     */ 
    251248    public Permissions revoke(Role role, Right... rights) { 
     
    264261     *   Permissions mask = new Permissions().grant(WORLD,READ); 
    265262     *   someEntity.getDetails().getPermissions().grantAllk(mask); 
    266      * </code> 
    267      * will allow READ access (and possibly more) to <code>someEntity</code> 
    268      * for members of WORLD. 
     263     * </code> will allow READ access (and possibly more) to 
     264     * <code>someEntity</code> for members of WORLD. 
    269265     */ 
    270266    public Permissions grantAll(Permissions mask) { 
     
    283279     *   Permissions mask = new Permissions().revoke(WORLD,READ,WRITE,USE); 
    284280     *   someEntity.getDetails().getPermissions().applyMask(mask); 
    285      * </code> 
    286      * will disallow all access to <code>someEntity</code> for members of 
    287      * WORLD. 
     281     * </code> will disallow all access to <code>someEntity</code> for members 
     282     * of WORLD. 
    288283     *  
    289284     * This also implies that applyMask can be used to make copies of 
    290285     * Permissions. For example, <code> 
    291286     *   new Permissions().applyMask( somePermissions ); 
    292      * </code> 
    293      * will produce a copy of <code>somePermissions</code>. 
     287     * </code> will produce a copy of 
     288     * <code>somePermissions</code>. 
    294289     *  
    295290     * Note: the logic here is different from Unix UMASKS. 
     
    366361 
    367362    /** 
    368      * two {@link Permissions} instances are <code>identical</code> if they 
    369      * have the same bit representation. 
     363     * two {@link Permissions} instances are <code>identical</code> if they have 
     364     * the same bit representation. 
    370365     *  
    371366     * @see <a 
     
    679674 
    680675    /** 
    681      * an immutable {@link Permissions} instance which is used as the default 
    682      * value in all persistent classes. It revokes {@link Right#WRITE} to both 
    683      * {@link Role#GROUP} and {@link Role#WORLD} 
    684      */ 
    685     public final static Permissions DEFAULT = USER_PRIVATE; 
    686  
    687     /** 
    688676     * an immutable {@link Permissions} instance with all {@link Right#WRITE} 
    689677     * rights turned off. Identical to {@link #WORLD_IMMUTABLE} 
     
    697685    public final static Permissions PUBLIC = WORLD_WRITEABLE; 
    698686 
     687    /** 
     688     * an immutable {@link Permissions} instance which is used as the default 
     689     * value in all persistent classes. It is initiall set to 
     690     * {@link #USER_PRIVATE}, but is reset from the 
     691     * {@link ome.system.PermissionsContext#KEY} configuration value which is set by 
     692     * default in etc/omero.properties. 
     693     */ 
     694    public/* final */static Permissions DEFAULT = USER_PRIVATE; 
     695 
     696    public static void setDefaultPermissions(String permissions) { 
     697        DEFAULT = new ImmutablePermissions(parseString(permissions)); 
     698    } 
     699 
    699700} 
  • trunk/components/model/test/ome/model/utests/PermissionsTest.java

    r1997 r4570  
    268268    public void testCompareWithString() throws Exception { 
    269269        assertTrue(Permissions.EMPTY.sameRights(Permissions 
     270                .parseString("------"))); 
     271        assertTrue(Permissions.EMPTY.sameRights(Permissions 
    270272                .parseString("______"))); 
    271273        assertTrue(Permissions.DEFAULT.sameRights(Permissions 
    272                 .parseString("rwr_r_"))); 
     274                .parseString("rw____"))); 
    273275        assertTrue(Permissions.GROUP_IMMUTABLE.sameRights(Permissions 
    274276                .parseString("r_r___"))); 
  • trunk/components/server/src/ome/services/sessions/SessionManagerImpl.java

    r4508 r4570  
    204204        s.setDefaultEventType(eventType); 
    205205        s.setDefaultPermissions(umask.toString()); 
    206         s.getDetails().setPermissions(Permissions.USER_PRIVATE); 
     206        s.getDetails().setPermissions(Permissions.DEFAULT); 
    207207    } 
    208208 
  • trunk/etc/omero.properties

    r4566 r4570  
    3131omero.security.filter.bitand=(int8and(permissions,%s) = %s) 
    3232omero.security.password_provider=chainedPasswordProvider 
     33omero.security.default_permissions=rw---- 
    3334 
    3435 

1.2.1-PRO © 2008-2009 agile42 all rights reserved (this page was served in: 0.97839 sec.)