From d1a43d631883508c83368f093cebbe87dc4d1907 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Fri, 15 Jan 2016 20:08:17 -0500 Subject: [PATCH] fixes --- .../java/org/keycloak/protocol/LoginProtocolFactory.java | 1 - .../keycloak/services/resources/IdentityBrokerService.java | 5 +---- .../org/keycloak/services/resources/RealmsResource.java | 7 +------ .../services/resources/admin/AttackDetectionResource.java | 5 +---- .../services/resources/admin/RoleMapperResource.java | 4 ---- .../keycloak/services/resources/admin/UsersResource.java | 5 +---- 6 files changed, 4 insertions(+), 23 deletions(-) diff --git a/server-spi/src/main/java/org/keycloak/protocol/LoginProtocolFactory.java b/server-spi/src/main/java/org/keycloak/protocol/LoginProtocolFactory.java index 2419d4676e..9f7801806f 100755 --- a/server-spi/src/main/java/org/keycloak/protocol/LoginProtocolFactory.java +++ b/server-spi/src/main/java/org/keycloak/protocol/LoginProtocolFactory.java @@ -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; diff --git a/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java b/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java index 84521b3f33..975063a291 100755 --- a/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java +++ b/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java @@ -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; } diff --git a/services/src/main/java/org/keycloak/services/resources/RealmsResource.java b/services/src/main/java/org/keycloak/services/resources/RealmsResource.java index 73c89b9c0f..e3a418d172 100755 --- a/services/src/main/java/org/keycloak/services/resources/RealmsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/RealmsResource.java @@ -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(); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AttackDetectionResource.java b/services/src/main/java/org/keycloak/services/resources/admin/AttackDetectionResource.java index 2a8e9245dd..c2fb26fd86 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/AttackDetectionResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AttackDetectionResource.java @@ -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()); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RoleMapperResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RoleMapperResource.java index dfd2119c47..202ac3add9 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RoleMapperResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RoleMapperResource.java @@ -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; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java index f78f33ffa1..77a925c268 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java @@ -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); }