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 ae743f399d..f80234df33 100755 --- a/services/src/main/java/org/keycloak/services/resources/RealmsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/RealmsResource.java @@ -98,9 +98,14 @@ public class RealmsResource { final @PathParam("protocol") String protocol) { RealmModel realm = init(name); + LoginProtocolFactory factory = (LoginProtocolFactory)session.getKeycloakSessionFactory().getProviderFactory(LoginProtocol.class, protocol); + if(factory == null){ + logger.debugv("protocol %s not found", protocol); + throw new NotFoundException("Protocol not found"); + } + EventBuilder event = new EventBuilder(realm, session, clientConnection); - LoginProtocolFactory factory = (LoginProtocolFactory)session.getKeycloakSessionFactory().getProviderFactory(LoginProtocol.class, protocol); Object endpoint = factory.createProtocolEndpoint(realm, event); ResteasyProviderFactory.getInstance().injectProperties(endpoint);