KEYCLOAK-3054: Fix potential NPE in RealmsResource

Prior to PR .well-known Endpoint threw NPE with if unknown
Protocol was provided.
This commit is contained in:
Thomas Darimont 2016-06-06 12:05:38 +02:00
parent 816b01860b
commit 67a63a806e

View file

@ -98,9 +98,14 @@ public class RealmsResource {
final @PathParam("protocol") String protocol) { final @PathParam("protocol") String protocol) {
RealmModel realm = init(name); 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); EventBuilder event = new EventBuilder(realm, session, clientConnection);
LoginProtocolFactory factory = (LoginProtocolFactory)session.getKeycloakSessionFactory().getProviderFactory(LoginProtocol.class, protocol);
Object endpoint = factory.createProtocolEndpoint(realm, event); Object endpoint = factory.createProtocolEndpoint(realm, event);
ResteasyProviderFactory.getInstance().injectProperties(endpoint); ResteasyProviderFactory.getInstance().injectProperties(endpoint);