类javax.naming.CompositeName源码实例Demo

下面列出了怎么用javax.naming.CompositeName的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: spring-ldap   文件: LdapTemplateTest.java
@Test
public void testUnbindRecursive() throws Exception {
	expectGetReadWriteContext();

	when(namingEnumerationMock.hasMore()).thenReturn(true, false, false);
	Binding binding = new Binding("cn=Some name", null);
	when(namingEnumerationMock.next()).thenReturn(binding);

	LdapName listDn = LdapUtils.newLdapName(DEFAULT_BASE_STRING);
	when(dirContextMock.listBindings(listDn)).thenReturn(namingEnumerationMock);
	LdapName subListDn = LdapUtils.newLdapName("cn=Some name, o=example.com");
	when(dirContextMock.listBindings(subListDn)).thenReturn(namingEnumerationMock);

	tested.unbind(new CompositeName(DEFAULT_BASE_STRING), true);

       verify(dirContextMock).unbind(subListDn);
       verify(dirContextMock).unbind(listDn);
       verify(namingEnumerationMock, times(2)).close();
       verify(dirContextMock).close();
}
 
源代码2 项目: tomcatsrc   文件: TestNamingContext.java
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    resp.setContentType("text/plain;UTF-8");
    PrintWriter out = resp.getWriter();

    try {
        Context initCtx = new InitialContext();

        Boolean b1 = (Boolean) initCtx.lookup(JNDI_NAME);
        Boolean b2 = (Boolean) initCtx.lookup(
                new CompositeName(JNDI_NAME));

        out.print(b1);
        out.print(b2);

    } catch (NamingException ne) {
        throw new ServletException(ne);
    }
}
 
源代码3 项目: openjdk-8   文件: ContinuationDirContext.java
protected DirContextNamePair getTargetContext(Name name)
        throws NamingException {

    if (cpe.getResolvedObj() == null)
        throw (NamingException)cpe.fillInStackTrace();

    Context ctx = NamingManager.getContext(cpe.getResolvedObj(),
                                           cpe.getAltName(),
                                           cpe.getAltNameCtx(),
                                           env);
    if (ctx == null)
        throw (NamingException)cpe.fillInStackTrace();

    if (ctx instanceof DirContext)
        return new DirContextNamePair((DirContext)ctx, name);

    if (ctx instanceof Resolver) {
        Resolver res = (Resolver)ctx;
        ResolveResult rr = res.resolveToClass(name, DirContext.class);

        // Reached a DirContext; return result.
        DirContext dctx = (DirContext)rr.getResolvedObj();
        return (new DirContextNamePair(dctx, rr.getRemainingName()));
    }

    // Resolve all the way using lookup().  This may allow the operation
    // to succeed if it doesn't require the penultimate context.
    Object ultimate = ctx.lookup(name);
    if (ultimate instanceof DirContext) {
        return (new DirContextNamePair((DirContext)ultimate,
                                      new CompositeName()));
    }

    throw (NamingException)cpe.fillInStackTrace();
}
 
源代码4 项目: jdk8u-dev-jdk   文件: ResolveResult.java
/**
      * Constructs a new instance of ResolveResult consisting of
      * the resolved object and the remaining unresolved component.
      *
      * @param robj The non-null object resolved to.
      * @param rcomp The single remaining name component that has yet to be
      *                 resolved. Cannot be null (but can be empty).
      */
    public ResolveResult(Object robj, String rcomp) {
        resolvedObj = robj;
        try {
        remainingName = new CompositeName(rcomp);
//          remainingName.appendComponent(rcomp);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen
        }
    }
 
源代码5 项目: spring-ldap   文件: DistinguishedName.java
/**
 * Construct a new <code>DistinguishedName</code> from the supplied
 * {@link Name}. The parts of the supplied {@link Name} must be
 * syntactically correct {@link LdapRdn}s.
 * 
 * @param name the {@link Name} to construct a new
 * <code>DistinguishedName</code> from.
 */
public DistinguishedName(Name name) {
	Assert.notNull(name, "name cannot be null");
	if (name instanceof CompositeName) {
		parse(LdapUtils.convertCompositeNameToString((CompositeName) name));
		return;
	}
	names = new LinkedList();
	for (int i = 0; i < name.size(); i++) {
		names.add(new LdapRdn(name.get(i)));
	}
}
 
