1919package ubic .gemma .core .security .authorization .acl ;
2020
2121import gemma .gsec .acl .BaseAclAdvice ;
22+ import gemma .gsec .acl .ObjectTransientnessRetrievalStrategy ;
23+ import gemma .gsec .acl .ParentIdentityRetrievalStrategy ;
2224import gemma .gsec .acl .domain .AclService ;
23- import gemma .gsec .model .GroupAuthority ;
2425import gemma .gsec .model .Securable ;
2526import gemma .gsec .model .User ;
2627import gemma .gsec .model .UserGroup ;
2728import org .apache .commons .logging .Log ;
2829import org .apache .commons .logging .LogFactory ;
2930import org .hibernate .SessionFactory ;
3031import org .springframework .beans .factory .annotation .Autowired ;
31- import org .springframework .security .acls .model .*;
32- import org .springframework .security .core .GrantedAuthority ;
33- import org .springframework .security .core .authority .SimpleGrantedAuthority ;
32+ import org .springframework .security .acls .model .ObjectIdentityRetrievalStrategy ;
3433import org .springframework .stereotype .Component ;
3534import ubic .gemma .model .analysis .Investigation ;
36- import ubic .gemma .model .analysis .SingleExperimentAnalysis ;
3735import ubic .gemma .model .common .auditAndSecurity .AuditTrail ;
3836import ubic .gemma .model .common .auditAndSecurity .curation .CurationDetails ;
3937import ubic .gemma .model .expression .arrayDesign .ArrayDesign ;
4038import ubic .gemma .model .expression .bioAssay .BioAssay ;
41- import ubic .gemma .model .expression .experiment .BioAssaySet ;
4239import ubic .gemma .model .expression .experiment .ExpressionExperiment ;
4340import ubic .gemma .persistence .util .Pointcuts ;
4441
45- import javax .annotation .Nullable ;
46- import java .util .Collection ;
47-
4842/**
4943 * For permissions modification to be triggered, the method name must match certain patterns, which include "create", or
5044 * "remove". These patterns are defined in the {@link Pointcuts}. Other methods that would require
@@ -58,14 +52,17 @@ public class AclAdvice extends BaseAclAdvice {
5852 private static final Log log = LogFactory .getLog ( AclAdvice .class );
5953
6054 @ Autowired
61- public AclAdvice ( AclService aclService , SessionFactory sessionFactory , ObjectIdentityRetrievalStrategy objectIdentityRetrievalStrategy ) {
62- super ( aclService , sessionFactory , objectIdentityRetrievalStrategy );
55+ public AclAdvice ( AclService aclService , SessionFactory sessionFactory ,
56+ ObjectIdentityRetrievalStrategy objectIdentityRetrievalStrategy ,
57+ ParentIdentityRetrievalStrategy parentIdentityRetrievalStrategy ,
58+ ObjectTransientnessRetrievalStrategy objectTransientnessRetrievalStrategy ) {
59+ super ( aclService , sessionFactory , objectIdentityRetrievalStrategy , parentIdentityRetrievalStrategy ,
60+ objectTransientnessRetrievalStrategy );
6361 }
6462
6563 @ Override
6664 protected boolean canSkipAclCheck ( Object object ) {
67- return AuditTrail .class .isAssignableFrom ( object .getClass () ) || CurationDetails .class
68- .isAssignableFrom ( object .getClass () );
65+ return object instanceof AuditTrail || object instanceof CurationDetails ;
6966 }
7067
7168 @ Override
@@ -75,7 +72,7 @@ protected boolean canSkipAssociationCheck( Object object, String propertyName )
7572 * If this is an expression experiment, don't go down the data vectors - it has no securable associations and
7673 * would be expensive to traverse.
7774 */
78- if ( ExpressionExperiment . class . isAssignableFrom ( object . getClass () )
75+ if ( object instanceof ExpressionExperiment
7976 && ( propertyName .equals ( "rawExpressionDataVectors" )
8077 || propertyName .equals ( "processedExpressionDataVectors" )
8178 || propertyName .equals ( "singleCellExpressionDataVectors" ) ) ) {
@@ -87,7 +84,7 @@ protected boolean canSkipAssociationCheck( Object object, String propertyName )
8784 /*
8885 * Array design has some non (directly) securable associations that would be expensive to load
8986 */
90- if ( ArrayDesign . class . isAssignableFrom ( object . getClass () ) && propertyName .equals ( "compositeSequences" ) ) {
87+ if ( object instanceof ArrayDesign && propertyName .equals ( "compositeSequences" ) ) {
9188 if ( AclAdvice .log .isTraceEnabled () )
9289 AclAdvice .log .trace ( "Skipping checking acl on probes on " + object );
9390 return true ;
@@ -97,60 +94,13 @@ protected boolean canSkipAssociationCheck( Object object, String propertyName )
9794 }
9895
9996 @ Override
100- protected void createOrUpdateAclSpecialCases ( MutableAcl acl , @ Nullable Acl parentAcl , Sid sid , Securable object ) {
101-
102- // Treating Analyses as special case. It'll inherit ACL from ExpressionExperiment
103- // If aclParent is passed to this method we overwrite it.
104- if ( SingleExperimentAnalysis .class .isAssignableFrom ( object .getClass () ) ) {
105- SingleExperimentAnalysis <?> experimentAnalysis = ( SingleExperimentAnalysis <?> ) object ;
106-
107- BioAssaySet bioAssaySet = experimentAnalysis .getExperimentAnalyzed ();
108- ObjectIdentity oi_temp = this .makeObjectIdentity ( bioAssaySet );
109-
110- parentAcl = this .getAclService ().readAclById ( oi_temp );
111- if ( parentAcl == null ) {
112- // This is possible if making an EESubSet is part of the transaction.
113- parentAcl = this .getAclService ().createAcl ( oi_temp );
114- }
115- acl .setEntriesInheriting ( true );
116- acl .setParent ( parentAcl );
117- //noinspection UnusedAssignment //Owner of the experiment owns analyses even if administrator ran them.
118- sid = parentAcl .getOwner ();
119- }
120-
121- }
122-
123- @ Override
124- protected GrantedAuthority getUserGroupGrantedAuthority ( Securable object ) {
125- Collection <? extends GroupAuthority > authorities = ( ( UserGroup ) object ).getAuthorities ();
126- assert authorities .size () == 1 ;
127- return new SimpleGrantedAuthority ( authorities .iterator ().next ().getAuthority () );
128- }
129-
130- @ Override
131- protected String getUserName ( Securable user ) {
132- return ( ( User ) user ).getUserName ();
133- }
134-
135- @ Override
136- protected boolean objectIsUser ( Securable object ) {
137- return User .class .isAssignableFrom ( object .getClass () );
138- }
139-
140- @ Override
141- protected boolean objectIsUserGroup ( Securable object ) {
142- return UserGroup .class .isAssignableFrom ( object .getClass () );
143- }
144-
145- @ Override
146- protected boolean specialCaseForAssociationFollow ( Object object , String property ) {
147- return BioAssay .class .isAssignableFrom ( object .getClass () ) && ( property .equals ( "sampleUsed" ) || property
148- .equals ( "arrayDesignUsed" ) );
97+ protected boolean canFollowAssociation ( Object object , String property ) {
98+ return object instanceof BioAssay && ( property .equals ( "sampleUsed" ) || property .equals ( "arrayDesignUsed" ) );
14999 }
150100
151101 @ Override
152- protected boolean specialCaseToKeepPrivateOnCreation ( Securable object ) {
153- return super .specialCaseToKeepPrivateOnCreation ( object )
102+ protected boolean isKeepPrivateOnCreation ( Securable object ) {
103+ return super .isKeepPrivateOnCreation ( object )
154104 || object instanceof UserGroup
155105 || object instanceof User
156106 || object instanceof Investigation ;
0 commit comments