Skip to content

Commit

Permalink
Gestion des réponses CAS XML EsupPortail#184
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisersly committed Oct 4, 2024
1 parent 1143d20 commit c72790c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/esup_portail/esup_stage/bootstrap/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Properties;

public class AppConfig {
private String casResponseType;
private String casUrlLogin;
private String casUrlLogout;
private String casUrlService;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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 + "'" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}

Expand Down

0 comments on commit c72790c

Please sign in to comment.