diff --git a/README.md b/README.md index 4718ddc7..b734834b 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,14 @@ Par exemple si `appli.data_dir=/etc/eStage/uploads` on aura : |_/signatures ``` +## CAS + +Par défaut, l'application attend du serveur CAS une réponse au format JSON. Si le serveur CAS répond au format XML, +il faut ajouter la ligne suivante au fichier `estage.properties` : +```properties +cas.response_type=xml +``` + ## Signature électronique (optionnel) La signature électronique est activée si au moins une des configuration ci-dessous est paramétrée. Si plusieurs solutions configurées, Docaposte prendra le dessus. diff --git a/src/main/java/org/esup_portail/esup_stage/bootstrap/AppConfig.java b/src/main/java/org/esup_portail/esup_stage/bootstrap/AppConfig.java index 487dac3f..b4c3abab 100644 --- a/src/main/java/org/esup_portail/esup_stage/bootstrap/AppConfig.java +++ b/src/main/java/org/esup_portail/esup_stage/bootstrap/AppConfig.java @@ -9,6 +9,7 @@ import java.util.Properties; public class AppConfig { + private String casResponseType; private String casUrlLogin; private String casUrlLogout; private String casUrlService; @@ -48,6 +49,14 @@ public class AppConfig { private String esupSignatureUri; private AppSignatureEnum appSignatureEnabled; + public String getCasResponseType() { + return casResponseType; + } + + public void setCasResponseType(String casResponseType) { + this.casResponseType = casResponseType; + } + public String getCasUrlLogin() { return casUrlLogin; } @@ -353,6 +362,11 @@ public void setAppSignatureEnabled(AppSignatureEnum appSignatureEnabled) { } public void initProperties(Properties props, String prefixeProps) { + if (props.containsKey("cas.response_type") && !Strings.isEmpty(props.getProperty("cas.response_type"))) { + this.casResponseType = props.getProperty("cas.response_type"); + } else { + this.casResponseType = "json"; + } this.casUrlLogout = props.getProperty("cas.url.logout"); this.casUrlLogin = props.getProperty("cas.url.login"); this.casUrlService = props.getProperty("cas.url.service"); @@ -435,6 +449,7 @@ public void initProperties(Properties props, String prefixeProps) { @Override public String toString() { return "AppConfig{" + + ", casResponseType='" + casResponseType + "'" + ", casUrlLogin='" + casUrlLogin + "'" + ", casUrlLogout='" + casUrlLogout + "'" + ", casUrlService='" + casUrlService + "'" + diff --git a/src/main/java/org/esup_portail/esup_stage/config/SecurityConfiguration.java b/src/main/java/org/esup_portail/esup_stage/config/SecurityConfiguration.java index eff92537..9c2b7a26 100644 --- a/src/main/java/org/esup_portail/esup_stage/config/SecurityConfiguration.java +++ b/src/main/java/org/esup_portail/esup_stage/config/SecurityConfiguration.java @@ -4,6 +4,7 @@ import org.esup_portail.esup_stage.security.userdetails.CasUserDetailsServiceImpl; import org.jasig.cas.client.session.SingleSignOutFilter; import org.jasig.cas.client.validation.TicketValidator; +import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; import org.jasig.cas.client.validation.json.Cas30JsonServiceTicketValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -49,6 +50,10 @@ public AuthenticationEntryPoint casEntryPoint() { @Bean public TicketValidator ticketValidator() { + + if (applicationBootstrap.getAppConfig().getCasResponseType().equals("xml")) { + return new Cas20ServiceTicketValidator(applicationBootstrap.getAppConfig().getCasUrlService()); + } return new Cas30JsonServiceTicketValidator(applicationBootstrap.getAppConfig().getCasUrlService()); }