protected boolean isDenied(Name name) { if (name == null) throw new NullPointerException("name is null"); for (Name prefix : deny) { if (name.startsWith(prefix)) { return true; } } return false; } }
protected boolean isAllowed(Name name) { if (name == null) throw new NullPointerException("name is null"); for (Name prefix : allow) { if (name.startsWith(prefix)) { return true; } } return false; }
private Name getRelativeName( String nameInNamespace, String baseDn ) throws NamingException { Properties props = new Properties(); props.setProperty( "jndi.syntax.direction", "right_to_left" ); props.setProperty( "jndi.syntax.separator", "," ); props.setProperty( "jndi.syntax.ignorecase", "true" ); props.setProperty( "jndi.syntax.trimblanks", "true" ); Name searchBaseDn = null; Name ctxRoot = new CompoundName( nameInNamespace, props ); searchBaseDn = new CompoundName( baseDn, props ); if ( !searchBaseDn.startsWith( ctxRoot ) ) { throw new NamingException( I18n.err( I18n.ERR_648, baseDn ) ); } for ( int ii = 0; ii < ctxRoot.size(); ii++ ) { searchBaseDn.remove( 0 ); } return searchBaseDn; }
/** * Remove the supplied path from the beginning the specified * <code>Name</code> if the name instance starts with * <code>path</code>. Useful for stripping base path suffix from a * <code>Name</code>. The original Name will not be affected. * * @param dn the dn to strip from. * @param pathToRemove the path to remove from the beginning the dn instance. * @return an LdapName instance that is a copy of the original name with the * specified path stripped from its beginning. * @since 2.0 */ public static LdapName removeFirst(Name dn, Name pathToRemove) { Assert.notNull(dn, "dn must not be null"); Assert.notNull(pathToRemove, "pathToRemove must not be null"); LdapName result = newLdapName(dn); LdapName path = returnOrConstructLdapNameFromName(pathToRemove); if(path.size() == 0 || !dn.startsWith(path)) { return result; } for(int i = 0; i < path.size(); i++) { try { result.remove(0); } catch (InvalidNameException e) { throw convertLdapException(e); } } return result; }
/** * Remove the supplied path from the beginning the specified * <code>Name</code> if the name instance starts with * <code>path</code>. Useful for stripping base path suffix from a * <code>Name</code>. The original Name will not be affected. * * @param dn the dn to strip from. * @param pathToRemove the path to remove from the beginning the dn instance. * @return an LdapName instance that is a copy of the original name with the * specified path stripped from its beginning. * @since 2.0 */ public static LdapName removeFirst(Name dn, Name pathToRemove) { Assert.notNull(dn, "dn must not be null"); Assert.notNull(pathToRemove, "pathToRemove must not be null"); LdapName result = newLdapName(dn); LdapName path = returnOrConstructLdapNameFromName(pathToRemove); if(path.size() == 0 || !dn.startsWith(path)) { return result; } for(int i = 0; i < path.size(); i++) { try { result.remove(0); } catch (InvalidNameException e) { throw convertLdapException(e); } } return result; }
/** * Remove the supplied path from the beginning the specified * <code>Name</code> if the name instance starts with * <code>path</code>. Useful for stripping base path suffix from a * <code>Name</code>. The original Name will not be affected. * * @param dn the dn to strip from. * @param pathToRemove the path to remove from the beginning the dn instance. * @return an LdapName instance that is a copy of the original name with the * specified path stripped from its beginning. * @since 2.0 */ public static LdapName removeFirst(Name dn, Name pathToRemove) { Assert.notNull(dn, "dn must not be null"); Assert.notNull(pathToRemove, "pathToRemove must not be null"); LdapName result = newLdapName(dn); LdapName path = returnOrConstructLdapNameFromName(pathToRemove); if(path.size() == 0 || !dn.startsWith(path)) { return result; } for(int i = 0; i < path.size(); i++) { try { result.remove(0); } catch (InvalidNameException e) { throw convertLdapException(e); } } return result; }
/** * Remove the supplied path from the beginning the specified * <code>Name</code> if the name instance starts with * <code>path</code>. Useful for stripping base path suffix from a * <code>Name</code>. The original Name will not be affected. * * @param dn the dn to strip from. * @param pathToRemove the path to remove from the beginning the dn instance. * @return an LdapName instance that is a copy of the original name with the * specified path stripped from its beginning. * @since 2.0 */ public static LdapName removeFirst(Name dn, Name pathToRemove) { Assert.notNull(dn, "dn must not be null"); Assert.notNull(pathToRemove, "pathToRemove must not be null"); LdapName result = newLdapName(dn); LdapName path = returnOrConstructLdapNameFromName(pathToRemove); if(path.size() == 0 || !dn.startsWith(path)) { return result; } for(int i = 0; i < path.size(); i++) { try { result.remove(0); } catch (InvalidNameException e) { throw convertLdapException(e); } } return result; }