javax.naming.CompositeName Java Examples
The following examples show how to use
javax.naming.CompositeName.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LdapTemplateTest.java From spring-ldap with Apache License 2.0 | 6 votes |
@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(); }
Example #2
Source File: TestNamingContext.java From tomcatsrc with Apache License 2.0 | 6 votes |
@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); } }
Example #3
Source File: ContinuationDirContext.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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(); }
Example #4
Source File: ContinuationDirContext.java From Java8CN with Apache License 2.0 | 5 votes |
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(); }
Example #5
Source File: LocalContext.java From unitime with Apache License 2.0 | 5 votes |
@Override public Object lookup(Name name) throws NamingException { if (name.isEmpty()) return cloneCtx(); Name nm = getMyComponents(name); String atom = nm.get(0); Object inter = iBindings.get(atom); if (nm.size() == 1) { if (inter == null) throw new NameNotFoundException(name + " not found"); try { return NamingManager.getObjectInstance(inter, new CompositeName().add(atom), this, iEnv); } catch (Exception e) { NamingException ne = new NamingException("getObjectInstance failed"); ne.setRootCause(e); throw ne; } } else { if (!(inter instanceof Context)) throw new NotContextException(atom + " does not name a context"); return ((Context) inter).lookup(nm.getSuffix(1)); } }
Example #6
Source File: ContinuationDirContext.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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(); }
Example #7
Source File: ResolveResult.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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 } }
Example #8
Source File: DefaultDirObjectFactoryTest.java From spring-ldap with Apache License 2.0 | 5 votes |
@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"); }
Example #9
Source File: ResolveResult.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * 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 } }
Example #10
Source File: ResolveResult.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example #11
Source File: ResolveResult.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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 } }
Example #12
Source File: ResolveResult.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example #13
Source File: ContinuationDirContext.java From JDKSourceCode1.8 with MIT License | 5 votes |
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(); }
Example #14
Source File: ResolveResult.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * 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 } }
Example #15
Source File: DirContextAdapterTest.java From spring-ldap with Apache License 2.0 | 5 votes |
/** * Test for LDAP-109, since also DirContextAdapter may get an invalid * CompositeName sent to it. */ @Test public void testConstructorUsingCompositeNameWithBackslashes() throws Exception { CompositeName compositeName = new CompositeName(); compositeName.add("cn=Some\\\\Person6,ou=company1,c=Sweden"); DirContextAdapter adapter = new DirContextAdapter(compositeName); assertThat(adapter.getDn().toString()).isEqualTo("cn=Some\\\\Person6,ou=company1,c=Sweden"); }
Example #16
Source File: LDAPCertStore.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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; }
Example #17
Source File: ContinuationDirContext.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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(); }
Example #18
Source File: ContinuationDirContext.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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(); }
Example #19
Source File: ResolveResult.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example #20
Source File: LdapManager.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
/** * Checks the existence of a particular DN * * @param nodeDN the DN to check * @return the existence of the nodeDN (or false if an error occurs). */ public boolean exists(String nodeDN) throws NamingException { try { Name n = new CompositeName().add(nodeDN); ctx.search(n, "(objectclass=*)", existanceSearchControl); return true; } catch (NameNotFoundException e) {//it's *BAD*. return false; } }
Example #21
Source File: ContinuationDirContext.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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(); }
Example #22
Source File: DefaultInitialContextTest.java From piranha with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test rename method. * * @throws Exception when an error occurs. */ @Test public void testRename2() throws Exception { DefaultInitialContext context = new DefaultInitialContext(); context.bind("name", "value"); context.rename(new CompositeName("name"), new CompositeName("newname")); }
Example #23
Source File: ContinuationDirContext.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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(); }
Example #24
Source File: ResolveResult.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example #25
Source File: DefaultInitialContextTest.java From piranha with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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")); }
Example #26
Source File: DefaultInitialContextTest.java From piranha with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test destroySubcontext method. * * @throws Exception when an error occurs. */ @Test public void testDestroySubcontext5() throws Exception { DefaultInitialContext context = new DefaultInitialContext(); context.bind("context1/context2/name", 12); context.unbind("context1/context2/name"); context.destroySubcontext(new CompositeName("context1/context2")); }
Example #27
Source File: ResolveResult.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example #28
Source File: ResolveResult.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * 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 } }
Example #29
Source File: DefaultInitialContextTest.java From piranha with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test list method. * * @throws Exception when an error occurs. */ @Test public void testList() throws Exception { DefaultInitialContext context = new DefaultInitialContext(); Name name = new CompositeName("name"); NamingEnumeration<NameClassPair> enumeration = context.list(name); assertNotNull(enumeration); }
Example #30
Source File: DefaultInitialContextTest.java From piranha with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test listBindings method. * * @throws Exception when an error occurs. */ @Test public void testListBindings7() throws Exception { DefaultInitialContext context = new DefaultInitialContext(); context.createSubcontext("name"); NamingEnumeration<Binding> enumeration = context.listBindings(new CompositeName("name")); assertNotNull(enumeration); }