Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 2a3dec70 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Fix authentication for cas

parent a97c91d3
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,6 @@ export class SecurityService { ...@@ -17,7 +17,6 @@ export class SecurityService {
private http: HttpClient, private http: HttpClient,
private alertService: AlertMessageService, private alertService: AlertMessageService,
private securityEventService: SecurityEventService, private securityEventService: SecurityEventService,
private lookups: GlobalLookups
) { ) {
this.securityEventService.onLogoutSuccessEvent().subscribe(() => window.location.reload()); this.securityEventService.onLogoutSuccessEvent().subscribe(() => window.location.reload());
this.securityEventService.onLogoutErrorEvent().subscribe((error) => this.alertService.error(error)); this.securityEventService.onLogoutErrorEvent().subscribe((error) => this.alertService.error(error));
......
...@@ -9,6 +9,7 @@ import eu.europa.ec.edelivery.smp.services.ServiceGroupService; ...@@ -9,6 +9,7 @@ import eu.europa.ec.edelivery.smp.services.ServiceGroupService;
import eu.europa.ec.edelivery.smp.utils.SessionSecurityUtils; import eu.europa.ec.edelivery.smp.utils.SessionSecurityUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.cas.authentication.CasAuthenticationToken;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.session.SessionAuthenticationException; import org.springframework.security.web.authentication.session.SessionAuthenticationException;
...@@ -91,7 +92,7 @@ public class SMPAuthorizationService { ...@@ -91,7 +92,7 @@ public class SMPAuthorizationService {
return userRO; return userRO;
} }
private SMPAuthenticationToken getSessionAuthentication() { private Authentication getSessionAuthentication() {
if (SecurityContextHolder.getContext() == null) { if (SecurityContextHolder.getContext() == null) {
LOG.warn("No users is logged-in! Session security context is null!"); LOG.warn("No users is logged-in! Session security context is null!");
return null; return null;
...@@ -101,15 +102,16 @@ public class SMPAuthorizationService { ...@@ -101,15 +102,16 @@ public class SMPAuthorizationService {
LOG.warn("No users is logged-in! Authentication is null or not authenticated!"); LOG.warn("No users is logged-in! Authentication is null or not authenticated!");
return null; return null;
} }
if (!(authentication instanceof SMPAuthenticationToken)) { if (!(authentication instanceof SMPAuthenticationToken
|| authentication instanceof CasAuthenticationToken)) {
LOG.warn("User is logged and authenticated with not supported Authentication [{}]!", authentication.getClass()); LOG.warn("User is logged and authenticated with not supported Authentication [{}]!", authentication.getClass());
return null; return null;
} }
return (SMPAuthenticationToken) authentication; return authentication;
} }
private SMPAuthenticationToken getAndValidateSessionAuthentication() { private Authentication getAndValidateSessionAuthentication() {
SMPAuthenticationToken authentication = getSessionAuthentication(); Authentication authentication = getSessionAuthentication();
if (authentication == null) { if (authentication == null) {
throw new SessionAuthenticationException(ERR_INVALID_OR_NULL); throw new SessionAuthenticationException(ERR_INVALID_OR_NULL);
} }
......
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