Mentions légales du service

Skip to content
Snippets Groups Projects
Commit f08e43af authored by Cédric Eoche-Duval's avatar Cédric Eoche-Duval
Browse files

[TLS-236]

git-svn-id: https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/gazelle-proxy/trunk@48813 356b4b1a-1d2b-0410-8bf1-ffa24008f01e
parent 13db783d
No related branches found
No related tags found
No related merge requests found
package net.ihe.gazelle.proxy.admin.gui;
import net.ihe.gazelle.proxy.admin.model.ApplicationConfiguration;
import org.jboss.seam.Component;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.security.Identity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.Remove;
/**
* This class contains the methods to access common applications preferences.
*
* @author Cédric Eoche-Duval / KEREVAL Rennes IHE development Project
* @version 1.0 - 2015, October 23th
* @class AbstractApplicationConfigurationManager.java
* @package net.ihe.gazelle.proxy.admin.gui
*/
public abstract class AbstractApplicationConfigurationManager<T> {
private static Logger log = LoggerFactory.getLogger(AbstractApplicationConfigurationManager.class);
private String releaseNoteUrl;
private String documentation;
private Boolean worksWithoutCas;
private String issueTracker;
private String evsClientUrl;
private String dicomStorage;
private String applicationUrl;
private String proxyOid;
private Boolean ipLogin;
private String ipLoginAdmin;
@Remove
@Destroy
public void destroy() {
resetApplicationConfiguration();
}
public void resetApplicationConfiguration() {
releaseNoteUrl = null;
documentation = null;
worksWithoutCas = null;
issueTracker = null;
evsClientUrl = null;
dicomStorage = null;
applicationUrl = null;
proxyOid = null;
ipLogin = null;
ipLoginAdmin = null;
}
protected String getApplicationProperty(String inPropertyKey) {
String value = ApplicationConfiguration.getValueOfVariable(inPropertyKey);
if (value == null) {
AbstractApplicationConfigurationManager.log.warn(
inPropertyKey + " variable is missing in app_configuration table");
}
return value;
}
public String getReleaseNoteUrl() {
if (releaseNoteUrl == null) {
releaseNoteUrl = getApplicationProperty("application_release_notes_url");
}
return releaseNoteUrl;
}
public String getIssueTracker() {
if (issueTracker == null) {
issueTracker = getApplicationProperty("application_issue_tracker");
}
return issueTracker;
}
public String getDocumentation() {
if (this.documentation == null) {
this.documentation = getApplicationProperty("application_documentation");
}
if (this.documentation == null) {
this.documentation = "http://gazelle.ihe.net";
}
return this.documentation;
}
public boolean isWorksWithoutCas() {
if (worksWithoutCas == null) {
String booleanAsString = getApplicationProperty("application_works_without_cas");
if (booleanAsString == null) {
this.worksWithoutCas = false;
} else {
this.worksWithoutCas = Boolean.valueOf(booleanAsString);
}
}
return worksWithoutCas;
}
/**
* Returns true if the logged in user has role "admin_role" or if the
* application works without cas
*
* @return
*/
public boolean isUserAllowedAsAdmin() {
return Identity.instance().isLoggedIn() && Identity.instance().hasRole("admin_role");
}
public String getEvsClientUrl() {
if (evsClientUrl == null) {
evsClientUrl = getApplicationProperty("evs_client_url");
}
return evsClientUrl;
}
public String getDicomStorage() {
if (dicomStorage == null) {
dicomStorage = getApplicationProperty("storage_dicom");
}
return dicomStorage;
}
public String getApplicationUrl() {
if (applicationUrl == null) {
applicationUrl = getApplicationProperty("application_url");
}
return applicationUrl;
}
public String getProxyOid() {
if (proxyOid == null) {
proxyOid = getApplicationProperty("proxy_oid");
}
return proxyOid;
}
public Boolean getIpLogin() {
if (ipLogin == null) {
String booleanAsString = ApplicationConfiguration.getValueOfVariable("ip_login");
if (booleanAsString == null) {
this.ipLogin = false;
} else {
this.ipLogin = Boolean.valueOf(booleanAsString);
}
}
return ipLogin;
}
public String getIpLoginAdmin() {
if (this.ipLoginAdmin == null) {
this.ipLoginAdmin = ApplicationConfiguration.getValueOfVariable("ip_login_admin");
}
return ipLoginAdmin;
}
public String loginByIP() {
AbstractApplicationConfigurationManager.log.info("starting authentication without cas");
Identity identity = (Identity) Component.getInstance("org.jboss.seam.security.identity");
if ("loggedIn".equals(identity.login())) {
return "/home.xhtml";
} else {
return null;
}
}
}
......@@ -35,10 +35,10 @@ import org.slf4j.LoggerFactory;
/**
* <b>Class Description : </b>ApplicationConfigurationManager<br>
* <br>
* This class contains the methods which are called in the footer modal panels
* This class contains the methods to access common applications preferences and specific proxy preferences
*
* @author Anne-Gaëlle Bergé / INRIA Rennes IHE development Project
* @version 1.0 - 2010, October 15th
* @version 2.0 - 2015, October 23th, (by Cédric Eoche-Duval)
* @class ApplicationConfigurationManager.java
* @package net.ihe.gazelle.simulator.common.action
* @see > Anne-Gaelle.Berge@inria.fr - http://www.ihe-europe.org
......@@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory;
@AutoCreate
@Scope(ScopeType.APPLICATION)
@GenerateInterface("ApplicationConfigurationManagerLocal")
public class ApplicationConfigurationManager implements Serializable, ApplicationConfigurationManagerLocal {
public class ApplicationConfigurationManager extends AbstractApplicationConfigurationManager<ApplicationConfigurationManager> implements Serializable, ApplicationConfigurationManagerLocal {
/**
*
......@@ -56,20 +56,10 @@ public class ApplicationConfigurationManager implements Serializable, Applicatio
private static final long serialVersionUID = -7817765881624341837L;
private static Logger log = LoggerFactory.getLogger(ApplicationConfigurationManager.class);
private String releaseNoteUrl;
private String documentation;
private Boolean worksWithoutCas;
private String issueTracker;
private String evsClientUrl;
private String dicomStorage;
private String proxyIpAddresses;
private Integer minProxyPort;
private Integer maxProxyPort;
private String applicationUrl;
private String casUrl;
private String proxyOid;
private Boolean ipLogin;
private String ipLoginAdmin;
@Remove
@Destroy
......@@ -78,94 +68,17 @@ public class ApplicationConfigurationManager implements Serializable, Applicatio
}
public void resetApplicationConfiguration() {
releaseNoteUrl = null;
documentation = null;
worksWithoutCas = null;
issueTracker = null;
evsClientUrl = null;
dicomStorage = null;
super.resetApplicationConfiguration();
proxyIpAddresses = null;
maxProxyPort = null;
minProxyPort = null;
casUrl = null;
applicationUrl = null;
proxyOid = null;
ipLogin = null;
ipLoginAdmin = null;
}
private String getApplicationProperty(String inPropertyKey) {
String value = ApplicationConfiguration.getValueOfVariable(inPropertyKey);
if (value == null) {
log.warn(inPropertyKey + " variable is missing in app_configuration table");
}
return value;
}
public String getReleaseNoteUrl() {
if (releaseNoteUrl == null) {
releaseNoteUrl = getApplicationProperty("application_release_notes_url");
}
return releaseNoteUrl;
}
public String getIssueTracker() {
if (issueTracker == null) {
issueTracker = getApplicationProperty("application_issue_tracker");
}
return issueTracker;
}
public String getDocumentation() {
if (this.documentation == null) {
this.documentation = getApplicationProperty("application_documentation");
}
if (this.documentation == null) {
this.documentation = "http://gazelle.ihe.net";
}
return this.documentation;
}
public boolean isWorksWithoutCas() {
if (worksWithoutCas == null) {
String booleanAsString = getApplicationProperty("application_works_without_cas");
if (booleanAsString == null) {
this.worksWithoutCas = false;
} else {
this.worksWithoutCas = Boolean.valueOf(booleanAsString);
}
}
return worksWithoutCas;
}
/**
* Returns true if the logged in user has role "admin_role" or if the
* application works without cas
*
* @return
*/
public boolean isUserAllowedAsAdmin() {
return Identity.instance().isLoggedIn() && Identity.instance().hasRole("admin_role");
}
public static ApplicationConfigurationManager instance() {
return (ApplicationConfigurationManager) Component.getInstance("applicationConfigurationManager");
}
public String getEvsClientUrl() {
if (evsClientUrl == null) {
evsClientUrl = getApplicationProperty("evs_client_url");
}
return evsClientUrl;
}
public String getDicomStorage() {
if (dicomStorage == null) {
dicomStorage = getApplicationProperty("storage_dicom");
}
return dicomStorage;
}
public String getProxyIpAddresses() {
if (proxyIpAddresses == null) {
proxyIpAddresses = getApplicationProperty("proxy_ip_addresses");
......@@ -198,13 +111,6 @@ public class ApplicationConfigurationManager implements Serializable, Applicatio
return maxProxyPort;
}
public String getApplicationUrl() {
if (applicationUrl == null) {
applicationUrl = getApplicationProperty("application_url");
}
return applicationUrl;
}
public String getCasUrl() {
if (casUrl == null) {
casUrl = getApplicationProperty("cas_url");
......@@ -212,39 +118,4 @@ public class ApplicationConfigurationManager implements Serializable, Applicatio
return casUrl;
}
public String getProxyOid() {
if (proxyOid == null) {
proxyOid = getApplicationProperty("proxy_oid");
}
return proxyOid;
}
public Boolean getIpLogin() {
if (ipLogin == null) {
String booleanAsString = ApplicationConfiguration.getValueOfVariable("ip_login");
if (booleanAsString == null) {
this.ipLogin = false;
} else {
this.ipLogin = Boolean.valueOf(booleanAsString);
}
}
return ipLogin;
}
public String getIpLoginAdmin() {
if (this.ipLoginAdmin == null) {
this.ipLoginAdmin = ApplicationConfiguration.getValueOfVariable("ip_login_admin");
}
return ipLoginAdmin;
}
public String loginByIP() {
log.info("starting authentication without cas");
Identity identity = (Identity) Component.getInstance("org.jboss.seam.security.identity");
if ("loggedIn".equals(identity.login())) {
return "/home.xhtml";
} else {
return null;
}
}
}
......@@ -54,12 +54,12 @@ public class AuthenticationFilter extends AbstractCasFilter {
private GatewayResolver gatewayStorage = new DefaultGatewayResolverImpl();
private boolean isCASEnabled = false;
protected boolean isCASEnabled = false;
/**
* The URL to the CAS Server login.
*/
private String casServerLoginUrl;
protected String casServerLoginUrl;
public AuthenticationFilter() {
super();
......@@ -83,7 +83,7 @@ public class AuthenticationFilter extends AbstractCasFilter {
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
reloadParameters();
reloadParameters(servletRequest);
if (isCASEnabled) {
doFilterCAS(servletRequest, servletResponse, filterChain);
} else {
......@@ -91,7 +91,7 @@ public class AuthenticationFilter extends AbstractCasFilter {
}
}
private void reloadParameters() {
protected void reloadParameters(ServletRequest servletRequest) {
// Create a seam context if needed
boolean createContexts = !Contexts.isEventContextActive() && !Contexts.isApplicationContextActive();
if (createContexts) {
......
......@@ -60,8 +60,8 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractCasFilter
private boolean exceptionOnValidationFailure;
private boolean useSession;
private boolean isCASEnabled = false;
private String casServerLoginUrl;
protected boolean isCASEnabled = false;
protected String casServerLoginUrl;
public Cas20ProxyReceivingTicketValidationFilter() {
super();
......@@ -87,7 +87,7 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractCasFilter
setTicketValidator(createValidator());
}
private Cas20ServiceTicketValidator createValidator() {
protected Cas20ServiceTicketValidator createValidator() {
Cas20ServiceTicketValidator validator = new Cas20ServiceTicketValidator(casServerLoginUrl);
validator.setProxyCallbackUrl(null);
validator.setProxyGrantingTicketStorage(proxyGrantingTicketStorage);
......@@ -162,7 +162,7 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractCasFilter
protected void onFailedValidation(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) {
}
private void reloadParameters() {
protected void reloadParameters(ServletRequest servletRequest) {
// Create a seam context if needed
boolean createContexts = !Contexts.isEventContextActive() && !Contexts.isApplicationContextActive();
if (createContexts) {
......@@ -184,7 +184,7 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractCasFilter
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
reloadParameters();
reloadParameters(servletRequest);
if (isCASEnabled) {
doFilterCAS(servletRequest, servletResponse, filterChain);
} else {
......
......@@ -18,7 +18,7 @@
<dependency>
<groupId>net.ihe.gazelle.simulators</groupId>
<artifactId>simulator-common-war</artifactId>
<version>4.0.6-SNAPSHOT</version>
<version>4.0.7-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
......@@ -26,7 +26,6 @@
<artifactId>gazelle-seam-tools-war</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>net.ihe.gazelle.maven</groupId>
<artifactId>gazelle-tools</artifactId>
<version>3.0.4-SNAPSHOT</version>
<version>3.0.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment