Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding cleaning filter when authentication is changed (MID-6897)
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/MidpointSecurityContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2010-2019 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.web.security; | ||
|
||
import com.evolveum.midpoint.model.api.authentication.MidpointAuthentication; | ||
|
||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContext; | ||
|
||
/** | ||
* @author skublik | ||
*/ | ||
|
||
public class MidpointSecurityContext implements SecurityContext { | ||
|
||
private SecurityContext securityContext; | ||
private RemoveUnusedSecurityFilterPublisher publisher; | ||
|
||
public MidpointSecurityContext (SecurityContext securityContext, RemoveUnusedSecurityFilterPublisher publisher) { | ||
this.securityContext = securityContext; | ||
this.publisher = publisher; | ||
} | ||
|
||
@Override | ||
public Authentication getAuthentication() { | ||
return securityContext.getAuthentication(); | ||
} | ||
|
||
@Override | ||
public void setAuthentication(Authentication authentication) { | ||
if (getAuthentication() instanceof MidpointAuthentication | ||
&& !getAuthentication().equals(authentication)) { | ||
publisher.publishCustomEvent((MidpointAuthentication) getAuthentication()); | ||
} | ||
securityContext.setAuthentication(authentication); | ||
} | ||
} |