源代码6 项目: spring-ldap   文件: DefaultDirObjectFactoryTest.java
@Test
public void testConstructAdapterFromName() throws InvalidNameException {
	CompositeName name = new CompositeName();
	name.add("ldap://localhost:389/ou=People,o=JNDITutorial");
	DefaultDirObjectFactory tested = new DefaultDirObjectFactory();
	DirContextAdapter result = tested.constructAdapterFromName(new BasicAttributes(), name, "");

	assertThat(result.getDn().toString()).isEqualTo("ou=People,o=JNDITutorial");
	assertThat(result.getReferralUrl().toString()).isEqualTo("ldap://localhost:389");
}
 
源代码7 项目: openjdk-8   文件: ResolveResult.java
/**
      * Constructs a new instance of ResolveResult consisting of
      * the resolved object and the remaining unresolved component.
      *
      * @param robj The non-null object resolved to.
      * @param rcomp The single remaining name component that has yet to be
      *                 resolved. Cannot be null (but can be empty).
      */
    public ResolveResult(Object robj, String rcomp) {
        resolvedObj = robj;
        try {
        remainingName = new CompositeName(rcomp);
//          remainingName.appendComponent(rcomp);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen
        }
    }
 
源代码8 项目: Java8CN   文件: ContinuationDirContext.java
protected DirContextNamePair getTargetContext(Name name)
        throws NamingException {

    if (cpe.getResolvedObj() == null)
        throw (NamingException)cpe.fillInStackTrace();

    Context ctx = NamingManager.getContext(cpe.getResolvedObj(),
                                           cpe.getAltName(),
                                           cpe.getAltNameCtx(),
                                           env);
    if (ctx == null)
        throw (NamingException)cpe.fillInStackTrace();

    if (ctx instanceof DirContext)
        return new DirContextNamePair((DirContext)ctx, name);

    if (ctx instanceof Resolver) {
        Resolver res = (Resolver)ctx;
        ResolveResult rr = res.resolveToClass(name, DirContext.class);

        // Reached a DirContext; return result.
        DirContext dctx = (DirContext)rr.getResolvedObj();
        return (new DirContextNamePair(dctx, rr.getRemainingName()));
    }

    // Resolve all the way using lookup().  This may allow the operation
    // to succeed if it doesn't require the penultimate context.
    Object ultimate = ctx.lookup(name);
    if (ultimate instanceof DirContext) {
        return (new DirContextNamePair((DirContext)ultimate,
                                      new CompositeName()));
    }

    throw (NamingException)cpe.fillInStackTrace();
}
 
protected DirContextNamePair getTargetContext(Name name)
        throws NamingException {

    if (cpe.getResolvedObj() == null)
        throw (NamingException)cpe.fillInStackTrace();

    Context ctx = NamingManager.getContext(cpe.getResolvedObj(),
                                           cpe.getAltName(),
                                           cpe.getAltNameCtx(),
                                           env);
    if (ctx == null)
        throw (NamingException)cpe.fillInStackTrace();

    if (ctx instanceof DirContext)
        return new DirContextNamePair((DirContext)ctx, name);

    if (ctx instanceof Resolver) {
        Resolver res = (Resolver)ctx;
        ResolveResult rr = res.resolveToClass(name, DirContext.class);

        // Reached a DirContext; return result.
        DirContext dctx = (DirContext)rr.getResolvedObj();
        return (new DirContextNamePair(dctx, rr.getRemainingName()));
    }

    // Resolve all the way using lookup().  This may allow the operation
    // to succeed if it doesn't require the penultimate context.
    Object ultimate = ctx.lookup(name);
    if (ultimate instanceof DirContext) {
        return (new DirContextNamePair((DirContext)ultimate,
                                      new CompositeName()));
    }

    throw (NamingException)cpe.fillInStackTrace();
}
 
public Object lookup(String name) throws NamingException {
    if (TraceCarol.isDebugJndiCarol()) {
        TraceCarol.debugJndiCarol("LmiInitialContext.lookup(\"" + name + "\")");
    }
    if ((name == null) || (name.equals(""))) {
        return (new LmiInitialContext(lmiEnv));
    }
    Object o = bindings.get(name);
    if (o != null) {
        return resolveObject(o, new CompositeName(name));
    } else {
        throw new NameNotFoundException(name + " not found");
    }
}
 
源代码11 项目: jdk1.8-source-analysis   文件: ResolveResult.java
/**
  * Adds a single component to the end of remaining name.
  *
  * @param name The component to add. Can be null.
  * @see #getRemainingName
  * @see #appendRemainingName
  */
public void appendRemainingComponent(String name) {
    if (name != null) {
        CompositeName rname = new CompositeName();
        try {
            rname.add(name);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen for empty composite name
        }
        appendRemainingName(rname);
    }
}
 
