forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KEYCLOAK-13633 Generalize GenericPrincipalFactory to PrincipleFactory
This allows to replace java.security.acl.Group usage only where necessary while keeping legacy adapter unchanged. Signed-off-by: Phillip Schichtel <[email protected]>
- Loading branch information
1 parent
52db229
commit f754b34
Showing
13 changed files
with
36 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 27,7 @@ | |
import org.jboss.security.SimpleGroup; | ||
import org.jboss.security.SimplePrincipal; | ||
import org.keycloak.adapters.spi.KeycloakAccount; | ||
import org.keycloak.adapters.tomcat.GenericPrincipalFactory; | ||
import org.keycloak.adapters.tomcat.PrincipalFactory; | ||
|
||
import javax.security.auth.Subject; | ||
import java.lang.reflect.Constructor; | ||
|
@@ -44,15 44,10 @@ | |
* @author <a href="mailto:[email protected]">Bill Burke</a> | ||
* @version $Revision: 1 $ | ||
*/ | ||
public class JBossWebPrincipalFactory extends GenericPrincipalFactory { | ||
public class JBossWebPrincipalFactory implements PrincipalFactory { | ||
|
||
private static Constructor jbossWebPrincipalConstructor = findJBossGenericPrincipalConstructor(); | ||
|
||
@Override | ||
protected GenericPrincipal createPrincipal(Principal userPrincipal, List<String> roles) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public GenericPrincipal createPrincipal(Realm realm, final Principal identity, final Set<String> roleSet) { | ||
KeycloakAccount account = new KeycloakAccount() { | ||
|
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -26,14 26,14 @@ | |
import org.keycloak.adapters.spi.SessionIdMapper; | ||
import org.keycloak.adapters.spi.SessionIdMapperUpdater; | ||
import org.keycloak.adapters.tomcat.CatalinaUserSessionManagement; | ||
import org.keycloak.adapters.tomcat.GenericPrincipalFactory; | ||
import org.keycloak.adapters.tomcat.PrincipalFactory; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Bill Burke</a> | ||
* @version $Revision: 1 $ | ||
*/ | ||
public class TomcatSamlSessionStore extends CatalinaSamlSessionStore { | ||
public TomcatSamlSessionStore(CatalinaUserSessionManagement sessionManagement, GenericPrincipalFactory principalFactory, SessionIdMapper idMapper, Request request, AbstractSamlAuthenticatorValve valve, HttpFacade facade, SamlDeployment deployment) { | ||
public TomcatSamlSessionStore(CatalinaUserSessionManagement sessionManagement, PrincipalFactory principalFactory, SessionIdMapper idMapper, Request request, AbstractSamlAuthenticatorValve valve, HttpFacade facade, SamlDeployment deployment) { | ||
super(sessionManagement, principalFactory, idMapper, SessionIdMapperUpdater.DIRECT, request, valve, facade, deployment); | ||
} | ||
|
||
|
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
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 |
---|---|---|
|
@@ -24,16 24,17 @@ | |
import java.security.Principal; | ||
import java.util.ArrayList; | ||
import java.util.Enumeration; | ||
import java.util.List; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Davide Ungari</a> | ||
* @version $Revision: 1 $ | ||
*/ | ||
public abstract class GenericPrincipalFactory { | ||
public abstract class GenericPrincipalFactory implements PrincipalFactory { | ||
|
||
@Override | ||
public GenericPrincipal createPrincipal(Realm realm, final Principal identity, final Set<String> roleSet) { | ||
Subject subject = new Subject(); | ||
Set<Principal> principals = subject.getPrincipals(); | ||
|
11 changes: 11 additions & 0 deletions
11
...s/spi/tomcat-adapter-spi/src/main/java/org/keycloak/adapters/tomcat/PrincipalFactory.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,11 @@ | ||
package org.keycloak.adapters.tomcat; | ||
|
||
import org.apache.catalina.Realm; | ||
import org.apache.catalina.realm.GenericPrincipal; | ||
|
||
import java.security.Principal; | ||
import java.util.Set; | ||
|
||
public interface PrincipalFactory { | ||
GenericPrincipal createPrincipal(Realm realm, final Principal identity, final Set<String> roleSet); | ||
} |