public Context getContext(final String identifier) { NamingStore namingStore = getNamingStore(identifier); if (namingStore != null) { try { return (Context) namingStore.lookup(EMPTY_NAME); } catch (NamingException e) { throw new IllegalStateException(e); } } else { return null; } } }
/** {@inheritDoc} */ public void addNamingListener(final Name target, final int scope, final NamingListener listener) throws NamingException { check(target, JndiPermission.ACTION_ADD_NAMING_LISTENER); namingStore.addNamingListener(target, scope, listener); }
/** {@inheritDoc} */ public void removeNamingListener(final NamingListener listener) throws NamingException { namingStore.removeNamingListener(listener); }
/** {@inheritDoc} */ public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException { check(name, JndiPermission.ACTION_LIST); try { return namingEnumeration(namingStore.list(getAbsoluteName(name))); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); return continuationContext.list(cpe.getRemainingName()); } catch (RequireResolveException r) { final Object o = lookup(r.getResolve()); if (o instanceof Context) { return ((Context)o).list(name.getSuffix(r.getResolve().size())); } throw notAContextException(r.getResolve()); } }
/** {@inheritDoc} */ public NamingEnumeration<Binding> listBindings(final Name name) throws NamingException { check(name, JndiPermission.ACTION_LIST_BINDINGS); try { return namingEnumeration(namingStore.listBindings(getAbsoluteName(name))); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); return continuationContext.listBindings(cpe.getRemainingName()); } catch (RequireResolveException r) { final Object o = lookup(r.getResolve()); if (o instanceof Context) { return ((Context)o).listBindings(name.getSuffix(r.getResolve().size())); } throw notAContextException(r.getResolve()); } }
private void check(Name name, int actions) throws NamingException { final SecurityManager sm = System.getSecurityManager(); if (sm != null && WildFlySecurityManager.isChecking()) { // build absolute name (including store's base name) Name absoluteName = (Name) namingStore.getBaseName().clone(); if (name.isEmpty()) { absoluteName.addAll(prefix); } else { final String firstComponent = name.get(0); if (firstComponent.startsWith("java:")) { absoluteName = name; } else if (firstComponent.isEmpty()) { absoluteName.addAll(name.getSuffix(1)); } else { absoluteName.addAll(prefix); if(name instanceof CompositeName) { if (name.size() == 1) { // name could be a nested name absoluteName.addAll(parseName(firstComponent)); } else { absoluteName.addAll(name); } } else { absoluteName.addAll(new CompositeName(name.toString())); } } } sm.checkPermission(new JndiPermission(absoluteName.toString(), actions)); } }
/** {@inheritDoc} */ public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException { check(name, JndiPermission.ACTION_LIST); try { return namingEnumeration(namingStore.list(getAbsoluteName(name))); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); return continuationContext.list(cpe.getRemainingName()); } catch (RequireResolveException r) { final Object o = lookup(r.getResolve()); if (o instanceof Context) { return ((Context)o).list(name.getSuffix(r.getResolve().size())); } throw notAContextException(r.getResolve()); } }
/** {@inheritDoc} */ public NamingEnumeration<Binding> listBindings(final Name name) throws NamingException { check(name, JndiPermission.ACTION_LIST_BINDINGS); try { return namingEnumeration(namingStore.listBindings(getAbsoluteName(name))); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); return continuationContext.listBindings(cpe.getRemainingName()); } catch (RequireResolveException r) { final Object o = lookup(r.getResolve()); if (o instanceof Context) { return ((Context)o).listBindings(name.getSuffix(r.getResolve().size())); } throw notAContextException(r.getResolve()); } }
private void check(Name name, int actions) throws NamingException { final SecurityManager sm = System.getSecurityManager(); if (sm != null && WildFlySecurityManager.isChecking()) { // build absolute name (including store's base name) Name absoluteName = (Name) namingStore.getBaseName().clone(); if (name.isEmpty()) { absoluteName.addAll(prefix); } else { final String firstComponent = name.get(0); if (firstComponent.startsWith("java:")) { absoluteName = name; } else if (firstComponent.isEmpty()) { absoluteName.addAll(name.getSuffix(1)); } else { absoluteName.addAll(prefix); if(name instanceof CompositeName) { if (name.size() == 1) { // name could be a nested name absoluteName.addAll(parseName(firstComponent)); } else { absoluteName.addAll(name); } } else { absoluteName.addAll(new CompositeName(name.toString())); } } } sm.checkPermission(new JndiPermission(absoluteName.toString(), actions)); } }
public Context getContext(String identifier) { final NamingStore namingStore; if (identifier.equals("global")) { namingStore = globalNamingStore.getValue(); } else if (identifier.equals("jboss")) { namingStore = jbossNamingStore.getValue(); } else if (identifier.equals("jboss/exported")) { namingStore = remoteExposedNamingStore.getValue(); } else { namingStore = null; } if (namingStore != null) { try { return (Context) namingStore.lookup(EMPTY_NAME); } catch (NamingException e) { throw new IllegalStateException(e); } } else { return null; } } });
/** {@inheritDoc} */ public void removeNamingListener(final NamingListener listener) throws NamingException { namingStore.removeNamingListener(listener); }
/** {@inheritDoc} */ public void addNamingListener(final Name target, final int scope, final NamingListener listener) throws NamingException { check(target, JndiPermission.ACTION_ADD_NAMING_LISTENER); namingStore.addNamingListener(target, scope, listener); }
/** {@inheritDoc} */ public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException { check(name, Action.LIST); try { return namingEnumeration(namingStore.list(getAbsoluteName(name))); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); return continuationContext.list(cpe.getRemainingName()); } catch (RequireResolveException r) { final Object o = lookup(r.getResolve()); if (o instanceof Context) { return ((Context)o).list(name.getSuffix(r.getResolve().size())); } throw notAContextException(r.getResolve()); } }
/** {@inheritDoc} */ public NamingEnumeration<Binding> listBindings(final Name name) throws NamingException { check(name, Action.LIST_BINDINGS); try { return namingEnumeration(namingStore.listBindings(getAbsoluteName(name))); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); return continuationContext.listBindings(cpe.getRemainingName()); } catch (RequireResolveException r) { final Object o = lookup(r.getResolve()); if (o instanceof Context) { return ((Context)o).listBindings(name.getSuffix(r.getResolve().size())); } throw notAContextException(r.getResolve()); } }
private void check(Name name, int actions) throws NamingException { final SecurityManager sm = System.getSecurityManager(); if (sm != null && WildFlySecurityManager.isChecking()) { // build absolute name (including store's base name) Name absoluteName = (Name) namingStore.getBaseName().clone(); if (name.isEmpty()) { absoluteName.addAll(prefix); } else { final String firstComponent = name.get(0); if (firstComponent.startsWith("java:")) { absoluteName = name; } else if (firstComponent.isEmpty()) { absoluteName.addAll(name.getSuffix(1)); } else { absoluteName.addAll(prefix); if(name instanceof CompositeName) { if (name.size() == 1) { // name could be a nested name absoluteName.addAll(parseName(firstComponent)); } else { absoluteName.addAll(name); } } else { absoluteName.addAll(new CompositeName(name.toString())); } } } sm.checkPermission(new JndiPermission(absoluteName.toString(), actions)); } }
/** {@inheritDoc} */ public Object lookupLink(Name name) throws NamingException { check(name, JndiPermission.ACTION_LOOKUP); if (name.isEmpty()) { return lookup(name); } try { final Name absoluteName = getAbsoluteName(name); Object link = namingStore.lookup(absoluteName); if (!(link instanceof LinkRef) && link instanceof Reference) { link = getObjectInstance(link, name, null); } return link; } catch (Exception e) { throw namingException(NamingLogger.ROOT_LOGGER.cannotLookupLink(), e, name); } }
/** {@inheritDoc} */ public void removeNamingListener(final NamingListener listener) throws NamingException { namingStore.removeNamingListener(listener); }
/** {@inheritDoc} */ public void addNamingListener(final Name target, final int scope, final NamingListener listener) throws NamingException { check(target, Action.ADD_NAMING_LISTENER); namingStore.addNamingListener(target, scope, listener); }
/** {@inheritDoc} */ public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException { check(name, JndiPermission.ACTION_LIST); try { return namingEnumeration(namingStore.list(getAbsoluteName(name))); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); return continuationContext.list(cpe.getRemainingName()); } catch (RequireResolveException r) { final Object o = lookup(r.getResolve()); if (o instanceof Context) { return ((Context)o).list(name.getSuffix(r.getResolve().size())); } throw notAContextException(r.getResolve()); } }
/** {@inheritDoc} */ public NamingEnumeration<Binding> listBindings(final Name name) throws NamingException { check(name, JndiPermission.ACTION_LIST_BINDINGS); try { return namingEnumeration(namingStore.listBindings(getAbsoluteName(name))); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); return continuationContext.listBindings(cpe.getRemainingName()); } catch (RequireResolveException r) { final Object o = lookup(r.getResolve()); if (o instanceof Context) { return ((Context)o).listBindings(name.getSuffix(r.getResolve().size())); } throw notAContextException(r.getResolve()); } }