import java.lang.reflect.Method;
import java.lang.reflect.Type;
+import org.springframework.security.core.context.SecurityContext;
+
import eu.etaxonomy.cdm.api.service.ICommonService;
import eu.etaxonomy.cdm.api.service.IService;
import eu.etaxonomy.cdm.api.service.ITestService;
private ICdmDataChangeService dataChangeService;
+ private SecurityContext securityContext;
+
+
public static CdmApplicationState getInstance() {
if(cdmApplicationState == null) {
cdmApplicationState = new CdmApplicationState();
getInstance().setDataChangeService(dataChangeService);
}
+
+
+ /**
+ * @return the securityContext
+ */
+ public SecurityContext getSecurityContext() {
+ return securityContext;
+ }
+
+ /**
+ * @param securityContext the securityContext to set
+ */
+ public void setSecurityContext(SecurityContext securityContext) {
+ this.securityContext = securityContext;
+ }
+
+ /**
+ * @return the securityContext
+ */
+ public static SecurityContext getCurrentSecurityContext() {
+ return getInstance().getSecurityContext();
+ }
+
+ /**
+ * @param securityContext the securityContext to set
+ */
+ public static void setCurrentSecurityContext(SecurityContext securityContext) {
+ getInstance().setSecurityContext(securityContext);
+ }
+
public static void dispose() {
getInstance().setCurrentDataChangeService(null);
getInstance().setAppConfig(null);
+ getInstance().setSecurityContext(null);
}
+
/**
* Generic method that will scan the getters of {@link ICdmApplicationConfiguration} for the given service
* interface. If a matching getter is found the according service implementation is returned by
return service;
}
+
/**
* @see #getService(Class)
* As ICommonService is not extending IService we need a specific request here
import org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor;
import org.springframework.remoting.httpinvoker.HttpInvokerClientConfiguration;
import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.context.SecurityContext;
+
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
/**
* @author cmathew
protected PostMethod createPostMethod(HttpInvokerClientConfiguration config) throws IOException {
PostMethod postMethod = super.createPostMethod(config);
- Authentication auth =
- SecurityContextHolder.getContext().getAuthentication();
-
- if ((auth != null) && (auth.getName() != null) &&
- (auth.getCredentials() != null)) {
- String base64 = auth.getName() + ":" + auth.getCredentials().toString();
- postMethod.setRequestHeader("Authorization", "Basic " +
- new String(Base64.encodeBase64(base64.getBytes())));
+ SecurityContext securityContext = CdmApplicationState.getCurrentSecurityContext();
+ if(securityContext != null) {
+ Authentication auth = securityContext.getAuthentication();
+ if ((auth != null) && (auth.getName() != null) &&
+ (auth.getCredentials() != null)) {
+ String base64 = auth.getName() + ":" + auth.getCredentials().toString();
+ postMethod.setRequestHeader("Authorization", "Basic " +
+ new String(Base64.encodeBase64(base64.getBytes())));
+ }
}
-
return postMethod;
}
}
\ No newline at end of file
</filter>
<filter class="org.apache.log4j.filter.ExpressionFilter">
<param name="expression"
- value="msg like '.*[net.sf.ehcache.pool.sizeof.SizeOf] - The configured limit of.*'" />
+ value="msg like '.*object references was reached while attempting to calculate the size of the object graph.*'" />
<param name="acceptOnMatch" value="false" />
</filter>
</appender>
<!-- name="org.hibernate.collection.internal.AbstractPersistentCollection"> -->
<!-- <level value="info" /> -->
<!-- </logger> -->
- <logger
- name="eu.etaxonomy.taxeditor.service.CdmServiceRequestExecutor">
- <level value="info" />
- </logger>
+<!-- <logger -->
+<!-- name="eu.etaxonomy.taxeditor.service.CdmServiceRequestExecutor"> -->
+<!-- <level value="info" /> -->
+<!-- </logger> -->
</log4j:configuration>
\ No newline at end of file
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.model.common.Group;
try{
SecurityContextHolder.clearContext();
-
Authentication lastAuthentication = CdmStore.getCurrentAuthentiation();
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password);
authentication = new UsernamePasswordAuthenticationToken(user,password, authentication.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
+ CdmApplicationState.setCurrentSecurityContext(SecurityContextHolder.getContext());
if(!authentication.equals(lastAuthentication)){
this.setChanged();