Fix StackOverflowError on Mongo

This commit is contained in:
mposolda 2016-12-20 12:21:21 +01:00
parent aee8398ee8
commit 96f2985e86
2 changed files with 13 additions and 9 deletions

View file

@ -32,8 +32,7 @@ public class MongoAuthorizationStoreFactory implements AuthorizationStoreFactory
@Override
public StoreFactory create(KeycloakSession session) {
MongoConnectionProvider connection = session.getProvider(MongoConnectionProvider.class);
AuthorizationProvider provider = session.getProvider(AuthorizationProvider.class);
return new MongoStoreFactory(connection.getInvocationContext(), provider);
return new MongoStoreFactory(connection.getInvocationContext(), session);
}
@Override

View file

@ -25,6 +25,7 @@ import org.keycloak.authorization.store.ResourceStore;
import org.keycloak.authorization.store.ScopeStore;
import org.keycloak.authorization.store.StoreFactory;
import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
import org.keycloak.models.KeycloakSession;
/**
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
@ -32,31 +33,35 @@ import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
public class MongoStoreFactory implements StoreFactory {
private final MongoStoreInvocationContext invocationContext;
private final AuthorizationProvider authorizationProvider;
private final KeycloakSession session;
public MongoStoreFactory(MongoStoreInvocationContext invocationContext, AuthorizationProvider authorizationProvider) {
public MongoStoreFactory(MongoStoreInvocationContext invocationContext, KeycloakSession session) {
this.invocationContext = invocationContext;
this.authorizationProvider = authorizationProvider;
this.session = session;
}
@Override
public PolicyStore getPolicyStore() {
return new MongoPolicyStore(this.invocationContext, this.authorizationProvider);
return new MongoPolicyStore(this.invocationContext, getAuthorizationProvider());
}
@Override
public ResourceServerStore getResourceServerStore() {
return new MongoResourceServerStore(this.invocationContext, this.authorizationProvider);
return new MongoResourceServerStore(this.invocationContext, getAuthorizationProvider());
}
@Override
public ResourceStore getResourceStore() {
return new MongoResourceStore(this.invocationContext, this.authorizationProvider);
return new MongoResourceStore(this.invocationContext, getAuthorizationProvider());
}
@Override
public ScopeStore getScopeStore() {
return new MongoScopeStore(this.invocationContext, this.authorizationProvider);
return new MongoScopeStore(this.invocationContext, getAuthorizationProvider());
}
private AuthorizationProvider getAuthorizationProvider() {
return session.getProvider(AuthorizationProvider.class);
}
@Override