源代码12 项目: dragonwell8_jdk   文件: LDAPCertStore.java
private String checkName(String name) throws CertStoreException {
    if (name == null) {
        throw new CertStoreException("Name absent");
    }
    try {
        if (new CompositeName(name).size() > 1) {
            throw new CertStoreException("Invalid name: " + name);
        }
    } catch (InvalidNameException ine) {
        throw new CertStoreException("Invalid name: " + name, ine);
    }
    return name;
}
 
源代码13 项目: hottub   文件: ResolveResult.java
/**
  * Adds a single component to the end of remaining name.
  *
  * @param name The component to add. Can be null.
  * @see #getRemainingName
  * @see #appendRemainingName
  */
public void appendRemainingComponent(String name) {
    if (name != null) {
        CompositeName rname = new CompositeName();
        try {
            rname.add(name);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen for empty composite name
        }
        appendRemainingName(rname);
    }
}
 
源代码14 项目: dragonwell8_jdk   文件: ResolveResult.java
/**
      * Constructs a new instance of ResolveResult consisting of
      * the resolved object and the remaining unresolved component.
      *
      * @param robj The non-null object resolved to.
      * @param rcomp The single remaining name component that has yet to be
      *                 resolved. Cannot be null (but can be empty).
      */
    public ResolveResult(Object robj, String rcomp) {
        resolvedObj = robj;
        try {
        remainingName = new CompositeName(rcomp);
//          remainingName.appendComponent(rcomp);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen
        }
    }
 
源代码15 项目: dragonwell8_jdk   文件: ResolveResult.java
/**
  * Adds a single component to the end of remaining name.
  *
  * @param name The component to add. Can be null.
  * @see #getRemainingName
  * @see #appendRemainingName
  */
public void appendRemainingComponent(String name) {
    if (name != null) {
        CompositeName rname = new CompositeName();
        try {
            rname.add(name);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen for empty composite name
        }
        appendRemainingName(rname);
    }
}
 
源代码16 项目: spring-ldap   文件: LdapUtils.java
/**
 * Converts a CompositeName to a String in a way that avoids escaping
 * problems, such as the dreaded "triple backslash" problem.
 * 
 * @param compositeName The CompositeName to convert
 * @return String containing the String representation of <code>name</code>
 */
public static String convertCompositeNameToString(
		CompositeName compositeName) {
	if (compositeName.size() > 0) {
		// A lookup with an empty String seems to produce an empty
		// compositeName here; need to take this into account.
		return compositeName.get(0);
	}
	else {
		return "";
	}
}
 
源代码17 项目: TencentKona-8   文件: ResolveResult.java
/**
      * Constructs a new instance of ResolveResult consisting of
      * the resolved object and the remaining unresolved component.
      *
      * @param robj The non-null object resolved to.
      * @param rcomp The single remaining name component that has yet to be
      *                 resolved. Cannot be null (but can be empty).
      */
    public ResolveResult(Object robj, String rcomp) {
        resolvedObj = robj;
        try {
        remainingName = new CompositeName(rcomp);
//          remainingName.appendComponent(rcomp);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen
        }
    }
 
源代码18 项目: TencentKona-8   文件: ResolveResult.java
/**
  * Adds a single component to the end of remaining name.
  *
  * @param name The component to add. Can be null.
  * @see #getRemainingName
  * @see #appendRemainingName
  */
public void appendRemainingComponent(String name) {
    if (name != null) {
        CompositeName rname = new CompositeName();
        try {
            rname.add(name);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen for empty composite name
        }
        appendRemainingName(rname);
    }
}
 
源代码19 项目: jdk8u60   文件: ContinuationDirContext.java
protected DirContextNamePair getTargetContext(Name name)
        throws NamingException {

    if (cpe.getResolvedObj() == null)
        throw (NamingException)cpe.fillInStackTrace();

    Context ctx = NamingManager.getContext(cpe.getResolvedObj(),
                                           cpe.getAltName(),
                                           cpe.getAltNameCtx(),
                                           env);
    if (ctx == null)
        throw (NamingException)cpe.fillInStackTrace();

    if (ctx instanceof DirContext)
        return new DirContextNamePair((DirContext)ctx, name);

    if (ctx instanceof Resolver) {
        Resolver res = (Resolver)ctx;
        ResolveResult rr = res.resolveToClass(name, DirContext.class);

        // Reached a DirContext; return result.
        DirContext dctx = (DirContext)rr.getResolvedObj();
        return (new DirContextNamePair(dctx, rr.getRemainingName()));
    }

    // Resolve all the way using lookup().  This may allow the operation
    // to succeed if it doesn't require the penultimate context.
    Object ultimate = ctx.lookup(name);
    if (ultimate instanceof DirContext) {
        return (new DirContextNamePair((DirContext)ultimate,
                                      new CompositeName()));
    }

    throw (NamingException)cpe.fillInStackTrace();
}
 
