diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java index 001a52a8d5..fdd8f369cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java @@ -119,7 +119,7 @@ public class JndiServiceImpl implements JndiService { try { final URI uri = new URI( jndiName ); final String scheme = uri.getScheme(); - if ( scheme != null && (! "java".equals( scheme ) ) ) { + if ( scheme != null && (! allowedScheme( scheme ) ) ) { throw new JndiException( "JNDI lookups for scheme '" + scheme + "' are not allowed" ); } } @@ -137,6 +137,16 @@ public class JndiServiceImpl implements JndiService { } } + private static boolean allowedScheme(final String scheme) { + switch ( scheme ) { + case "java" : + case "osgi" : + return true; + default: + return false; + } + } + private void cleanUp(InitialContext initialContext) { try { initialContext.close();