Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.

Ticket #379: 379.patch

File 379.patch, 18.5 KB (added by jmoore, 17 years ago)
  • components/dsl/resources/ome/dsl/data.vm

     
    11begin; 
    22set constraints all deferred; 
    33 
    4 insert into experimenter (id,version,omename,firstname,lastname) 
    5         values (0,0,'root','root','root'); 
    6 insert into event (id,time,status,experimenter) values (0,now(),'BOOTSTRAP',0); 
     4insert into experimenter (id,permissions,version,omename,firstname,lastname) 
     5        values (0,0,0,'root','root','root'); 
     6insert into event (id,permissions,time,status,experimenter) values (0,0,now(),'BOOTSTRAP',0); 
    77insert into experimentergroup (id,permissions,version,owner_id,group_id,creation_id,update_id,name) 
    88        values (0,-35,0,0,0,0,0,'system'); 
    99insert into experimentergroup (id,permissions,version,owner_id,group_id,creation_id,update_id,name) 
  • components/dsl/resources/ome/dsl/mapping.vm

     
    1010<!DOCTYPE hibernate-mapping PUBLIC 
    1111    "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
    1212    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > 
    13      
     13 
    1414<hibernate-mapping> 
    1515#if($type.superclass)<joined-subclass 
    1616#else<class 
    1717#end 
    18     name="${type.id}"  
     18    name="${type.id}" 
    1919    table="${type.table}" 
    2020    abstract="$type.abstract" 
    2121    select-before-update="true" 
     
    3232          public final static String OWNER_FILTER = "${ofilter}"; 
    3333          public final static String GROUP_FILTER = "${gfilter}"; 
    3434          public final static String EVENT_FILTER = "${efilter}"; 
    35           public final static String PERMS_FILTER = "${pfilter}";   
     35          public final static String PERMS_FILTER = "${pfilter}"; 
    3636#foreach( $prop in $type.properties) 
    3737#if($prop.one2Many) 
    3838#set( $UC_NAME = "${prop.name.toUpperCase()}") 
     
    4444#end 
    4545        </meta> 
    4646#end 
    47         <meta attribute="class-code">  
     47        <meta attribute="class-code"> 
    4848/* These values are defined in dsl/resources/ome/dsl/mapping.vm: 
    4949 * ------------------------------------------------------------- 
    5050 * Explanation of serialVersionUID ex 0000000 03 00 00 01 03 01 L; 
     
    5555 * 14-15 : release type   (M) 
    5656 * 16-17 : release number (2) 
    5757 * 18-19 : increment per delta // any changes to the dsl or mapping files 
    58  */  
    59           private static final long serialVersionUID = 0000000030000010301L;                      
     58 */ 
     59          private static final long serialVersionUID = 0000000030000010301L; 
    6060        </meta> 
    6161## 
    6262## INTERFACES: 
     
    7272#set( $name_idx = ${type.id.lastIndexOf(".")} ) 
    7373#set( $name_idx = ${name_idx} + 1 ) 
    7474#set( $name_max = ${type.id.length()} ) 
    75 #set( $name_end = ${type.id.substring($name_idx,$name_max)} )  
     75#set( $name_end = ${type.id.substring($name_idx,$name_max)} ) 
    7676        public $name_end (String value) { 
    7777          setValue(value); 
    7878        } 
     
    8585#foreach( $prop in $type.properties) 
    8686#if($prop.class.name == "ome.dsl.LinkParent") 
    8787        <meta attribute="link-parent">$prop.type</meta> 
    88 #elseif($prop.class.name == "ome.dsl.LinkChild")  
    89         <meta attribute="link-child">$prop.type</meta>   
     88#elseif($prop.class.name == "ome.dsl.LinkChild") 
     89        <meta attribute="link-child">$prop.type</meta> 
    9090#end 
    9191#end 
    9292#end 
     
    9595         COMMON 
    9696     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> 
    9797#####################################################################INHERITANCE 
    98 #if(!$type.superclass)  
     98#if(!$type.superclass) 
    9999        <id name="id" type="java.lang.Long" column="id"> 
    100             <meta attribute="setter-scope">protected</meta>         
     100            <meta attribute="setter-scope">protected</meta> 
    101101            <meta attribute="field-description"> 
    102102              The DB unique identifier for this object. You are not responsible for 
    103               setting the id; however, it can be useful for creating "unloaded"  
    104               versions of your objects.             
     103              setting the id; however, it can be useful for creating "unloaded" 
     104              versions of your objects. 
    105105            </meta> 
    106106            <generator class="sequence"> 
    107107                <param name="sequence">seq_${type.table}</param> 
     
    110110 
    111111#* 
    112112#if(!$type.immutable) 
    113         <version name="version" type="java.lang.Integer"  
     113        <version name="version" type="java.lang.Integer" 
    114114                column="version" unsaved-value="negative"> 
    115115            <meta attribute="setter-scope">protected</meta> 
    116116            <meta attribute="field-description"> 
    117117              This version number is controlled by the database for optimisitic 
    118118              locking. 
    119119            </meta> 
    120         </version>            
     120        </version> 
    121121#end 
    122122*# 
    123123 
    124124        <component name="details" class="ome.model.internal.Details"> 
    125125            <meta attribute="field-description"> 
    126               The details of this object correspond to low-level system  
    127               information. Owner, permissions,  
    128             </meta>         
     126              The details of this object correspond to low-level system 
     127              information. Owner, permissions, 
     128            </meta> 
    129129            <meta attribute="default-value">new Details()</meta> 
    130 #if(!$type.global)       
    131             <many-to-one name="owner" class="ome.model.meta.Experimenter"  
     130#if(!$type.global) 
     131            <many-to-one name="owner" class="ome.model.meta.Experimenter" 
    132132                column="owner_id" not-null="true" cascade="$cascade_settings"/> 
    133             <many-to-one name="group" class="ome.model.meta.ExperimenterGroup"  
     133            <many-to-one name="group" class="ome.model.meta.ExperimenterGroup" 
    134134                column="group_id" not-null="true" cascade="$cascade_settings"/> 
    135135            <!-- creationEvent is not updateable --> 
    136             <many-to-one name="creationEvent" class="ome.model.meta.Event"  
     136            <many-to-one name="creationEvent" class="ome.model.meta.Event" 
    137137                column="creation_id" update="false" 
    138                 not-null="true" cascade="$cascade_settings"/>            
     138                not-null="true" cascade="$cascade_settings"/> 
    139139#if(!$type.immutable) 
    140             <many-to-one name="updateEvent" class="ome.model.meta.Event"  
     140            <many-to-one name="updateEvent" class="ome.model.meta.Event" 
    141141                column="update_id" update="true" 
    142                 not-null="true" cascade="$cascade_settings"/>                    
     142                not-null="true" cascade="$cascade_settings"/> 
    143143#end 
     144#end 
    144145            <component name="permissions" class="ome.model.internal.Permissions"> 
    145146                <!-- meta is ignored. We control Details --> 
    146147                                <meta attribute="default-value">new Permissions(Permissions.DEFAULT)</meta> 
    147                 <property name="perm1" not-null="true"  
    148                     type="long" column="permissions"/>  
     148                <property name="perm1" not-null="true" 
     149                    type="long" column="permissions"/> 
    149150                <!-- TODO possibly just default CHMOD here --> 
    150151            </component> 
    151 #end 
    152152                        <!-- Even global objects can have external info --> 
    153153            <many-to-one name="externalInfo" class="ome.model.meta.ExternalInfo" 
    154154                column="external_id" not-null="false" unique="true" 
    155155                cascade="$cascade_settings,delete"/> 
    156156        </component> 
    157          
     157 
    158158#else ###############################################################INHERITANCE 
    159159#set($superId = ${type.typeToColumn($type.superclass)} ) 
    160160        <key column="${superId}_id"/> 
    161 #end  
     161#end 
    162162#####################################################################INHERITANCE 
    163163<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    164164         INTERFACE-BASED 
     
    173173#end 
    174174 
    175175#if($type.named) 
    176         <property name="name" type="java.lang.String"  
     176        <property name="name" type="java.lang.String" 
    177177                column="name" not-null="true" length="256"/> 
    178178#end 
    179179 
    180180#if($type.described) 
    181         <property name="description" type="text"  
     181        <property name="description" type="text" 
    182182                column="description" length="256"/> 
    183183#end 
    184          
     184 
    185185<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    186186         SPECIFIC 
    187187     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> 
     
    191191#if($prop.class.name == "ome.dsl.EntryField") #############################TYPE 
    192192## This is handled by ome/dsl/data.vm 
    193193###########################################################################TYPE 
    194 #elseif($prop.one2Many && $prop.tag)  
     194#elseif($prop.one2Many && $prop.tag) 
    195195 
    196196    <one-to-one 
    197197        name="${prop.name}" 
     
    201201        lazy="false" 
    202202      > 
    203203      <meta attribute="scope-set">protected</meta> 
    204       <formula>'true'</formula>  
     204      <formula>'true'</formula> 
    205205      <formula>id</formula> 
    206206    </one-to-one> 
    207207 
     
    234234        inverse="true" 
    235235#if($prop.class.name == "ome.dsl.ChildLink" ) 
    236236        cascade="all-delete-orphan"> 
    237         <meta attribute="link-add-method">${prop.target}</meta>         
    238         <meta attribute="link-add-order">this,addition</meta>                                 
     237        <meta attribute="link-add-method">${prop.target}</meta> 
     238        <meta attribute="link-add-order">this,addition</meta> 
    239239        <meta attribute="link-add-next">parent</meta> 
    240         <meta attribute="link-add-other">child</meta>         
    241 #elseif($prop.class.name == "ome.dsl.ParentLink")          
     240        <meta attribute="link-add-other">child</meta> 
     241#elseif($prop.class.name == "ome.dsl.ParentLink") 
    242242        cascade="all-delete-orphan"> 
    243         <meta attribute="link-add-method">${prop.target}</meta>         
     243        <meta attribute="link-add-method">${prop.target}</meta> 
    244244        <meta attribute="link-add-order">addition,this</meta> 
    245         <meta attribute="link-add-next">child</meta>                   
    246         <meta attribute="link-add-other">parent</meta>                       
     245        <meta attribute="link-add-next">child</meta> 
     246        <meta attribute="link-add-other">parent</meta> 
    247247#else 
    248248        cascade="$cascade_settings"> 
    249         <meta attribute="set-add-method">${prop.inverse}</meta>         
     249        <meta attribute="set-add-method">${prop.inverse}</meta> 
    250250#end 
    251251        <key column="${prop.foreignKey}" not-null="${prop.required}"/> 
    252252        <one-to-many class="${prop.type}"/> 
     
    258258        <filter name="${pfilter}_${UC_NAME}" condition=":permsStr = permissions"/> 
    259259#end 
    260260    </set> 
    261      
     261 
    262262#end ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ORDERED 
    263263#elseif($prop.foreignKey) ## REGULAR M-1 ##################################TYPE 
    264264 
     
    266266#if($prop.tag) 
    267267    <properties name="${prop.tag}Tag"> 
    268268    <property name="${prop.tag}" type="java.lang.Boolean"/> 
    269 #end     
     269#end 
    270270    <many-to-one 
    271271        name="${prop.name}" 
    272272        class="${prop.type}" 
     
    275275        unique="${prop.unique}" 
    276276        cascade="$cascade_settings" 
    277277        insert="${prop.insert}" 
    278         update="${prop.update}"         
     278        update="${prop.update}" 
    279279     > 
    280280 
    281 #if($prop.class.name == "ome.dsl.LinkParent" || $prop.class.name == "ome.dsl.LinkChild")  
     281#if($prop.class.name == "ome.dsl.LinkParent" || $prop.class.name == "ome.dsl.LinkChild") 
    282282           <meta attribute="property-type">IObject</meta> 
    283283#elseif($prop.inverse && $prop.tag) 
    284284           <meta attribute="WORKAROUND">${prop.inverse}</meta> 
     
    292292 
    293293#else ## REGULAR PROPERTY #################################################TYPE 
    294294 
    295     <property name="${prop.name}" type="${prop.type}"  
    296         not-null="${prop.required}" unique="${prop.unique}"  
     295    <property name="${prop.name}" type="${prop.type}" 
     296        not-null="${prop.required}" unique="${prop.unique}" 
    297297        update="${prop.update}" 
    298298     /> 
    299299 
     
    316316  <filter-def name="${ofilter}"> 
    317317    <filter-param type="java.lang.Long" name="ownerId"/> 
    318318  </filter-def> 
    319    
     319 
    320320  <filter-def name="${gfilter}"> 
    321321    <filter-param type="java.lang.Long" name="groupId"/> 
    322322  </filter-def> 
    323    
     323 
    324324  <filter-def name="${efilter}"> 
    325         <filter-param type="java.lang.Long" name="eventId"/>   
     325        <filter-param type="java.lang.Long" name="eventId"/> 
    326326  </filter-def> 
    327    
     327 
    328328  <filter-def name="${pfilter}"> 
    329329    <filter-param type="java.lang.String" name="permsStr"/> 
    330330  </filter-def> 
    331    
     331 
    332332#foreach( $prop in $type.properties ) 
    333333#if($prop.one2Many) 
    334334#set( $UC_NAME = "${prop.name.toUpperCase()}") 
    335335  <filter-def name="${ofilter}_${UC_NAME}"> 
    336336    <filter-param type="java.lang.Long" name="ownerId"/> 
    337337  </filter-def> 
    338    
     338 
    339339  <filter-def name="${gfilter}_${UC_NAME}"> 
    340340    <filter-param type="java.lang.Long" name="groupId"/> 
    341341  </filter-def> 
    342    
     342 
    343343  <filter-def name="${efilter}_${UC_NAME}"> 
    344         <filter-param type="java.lang.Long" name="eventId"/>   
     344        <filter-param type="java.lang.Long" name="eventId"/> 
    345345  </filter-def> 
    346    
     346 
    347347  <filter-def name="${pfilter}_${UC_NAME}"> 
    348348    <filter-param type="java.lang.String" name="permsStr"/> 
    349349  </filter-def> 
  • components/server/src/ome/services/util/OmeroAroundInvoke.java

     
    5858    private transient BeanHelper beanHelper = new BeanHelper(this.getClass()); 
    5959     
    6060    /** Interceptors that are determinined at compile time by server/build.xml 
    61      *  The REPLACE token will be replaced with a (possibly) empty comma- 
     61     *  The string "ome.security.basic.BasicSecurityWiring" may be replaced by a 
    6262     *  comma separated list of strings representing the class names of  
    6363     *  HardWiredInterceptor subclasses which are prepended to the list of 
    6464     *  interceptors for each call. Note: these interceptors will NOT be applied 
    6565     *  to server internal calls. 
    6666     */ 
    6767    private final static List<HardWiredInterceptor> CPTORS = HardWiredInterceptor 
    68             .parse(new String[] { /* @REPLACE@ */}); 
     68            .parse(new String[] { "ome.security.basic.BasicSecurityWiring"}); 
    6969 
    7070    private transient Log logger = LogFactory.getLog(this.getClass()); 
    7171 
     
    114114    protected final Object loginAndSpringWrap(InvocationContext context) 
    115115            throws Exception { 
    116116        try { 
    117             login(); 
    118117            return call(context); 
    119118        } catch (Throwable t) { 
    120119            throw beanHelper.translateException(t); 
    121         } finally { 
    122             logout(); 
    123120        } 
    124121 
    125122    } 
    126123 
    127     private void login() { 
    128         Principal p; 
    129         if (sessionContext.getCallerPrincipal() instanceof Principal) { 
    130             p = (Principal) sessionContext.getCallerPrincipal(); 
    131             securitySystem.login(p); 
    132             if (logger.isDebugEnabled()) { 
    133                 logger.debug("Running with user: " + p.getName()); 
    134             } 
    135         } else { 
    136             throw new ApiUsageException( 
    137                     "ome.system.Principal instance must be provided on login."); 
    138         } 
    139  
    140     } 
    141  
    142     private void logout() { 
    143         securitySystem.logout(); 
    144     } 
    145  
    146124    private Object call(InvocationContext context) throws Throwable { 
    147125 
    148126        Object bean = context.getBean(); 
  • components/server/src/ome/security/JBossLoginModule.java

     
    88package ome.security; 
    99 
    1010// Java imports 
     11import java.security.Principal; 
     12 
    1113import javax.security.auth.login.LoginException; 
    1214 
    1315// Third-party libraries 
     
    1820/** 
    1921 * configured in jboss-login.xml to add logic to the JBoss authentication 
    2022 * procedure. 
    21  *  
     23 * 
    2224 * Specifically, we override {@link #validatePassword(String, String)} here in 
    2325 * order to interpret empty string passwords as "open", i.e. any password will 
    2426 * be accepted. This eases entry into the system in that passwords can be 
    2527 * initially ignored. 
    26  *  
     28 * 
    2729 * @author Josh Moore &nbsp;&nbsp;&nbsp;&nbsp; <a 
    2830 *         href="mailto:josh.moore@gmx.de">josh.moore@gmx.de</a> 
    2931 * @version 1.0 <small> (<b>Internal version:</b> $Rev$ $Date$) </small> 
     
    5658                : expectedPassword.trim()); 
    5759    } 
    5860 
     61    @Override 
     62    public boolean login() throws LoginException { 
     63        // TODO Auto-generated method stub 
     64        boolean b = super.login(); 
     65        if (!b) { 
     66            Object username = sharedState.get("javax.security.auth.login.name"); 
     67            Object password = sharedState.get("javax.security.auth.login.password"); 
     68            System.err.println("Login failed:"+username+"//"+password); 
     69        } 
     70        return b; 
     71    } 
     72 
    5973} 
  • components/server/src/ome/security/basic/CurrentDetails.java

     
    3939 * user must be set (the creation of a new user is only allowed if the current 
    4040 * user is set to root; root always exists. QED.) The event must also be set. 
    4141 * Umask is optional. 
    42  *  
     42 * 
    4343 * This information is stored in a Details object, but unlike Details which 
    4444 * assumes that an empty value signifies increased security levels, empty values 
    4545 * here signifiy reduced security levels. E.g., 
    46  *  
     46 * 
    4747 * Details: user == null ==> object belongs to root CurrentDetails: user == null 
    4848 * ==> current user is "nobody" (anonymous) 
    49  *  
     49 * 
    5050 */ 
    5151class CurrentDetails { 
    5252    private static Log log = LogFactory.getLog(CurrentDetails.class); 
     
    106106        l.setEntityType(klass.getName()); // TODO could be id to Type entity 
    107107        l.setEntityId(id); 
    108108        l.setEvent(getCreationEvent()); 
     109        Details d = new Details(); 
     110        d.setPermissions(new Permissions()); 
     111        l.setDetails(d); 
    109112        list.add(l); 
    110113    } 
    111114 
  • components/server/src/ome/security/basic/BasicSecurityWiring.java

     
    11/* 
    22 *   $Id$ 
    33 * 
    4  *   Copyright 2006 University of Dundee. All rights reserved. 
     4 *   Copyright 2007 Glencoe Software, Inc. All rights reserved. 
    55 *   Use is subject to license terms supplied in LICENSE.txt 
    66 */ 
    77 
    8 package ome.services.icy.fire; 
     8package ome.security.basic; 
    99 
    1010import ome.conditions.ApiUsageException; 
    1111import ome.logic.HardWiredInterceptor; 
     
    6060        securitySystem.logout(); 
    6161    } 
    6262 
    63 } 
    64  No newline at end of file 
     63} 

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.23140 sec.)

We're Hiring!