use of javax.naming.CompositeName in project Payara by payara.
the class WARDirContext method loadEntries.
/**
* Constructs a tree of the entries contained in a WAR file.
*/
protected void loadEntries() {
try {
Enumeration<? extends ZipEntry> entryList = base.entries();
entries = new Entry("/", new ZipEntry("/"));
while (entryList.hasMoreElements()) {
ZipEntry entry = entryList.nextElement();
String name = normalize(entry);
int pos = name.lastIndexOf('/');
// Check that parent entries exist and, if not, create them.
// This fixes a bug for war files that don't record separate
// zip entries for the directories.
int currentPos = -1;
int lastPos = 0;
while ((currentPos = name.indexOf('/', lastPos)) != -1) {
Name parentName = new CompositeName(name.substring(0, lastPos));
Name childName = new CompositeName(name.substring(0, currentPos));
String entryName = name.substring(lastPos, currentPos);
// Parent should have been created in last cycle through
// this loop
Entry parent = treeLookup(parentName);
Entry child = treeLookup(childName);
if (child == null) {
// Create a new entry for missing entry and strip off
// the leading '/' character and appended on by the
// normalize method and add '/' character to end to
// signify that it is a directory entry
String zipName = name.substring(1, currentPos) + "/";
child = new Entry(entryName, new ZipEntry(zipName));
if (parent != null)
parent.addChild(child);
}
// Increment lastPos
lastPos = currentPos + 1;
}
String entryName = name.substring(pos + 1, name.length());
Name compositeName = new CompositeName(name.substring(0, pos));
Entry parent = treeLookup(compositeName);
Entry child = new Entry(entryName, entry);
if (parent != null)
parent.addChild(child);
}
} catch (Exception e) {
}
}
use of javax.naming.CompositeName in project Payara by payara.
the class GlassfishNamingManagerImpl method publishCosNamingObject.
@Override
public void publishCosNamingObject(String name, Object obj, boolean rebind) throws NamingException {
Name nameObj = new CompositeName(name);
// Create any COS naming sub-contexts in name
// that don't already exist.
createSubContexts(nameObj, getCosContext());
if (rebind) {
getCosContext().rebind(name, obj);
} else {
getCosContext().bind(name, obj);
}
// Bind a reference to it in the SerialContext using
// the same name. This is needed to allow standalone clients
// to lookup the object using the same JNDI name.
// It is also used from bindObjects while populating ejb-refs in
// the java:comp namespace.
Object serialObj = new Reference("reference", new StringRefAddr("url", name), IIOPOBJECT_FACTORY, null);
publishObject(name, serialObj, rebind);
}
use of javax.naming.CompositeName in project geronimo-xbean by apache.
the class AbstractContext method composeName.
public String composeName(String name, String prefix) throws NamingException {
if (name == null)
throw new NullPointerException("name is null");
if (prefix == null)
throw new NullPointerException("prefix is null");
CompositeName result = new CompositeName(prefix);
result.addAll(new CompositeName(name));
return result.toString();
}
use of javax.naming.CompositeName in project Payara by payara.
the class LDAPRealm method userSearch.
/**
* Do anonymous search for the user. Should be unique if exists.
*/
private String userSearch(DirContext ctx, String baseDN, String filter) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINE, "search: baseDN: " + baseDN + " filter: " + filter);
}
String foundDN = null;
NamingEnumeration namingEnum = null;
SearchControls ctls = new SearchControls();
ctls.setReturningAttributes(_dnOnly);
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
ctls.setCountLimit(1);
try {
namingEnum = ctx.search(baseDN, filter, ctls);
if (namingEnum.hasMore()) {
SearchResult res = (SearchResult) namingEnum.next();
StringBuffer sb = new StringBuffer();
// for dn name with '/'
CompositeName compDN = new CompositeName(res.getName());
String ldapDN = compDN.get(0);
sb.append(ldapDN);
if (res.isRelative()) {
sb.append(",");
sb.append(baseDN);
}
foundDN = sb.toString();
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINE, "Found user DN: " + foundDN);
}
}
} catch (Exception e) {
_logger.log(Level.WARNING, "ldaprealm.searcherror", filter);
_logger.log(Level.WARNING, "security.exception", e);
} finally {
if (namingEnum != null) {
try {
namingEnum.close();
} catch (Exception ex) {
}
}
}
return foundDN;
}
use of javax.naming.CompositeName in project rabbitmq-jms-client by rabbitmq.
the class RMQConnectionFactoryTest method testConnectionFactoryRegeneration.
@Test
public void testConnectionFactoryRegeneration() throws Exception {
RMQConnectionFactory connFactory = new RMQConnectionFactory();
connFactory.setHost("sillyHost");
connFactory.setPassword("my-password");
connFactory.setPort(42);
connFactory.setQueueBrowserReadMax(52);
connFactory.setSsl(true);
connFactory.setTerminationTimeout(1234567890123456789L);
connFactory.setUsername("fred");
connFactory.setVirtualHost("bill");
Reference ref = connFactory.getReference();
RMQConnectionFactory newFactory = (RMQConnectionFactory) new RMQObjectFactory().createConnectionFactory(ref, new Hashtable<Object, Object>(), new CompositeName("newOne"));
assertEquals("amqps://fred:my-password@sillyHost:42/bill", newFactory.getUri(), "Not the correct uri");
assertEquals("sillyHost", newFactory.getHost(), "Not the correct host");
assertEquals("my-password", newFactory.getPassword(), "Not the correct password");
assertEquals(42, newFactory.getPort(), "Not the correct port");
assertEquals(52, newFactory.getQueueBrowserReadMax(), "Not the correct queueBrowserReadMax");
assertEquals(true, newFactory.isSsl(), "Not the correct ssl");
assertEquals(15000L, newFactory.getTerminationTimeout(), "Not the correct terminationTimeout");
assertEquals("fred", newFactory.getUsername(), "Not the correct username");
assertEquals("bill", newFactory.getVirtualHost(), "Not the correct virtualHost");
}
Aggregations