List of usage examples for javax.naming NamingEnumeration nextElement
E nextElement();
From source file:com.globalsight.everest.usermgr.UserLdapHelper.java
static List getListOfEmailInfo(NamingEnumeration p_searchResults) throws NamingException { List result = new ArrayList(); while (p_searchResults.hasMoreElements()) { Object searchResultObj = p_searchResults.nextElement(); if (searchResultObj instanceof SearchResult) { SearchResult tmpSearchResult = (SearchResult) searchResultObj; Attributes entry = tmpSearchResult.getAttributes(); result.add(getUserEmailInfo(entry)); }//from ww w .j a va2 s .c o m } p_searchResults.close(); return result.size() == 0 ? null : result; }
From source file:org.viafirma.cliente.util.ConfigUtil.java
/** * Recupera el conjunto de propiedades que utiliza la aplicacin. * @param context// ww w. j av a2 s. co m * @return */ public Properties readConfigPropertes() { Properties properties = new Properties(); Context initCtx; try { // carcamos la configuracin por defecto properties.load(getClass().getResourceAsStream("/viafirmaConfig.properties")); // recuperamos la configuracin almacenada en el contexto de aplicacin initCtx = new InitialContext(); Context contextInit = (Context) initCtx.lookup("java:comp/env"); // recuperamos ahora todos los parametros JNDI que estan en el raiz de la aplicacin NamingEnumeration<NameClassPair> propiedadesJDNI = contextInit.list(""); while (propiedadesJDNI.hasMoreElements()) { NameClassPair propiedad = propiedadesJDNI.nextElement(); Object temp = contextInit.lookup(propiedad.getName()); if (temp instanceof String) { if (propiedad.getName().startsWith("SYSTEM_")) { String valor = (String) temp; String nombre = StringUtils.substringAfter(propiedad.getName(), "SYSTEM_"); System.getProperties().put(nombre, valor); properties.put(nombre, valor); } else { String valor = (String) temp; properties.put(propiedad.getName(), valor); } } } for (Object key : properties.keySet()) { if (((String) key).contains("PASSWORD")) { System.out.println("\t\t\t" + key + "=***"); } else { System.out.println("\t\t\t" + key + "=" + properties.get(key)); } } } catch (Exception e) { log.error("No se pueden recuperar los parametros de configuracin. JNDI parece no estar disponible. " + e.getMessage()); //Permitimos el arranque de la aplicacin utilizando la configuracin de los properties. //throw new ExceptionInInitializerError("No se pueden recuperar los parametros de configuracin. JNDI parece no estar disponible."+e.getMessage()); } return properties; }
From source file:org.netoprise.neo4j.ConnectorTest.java
@Test @Ignore/*from w w w .j a v a 2 s . c o m*/ @OperateOnDeployment("test") public void listJNDI() { try { Context context = new InitialContext(); System.out.println("Context namespace: " + context.getNameInNamespace()); NamingEnumeration<NameClassPair> content = context.list("comp"); while (content.hasMoreElements()) { NameClassPair nameClassPair = (NameClassPair) content.nextElement(); System.out .println("Name :" + nameClassPair.getName() + " with type:" + nameClassPair.getClassName()); } } catch (NamingException e) { throw new RuntimeException(e); } }
From source file:org.picketlink.idm.performance.TestBase.java
public void removeContext(Context mainCtx, String name) throws Exception { Context deleteCtx = (Context) mainCtx.lookup(name); NamingEnumeration subDirs = mainCtx.listBindings(name); while (subDirs.hasMoreElements()) { Binding binding = (Binding) subDirs.nextElement(); String subName = binding.getName(); removeContext(deleteCtx, subName); }// w ww . j a v a2s. c om mainCtx.unbind(name); }
From source file:org.nuxeo.ecm.platform.io.test.TestIORemoteCopy.java
@Before public void setUp() throws Exception { System.setProperty("org.nuxeo.runtime.streaming.isServer", "false"); System.setProperty("org.nuxeo.runtime.server.port", "62475"); System.setProperty("org.nuxeo.runtime.server.host", "localhost"); System.setProperty("org.nuxeo.runtime.streaming.serverLocator", STREAM_SERVER_URL); super.setUp(); // the core bundle deployContrib("org.nuxeo.ecm.core", "OSGI-INF/CoreService.xml"); deployContrib("org.nuxeo.ecm.platform.io.core.tests", "TypeService.xml"); deployContrib("org.nuxeo.ecm.core", "OSGI-INF/SecurityService.xml"); deployContrib("org.nuxeo.ecm.platform.io.core.tests", "RepositoryService.xml"); deployContrib("org.nuxeo.ecm.platform.io.core.tests", "test-CoreExtensions.xml"); deployContrib("org.nuxeo.ecm.platform.io.core.tests", "CoreEventListenerService.xml"); // repo test case misc deployContrib("org.nuxeo.ecm.platform.io.core.tests", "DefaultPlatform.xml"); deployContrib("org.nuxeo.ecm.platform.io.core.tests", "RepositoryManager.xml"); deployContrib("org.nuxeo.ecm.platform.io.core.tests", "LifeCycleCoreExtensions.xml"); deployContrib("org.nuxeo.ecm.platform.io.core.tests", "LifeCycleService.xml"); // specific files deployContrib("org.nuxeo.ecm.platform.io.core.tests", "io-test-framework.xml"); deployContrib("org.nuxeo.ecm.platform.io.core.tests", "io-test-contrib.xml"); deployContrib("org.nuxeo.ecm.platform.io.core.tests", "RemotingService.xml"); deployContrib("org.nuxeo.ecm.platform.io.core.tests", "JBossLoginConfig.xml"); // donnot : deployContrib("StreamingServer.xml"); deployBundle("org.nuxeo.ecm.relations.api"); deployBundle("org.nuxeo.ecm.relations"); deployBundle("org.nuxeo.ecm.relations.jena"); deployBundle("org.nuxeo.ecm.platform.comment.api"); deployBundle("org.nuxeo.ecm.platform.comment"); InitialContext ctx1 = new InitialContext(); System.err.println(ctx1.lookup("java:/comment-relations")); NamingEnumeration<NameClassPair> en = ctx1.list("/"); while (en.hasMore()) { Object o = en.nextElement(); System.err.println(o);//from w w w . ja v a 2 s . c o m } deployContrib("org.nuxeo.ecm.platform.io.core.tests", "commentService-config-bundle.xml"); Map<String, Serializable> ctx = new HashMap<String, Serializable>(); ctx.put("username", SecurityConstants.ADMINISTRATOR); coreSession = CoreInstance.getInstance().open(localRepositoryName, ctx); ioService = Framework.getService(IOManager.class); }
From source file:com.globalsight.everest.usermgr.UserLdapHelper.java
/** * Get the Uset ID array from a NamingEnumeration *///from w ww . ja va2s.com static Vector getUIDsVectorFromSearchResults(NamingEnumeration p_SearchResults) throws NamingException { Vector uids = new Vector(); while (p_SearchResults.hasMoreElements()) { /* Next directory entry */ Object searchResultObj = p_SearchResults.nextElement(); if (searchResultObj instanceof SearchResult) { SearchResult tempSearchResult = (SearchResult) searchResultObj; Attributes entry = tempSearchResult.getAttributes(); String uid = getSingleAttributeValue(entry.get(LDAP_ATTR_USERID)); uids.addElement(uid); } } p_SearchResults.close(); return uids; }
From source file:org.apache.cloudstack.ldap.ADLdapUserManagerImpl.java
@Override public List<LdapUser> getUsersInGroup(String groupName, LdapContext context) throws NamingException { if (StringUtils.isBlank(groupName)) { throw new IllegalArgumentException("ldap group name cannot be blank"); }//from ww w .j a v a 2 s . c o m String basedn = _ldapConfiguration.getBaseDn(); if (StringUtils.isBlank(basedn)) { throw new IllegalArgumentException("ldap basedn is not configured"); } final SearchControls searchControls = new SearchControls(); searchControls.setSearchScope(_ldapConfiguration.getScope()); searchControls.setReturningAttributes(_ldapConfiguration.getReturnAttributes()); NamingEnumeration<SearchResult> results = context.search(basedn, generateADGroupSearchFilter(groupName), searchControls); final List<LdapUser> users = new ArrayList<LdapUser>(); while (results.hasMoreElements()) { final SearchResult result = results.nextElement(); users.add(createUser(result)); } return users; }
From source file:com.globalsight.everest.usermgr.UserLdapHelper.java
static Vector getNamesVectorFromSearchResults(NamingEnumeration p_SearchResults) throws NamingException { Vector userNames = new Vector(); while (p_SearchResults.hasMoreElements()) { /* Next directory entry */ Object searchResultObj = p_SearchResults.nextElement(); if (searchResultObj instanceof SearchResult) { SearchResult tempSearchResult = (SearchResult) searchResultObj; Attributes entry = tempSearchResult.getAttributes(); String userName = getSingleAttributeValue(entry.get(LDAP_ATTR_USER_NAME)); userNames.addElement(userName); }//from ww w. j a v a 2s .com } p_SearchResults.close(); return userNames; }
From source file:com.globalsight.everest.usermgr.UserLdapHelper.java
/** * Generates a collection of UserInfo objects from a NamingEnumeration after * a search is carried out./*from w w w . ja va 2 s .c om*/ */ static Vector getUserInfosFromSearchResults(NamingEnumeration p_SearchResults) throws NamingException { Vector userInfoList = new Vector(); while (p_SearchResults.hasMoreElements()) { /* Next directory entry */ Object searchResultObj = p_SearchResults.nextElement(); if (searchResultObj instanceof SearchResult) { SearchResult tempSearchResult = (SearchResult) searchResultObj; Attributes entry = tempSearchResult.getAttributes(); userInfoList.addElement(getUserInfoFromLDAPEntry(entry)); } } p_SearchResults.close(); return userInfoList; }
From source file:com.globalsight.everest.usermgr.UserLdapHelper.java
/** * Generates a collection of User objects from a NamingEnumeration after a * search is carried out./*from w w w . j a v a 2s. com*/ */ static Vector<User> getUsersFromSearchResults(NamingEnumeration p_SearchResults) throws NamingException { Vector<User> userList = new Vector<User>(); while (p_SearchResults.hasMoreElements()) { /* Next directory entry */ Object searchResultObj = p_SearchResults.nextElement(); if (searchResultObj instanceof SearchResult) { SearchResult tempSearchResult = (SearchResult) searchResultObj; Attributes entry = tempSearchResult.getAttributes(); userList.addElement(getUserFromLDAPEntry(entry)); } } p_SearchResults.close(); return userList; }