源代码20 项目: jdk8u60   文件: ResolveResult.java
/**
      * Constructs a new instance of ResolveResult consisting of
      * the resolved object and the remaining unresolved component.
      *
      * @param robj The non-null object resolved to.
      * @param rcomp The single remaining name component that has yet to be
      *                 resolved. Cannot be null (but can be empty).
      */
    public ResolveResult(Object robj, String rcomp) {
        resolvedObj = robj;
        try {
        remainingName = new CompositeName(rcomp);
//          remainingName.appendComponent(rcomp);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen
        }
    }
 
源代码21 项目: jdk8u60   文件: ResolveResult.java
/**
  * Adds a single component to the end of remaining name.
  *
  * @param name The component to add. Can be null.
  * @see #getRemainingName
  * @see #appendRemainingName
  */
public void appendRemainingComponent(String name) {
    if (name != null) {
        CompositeName rname = new CompositeName();
        try {
            rname.add(name);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen for empty composite name
        }
        appendRemainingName(rname);
    }
}
 
源代码22 项目: JDKSourceCode1.8   文件: ContinuationDirContext.java
protected DirContextNamePair getTargetContext(Name name)
        throws NamingException {

    if (cpe.getResolvedObj() == null)
        throw (NamingException)cpe.fillInStackTrace();

    Context ctx = NamingManager.getContext(cpe.getResolvedObj(),
                                           cpe.getAltName(),
                                           cpe.getAltNameCtx(),
                                           env);
    if (ctx == null)
        throw (NamingException)cpe.fillInStackTrace();

    if (ctx instanceof DirContext)
        return new DirContextNamePair((DirContext)ctx, name);

    if (ctx instanceof Resolver) {
        Resolver res = (Resolver)ctx;
        ResolveResult rr = res.resolveToClass(name, DirContext.class);

        // Reached a DirContext; return result.
        DirContext dctx = (DirContext)rr.getResolvedObj();
        return (new DirContextNamePair(dctx, rr.getRemainingName()));
    }

    // Resolve all the way using lookup().  This may allow the operation
    // to succeed if it doesn't require the penultimate context.
    Object ultimate = ctx.lookup(name);
    if (ultimate instanceof DirContext) {
        return (new DirContextNamePair((DirContext)ultimate,
                                      new CompositeName()));
    }

    throw (NamingException)cpe.fillInStackTrace();
}
 
源代码23 项目: JDKSourceCode1.8   文件: ResolveResult.java
/**
      * Constructs a new instance of ResolveResult consisting of
      * the resolved object and the remaining unresolved component.
      *
      * @param robj The non-null object resolved to.
      * @param rcomp The single remaining name component that has yet to be
      *                 resolved. Cannot be null (but can be empty).
      */
    public ResolveResult(Object robj, String rcomp) {
        resolvedObj = robj;
        try {
        remainingName = new CompositeName(rcomp);
//          remainingName.appendComponent(rcomp);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen
        }
    }
 
源代码24 项目: openjdk-jdk8u   文件: LDAPCertStore.java
private String checkName(String name) throws CertStoreException {
    if (name == null) {
        throw new CertStoreException("Name absent");
    }
    try {
        if (new CompositeName(name).size() > 1) {
            throw new CertStoreException("Invalid name: " + name);
        }
    } catch (InvalidNameException ine) {
        throw new CertStoreException("Invalid name: " + name, ine);
    }
    return name;
}
 
源代码25 项目: jdk8u_jdk   文件: ContinuationDirContext.java
protected DirContextNamePair getTargetContext(Name name)
        throws NamingException {

    if (cpe.getResolvedObj() == null)
        throw (NamingException)cpe.fillInStackTrace();

    Context ctx = NamingManager.getContext(cpe.getResolvedObj(),
                                           cpe.getAltName(),
                                           cpe.getAltNameCtx(),
                                           env);
    if (ctx == null)
        throw (NamingException)cpe.fillInStackTrace();

    if (ctx instanceof DirContext)
        return new DirContextNamePair((DirContext)ctx, name);

    if (ctx instanceof Resolver) {
        Resolver res = (Resolver)ctx;
        ResolveResult rr = res.resolveToClass(name, DirContext.class);

        // Reached a DirContext; return result.
        DirContext dctx = (DirContext)rr.getResolvedObj();
        return (new DirContextNamePair(dctx, rr.getRemainingName()));
    }

    // Resolve all the way using lookup().  This may allow the operation
    // to succeed if it doesn't require the penultimate context.
    Object ultimate = ctx.lookup(name);
    if (ultimate instanceof DirContext) {
        return (new DirContextNamePair((DirContext)ultimate,
                                      new CompositeName()));
    }

    throw (NamingException)cpe.fillInStackTrace();
}
 
