Changeset 1025
- Timestamp:
- 10/09/06 19:05:53 (2 years ago)
- Location:
- trunk/components/server/src/ome
- Files:
-
- 6 modified
-
logic/AbstractBean.java (modified) (3 diffs)
-
security/basic/BasicSecuritySystem.java (modified) (1 diff)
-
security/basic/CurrentDetails.java (modified) (1 diff)
-
security/basic/EventHandler.java (modified) (5 diffs)
-
services/RawPixelsBean.java (modified) (2 diffs)
-
services/RenderingBean.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/server/src/ome/logic/AbstractBean.java
r903 r1025 50 50 import ome.security.SecuritySystem; 51 51 import ome.services.query.QueryFactory; 52 import ome.system.EventContext; 52 53 import ome.system.OmeroContext; 53 54 import ome.system.Principal; … … 82 83 private @Resource SessionContext sessionContext; 83 84 85 protected boolean contextLoaded = true; // always true for stateless services. 86 84 87 // ~ Lifecycle implementations 85 88 // ========================================================================= … … 109 112 (ProxyFactoryBean) applicationContext.getBean(factoryName), 110 113 context ); 114 if (!contextLoaded) 115 { 116 adapter.getUserAttributes().put( EventContext.class, Boolean.TRUE ); 117 contextLoaded = true; 118 } 111 119 return adapter.proceed( ); 112 120 } catch (Throwable t) { -
trunk/components/server/src/ome/security/basic/BasicSecuritySystem.java
r1006 r1025 1013 1013 { 1014 1014 final Principal p = clearAndCheckPrincipal(); 1015 throw new UnsupportedOperationException("not implemented."); 1015 1016 if ( ! (context instanceof BasicEventContext) ) 1017 throw new ApiUsageException( "BasicSecuritySystem can only accept " + 1018 "BasicEventContext instances."); 1019 1020 final BasicEventContext bec = (BasicEventContext) context; 1021 final String u_name = bec.getCurrentUserName(); 1022 final String g_name = bec.getCurrentGroupName(); 1023 final String t_name = bec.getCurrentEventType(); 1024 1025 if ( p.getName().equals( u_name ) && 1026 p.getGroup().equals( g_name ) && 1027 p.getEventType().equals( t_name )) 1028 { 1029 cd.setCurrentEventContext( bec ); 1030 } 1031 1032 else 1033 { 1034 throw new InternalException(String.format( 1035 "Principal:%s/%s/%s does not match Context:%s/%s/%s", 1036 p.getName(),p.getGroup(),p.getEventType(), 1037 u_name,g_name,t_name)); 1038 } 1016 1039 } 1017 1040 -
trunk/components/server/src/ome/security/basic/CurrentDetails.java
r992 r1025 96 96 return data.get(); 97 97 } 98 99 void setCurrentEventContext( BasicEventContext bec ) 100 { 101 data.set( bec ); 102 } 98 103 99 104 private Details getDetails() -
trunk/components/server/src/ome/security/basic/EventHandler.java
r992 r1025 58 58 import ome.model.meta.EventLog; 59 59 import ome.system.EventContext; 60 import ome.tools.spring.AOPAdapter; 60 61 61 62 /** … … 86 87 87 88 // for StatefulServices TODO 88 private Map< Session, Event> events= Collections89 .synchronizedMap(new WeakHashMap< Session, Event>());89 private Map<Object, EventContext> objCtxMap = Collections 90 .synchronizedMap(new WeakHashMap<Object, EventContext>()); 90 91 91 92 /** only public constructor, used for dependency injection. Requires an … … 113 114 { 114 115 boolean readOnly = checkReadOnly(arg0); 115 secSys.loadEventContext(readOnly); 116 // TODO check for an existing session here. 116 boolean stateful = StatefulServiceInterface.class.isAssignableFrom( 117 arg0.getThis().getClass()); 118 119 if ( stateful ) 120 { 121 EventContext prevCtx = objCtxMap.get( arg0.getThis() ); 122 boolean needCtx = false; 123 if ( arg0 instanceof AOPAdapter ) 124 { 125 // TODO needs refactoring. Perhaps better to add this to 126 // SecuritySystem. Or when OmeroContext is reworked, that this 127 // is added to that interface. 128 AOPAdapter adapter = (AOPAdapter) arg0; 129 Map attributes = adapter.getUserAttributes(); 130 if ( attributes != null ) 131 { 132 Object o = attributes.get( EventContext.class ); 133 if ( o instanceof Boolean && ((Boolean)o).booleanValue() ) 134 { 135 needCtx = true; 136 } 137 } 138 } 139 140 if ( null == prevCtx ) 141 { 142 if ( ! needCtx ) 143 { 144 throw new InternalException( 145 "Stateful service missing context." ); 146 } 147 148 else 149 { 150 secSys.loadEventContext(false); 151 objCtxMap.put( arg0.getThis(), secSys.getEventContext() ); 152 prevCtx = secSys.getEventContext(); 153 } 154 } 155 secSys.setEventContext( prevCtx ); 156 } 157 158 else // stateless 159 { 160 // this is usually done manually by stateful services 161 // in their @PostConstruct methods 162 secSys.loadEventContext(readOnly); 163 } 117 164 118 165 // now the user can be considered to be logged in. … … 134 181 } finally { 135 182 try { 136 137 boolean stateful = (arg0.getThis() instanceof StatefulServiceInterface);138 183 139 184 // on failure, we want to make sure that no one attempts … … 293 338 public Object doInHibernate(Session session) 294 339 throws HibernateException, SQLException { 295 if (session.isDirty()) 340 boolean dirty = session.isDirty(); 341 if (dirty) 296 342 { 297 343 throw new InternalException("Session is dirty. Cannot properly " + -
trunk/components/server/src/ome/services/RawPixelsBean.java
r903 r1025 100 100 } 101 101 102 public RawPixelsBean() 103 { 104 super.contextLoaded = false; 105 } 106 102 107 public final void setPixelsMetadata(IPixels metaService) 103 108 { … … 142 147 // ========================================================================= 143 148 144 @RolesAllowed("user") 149 @RolesAllowed("user") 145 150 public void setPixelsId( long pixelsId ) 146 151 { -
trunk/components/server/src/ome/services/RenderingBean.java
r1024 r1025 185 185 private transient ReentrantReadWriteLock rwl 186 186 = new ReentrantReadWriteLock(); 187 188 public RenderingBean() 189 { 190 super.contextLoaded = false; 191 } 187 192 188 193 /** set injector. For use during configuration. Can only be called once. */
