This commit is contained in:
Bill Burke 2016-01-15 20:08:17 -05:00
parent 007e9530ec
commit d1a43d6318
6 changed files with 4 additions and 23 deletions

View file

@ -8,7 +8,6 @@ import org.keycloak.models.RealmModel;
import org.keycloak.provider.ProviderFactory;
import org.keycloak.representations.idm.ClientRepresentation;
import org.keycloak.representations.idm.ClientTemplateRepresentation;
import org.keycloak.services.managers.AuthenticationManager;
import java.util.List;

View file

@ -56,7 +56,6 @@ import org.keycloak.provider.ProviderFactory;
import org.keycloak.representations.AccessToken;
import org.keycloak.services.managers.AppAuthManager;
import org.keycloak.services.managers.AuthenticationManager.AuthResult;
import org.keycloak.services.managers.BruteForceProtector;
import org.keycloak.services.managers.ClientSessionCode;
import org.keycloak.services.messages.Messages;
import org.keycloak.services.ErrorResponse;
@ -116,13 +115,11 @@ public class IdentityBrokerService implements IdentityProvider.AuthenticationCal
private EventBuilder event;
private BruteForceProtector protector;
public IdentityBrokerService(RealmModel realmModel, BruteForceProtector protector) {
public IdentityBrokerService(RealmModel realmModel) {
if (realmModel == null) {
throw new IllegalArgumentException("Realm can not be null.");
}
this.protector = protector;
this.realmModel = realmModel;
}

View file

@ -14,8 +14,6 @@ import org.keycloak.protocol.LoginProtocolFactory;
import org.keycloak.protocol.oidc.OIDCLoginProtocol;
import org.keycloak.protocol.oidc.OIDCLoginProtocolService;
import org.keycloak.services.clientregistration.ClientRegistrationService;
import org.keycloak.services.managers.AuthenticationManager;
import org.keycloak.services.managers.BruteForceProtector;
import org.keycloak.services.managers.RealmManager;
import org.keycloak.services.util.CacheControlUtil;
import org.keycloak.wellknown.WellKnownProvider;
@ -41,9 +39,6 @@ public class RealmsResource {
@Context
protected ClientConnection clientConnection;
@Context
protected BruteForceProtector protector;
public static UriBuilder realmBaseUrl(UriInfo uriInfo) {
UriBuilder baseUriBuilder = uriInfo.getBaseUriBuilder();
return realmBaseUrl(baseUriBuilder);
@ -177,7 +172,7 @@ public class RealmsResource {
public IdentityBrokerService getBrokerService(final @PathParam("realm") String name) {
RealmModel realm = init(name);
IdentityBrokerService brokerService = new IdentityBrokerService(realm, protector);
IdentityBrokerService brokerService = new IdentityBrokerService(realm);
ResteasyProviderFactory.getInstance().injectProperties(brokerService);
brokerService.init();

View file

@ -45,9 +45,6 @@ public class AttackDetectionResource {
@Context
protected HttpHeaders headers;
@Context
protected BruteForceProtector protector;
public AttackDetectionResource(RealmAuth auth, RealmModel realm, AdminEventBuilder adminEvent) {
this.auth = auth;
this.realm = realm;
@ -77,7 +74,7 @@ public class AttackDetectionResource {
UsernameLoginFailureModel model = session.sessions().getUserLoginFailure(realm, username.toLowerCase());
if (model == null) return data;
if (protector.isTemporarilyDisabled(session, realm, username)) {
if (session.getProvider(BruteForceProtector.class).isTemporarilyDisabled(session, realm, username)) {
data.put("disabled", true);
}
data.put("numFailures", model.getNumFailures());

View file

@ -14,7 +14,6 @@ import org.keycloak.models.utils.ModelToRepresentation;
import org.keycloak.representations.idm.ClientMappingsRepresentation;
import org.keycloak.representations.idm.MappingsRepresentation;
import org.keycloak.representations.idm.RoleRepresentation;
import org.keycloak.services.managers.BruteForceProtector;
import org.keycloak.services.managers.RealmManager;
import javax.ws.rs.Consumes;
@ -63,9 +62,6 @@ public class RoleMapperResource {
@Context
protected HttpHeaders headers;
@Context
protected BruteForceProtector protector;
public RoleMapperResource(RealmModel realm, RealmAuth auth, RoleMapperModel roleMapper, AdminEventBuilder adminEvent) {
this.auth = auth;
this.realm = realm;

View file

@ -105,9 +105,6 @@ public class UsersResource {
@Context
protected HttpHeaders headers;
@Context
protected BruteForceProtector protector;
public UsersResource(RealmModel realm, RealmAuth auth, TokenManager tokenManager, AdminEventBuilder adminEvent) {
this.auth = auth;
this.realm = realm;
@ -270,7 +267,7 @@ public class UsersResource {
rep.setFederatedIdentities(reps);
}
if ((protector != null) && protector.isTemporarilyDisabled(session, realm, rep.getUsername())) {
if (session.getProvider(BruteForceProtector.class).isTemporarilyDisabled(session, realm, rep.getUsername())) {
rep.setEnabled(false);
}