源代码26 项目: openjdk-8-source   文件: ContinuationDirContext.java
protected DirContextNamePair getTargetContext(Name name)
        throws NamingException {

    if (cpe.getResolvedObj() == null)
        throw (NamingException)cpe.fillInStackTrace();

    Context ctx = NamingManager.getContext(cpe.getResolvedObj(),
                                           cpe.getAltName(),
                                           cpe.getAltNameCtx(),
                                           env);
    if (ctx == null)
        throw (NamingException)cpe.fillInStackTrace();

    if (ctx instanceof DirContext)
        return new DirContextNamePair((DirContext)ctx, name);

    if (ctx instanceof Resolver) {
        Resolver res = (Resolver)ctx;
        ResolveResult rr = res.resolveToClass(name, DirContext.class);

        // Reached a DirContext; return result.
        DirContext dctx = (DirContext)rr.getResolvedObj();
        return (new DirContextNamePair(dctx, rr.getRemainingName()));
    }

    // Resolve all the way using lookup().  This may allow the operation
    // to succeed if it doesn't require the penultimate context.
    Object ultimate = ctx.lookup(name);
    if (ultimate instanceof DirContext) {
        return (new DirContextNamePair((DirContext)ultimate,
                                      new CompositeName()));
    }

    throw (NamingException)cpe.fillInStackTrace();
}
 
源代码27 项目: openjdk-jdk8u   文件: ResolveResult.java
/**
  * Adds a single component to the end of remaining name.
  *
  * @param name The component to add. Can be null.
  * @see #getRemainingName
  * @see #appendRemainingName
  */
public void appendRemainingComponent(String name) {
    if (name != null) {
        CompositeName rname = new CompositeName();
        try {
            rname.add(name);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen for empty composite name
        }
        appendRemainingName(rname);
    }
}
 
源代码28 项目: jdk8u-jdk   文件: ContinuationDirContext.java
protected DirContextNamePair getTargetContext(Name name)
        throws NamingException {

    if (cpe.getResolvedObj() == null)
        throw (NamingException)cpe.fillInStackTrace();

    Context ctx = NamingManager.getContext(cpe.getResolvedObj(),
                                           cpe.getAltName(),
                                           cpe.getAltNameCtx(),
                                           env);
    if (ctx == null)
        throw (NamingException)cpe.fillInStackTrace();

    if (ctx instanceof DirContext)
        return new DirContextNamePair((DirContext)ctx, name);

    if (ctx instanceof Resolver) {
        Resolver res = (Resolver)ctx;
        ResolveResult rr = res.resolveToClass(name, DirContext.class);

        // Reached a DirContext; return result.
        DirContext dctx = (DirContext)rr.getResolvedObj();
        return (new DirContextNamePair(dctx, rr.getRemainingName()));
    }

    // Resolve all the way using lookup().  This may allow the operation
    // to succeed if it doesn't require the penultimate context.
    Object ultimate = ctx.lookup(name);
    if (ultimate instanceof DirContext) {
        return (new DirContextNamePair((DirContext)ultimate,
                                      new CompositeName()));
    }

    throw (NamingException)cpe.fillInStackTrace();
}
 
源代码29 项目: jdk8u-jdk   文件: ResolveResult.java
/**
  * Adds a single component to the end of remaining name.
  *
  * @param name The component to add. Can be null.
  * @see #getRemainingName
  * @see #appendRemainingName
  */
public void appendRemainingComponent(String name) {
    if (name != null) {
        CompositeName rname = new CompositeName();
        try {
            rname.add(name);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen for empty composite name
        }
        appendRemainingName(rname);
    }
}
 
源代码30 项目: piranha   文件: DefaultInitialContextTest.java
/**
 * Test destroySubcontext method.
 *
 * @throws Exception when an error occurs.
 */
@Test
public void testDestroySubcontext2() throws Exception {
    DefaultInitialContext context = new DefaultInitialContext();
    context.createSubcontext(new CompositeName("context"));
    context.bind("context/name", 12);
    assertThrows(ContextNotEmptyException.class, () -> context.destroySubcontext("context"));
}
 
 类所在包
 同包方法