Merge pull request #2917 from thomasdarimont/issue/KEYCLOAK-3054-fix-npe-on-unknown-protocol

KEYCLOAK-3054: Fix potential NPE in RealmsResource
This commit is contained in:
Stian Thorgersen 2016-06-07 13:09:54 +02:00
commit b6a76b1267

View file

@ -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);