@SuppressWarnings("unchecked") public static List<String> getAliases() { LOGGER.entering(KeyStoreTool.class.getName(), "getAliases"); List<String> result = new LinkedList<String>(); try { result.addAll(EnumerationUtils.toList(keyStore.aliases())); } catch (Exception e) { LOGGER.log(Level.WARNING, "Error while reading aliases.", e); } LOGGER.exiting(KeyStoreTool.class.getName(), "getAliases", result); return result; }
/** * Filter {@link JarEntry} list from {@link JarFile} * * @param jarFile * {@link JarFile} * @param jarEntryFilter * {@link JarEntryFilter} * @return Read-only List */ @Nonnull public static List<JarEntry> filter(JarFile jarFile, JarEntryFilter jarEntryFilter) { if (jarFile == null) { return Collections.emptyList(); } Enumeration<JarEntry> jarEntries = jarFile.entries(); List<JarEntry> jarEntriesList = EnumerationUtils.toList(jarEntries); return doFilter(jarEntriesList, jarEntryFilter); }
/** * This is a workaround after upgrading to CXF 2.7.0 whereby we could no longer just call "setHideServiceList" on * the ServletController. Instead, it is now reading this information from the ServletConfig, so wrapping the base * ServletContext to return true or false for hide service list depending on whether or not we are in dev mode. */ protected ServletConfig getCXFServletConfig(final ServletConfig baseServletConfig) { // disable handling of URLs ending in /services which display CXF generated service lists if we are not in dev mode final String shouldHide = Boolean.toString(!ConfigContext.getCurrentContextConfig().getDevMode().booleanValue()); return new ServletConfig() { private static final String HIDE_SERVICE_LIST_PAGE_PARAM = "hide-service-list-page"; @Override public String getServletName() { return baseServletConfig.getServletName(); } @Override public ServletContext getServletContext() { return baseServletConfig.getServletContext(); } @Override public String getInitParameter(String parameter) { if (HIDE_SERVICE_LIST_PAGE_PARAM.equals(parameter)) { return shouldHide; } return baseServletConfig.getInitParameter(parameter); } @Override public Enumeration<String> getInitParameterNames() { List<String> initParameterNames = EnumerationUtils.toList(baseServletConfig.getInitParameterNames()); initParameterNames.add(HIDE_SERVICE_LIST_PAGE_PARAM); return new Vector<String>(initParameterNames).elements(); } }; }
@Read public Patient read(@IdParam IdDt theId, HttpServletRequest theRequest) { Patient retVal = new Patient(); retVal.setId(theId); ourRequest = theRequest; ourLog.info(EnumerationUtils.toList(ourRequest.getHeaderNames()).toString()); ourLog.info("Proxy-Connection: " + EnumerationUtils.toList(ourRequest.getHeaders("Proxy-Connection"))); ourLog.info("Host: " + EnumerationUtils.toList(ourRequest.getHeaders("Host"))); ourLog.info("User-Agent: " + EnumerationUtils.toList(ourRequest.getHeaders("User-Agent"))); return retVal; }
@Read public Patient read(@IdParam IdType theId, HttpServletRequest theRequest) { Patient retVal = new Patient(); retVal.setId(theId); ourRequest = theRequest; ourLog.info(EnumerationUtils.toList(ourRequest.getHeaderNames()).toString()); ourLog.info("Proxy-Connection: " + EnumerationUtils.toList(ourRequest.getHeaders("Proxy-Connection"))); ourLog.info("Host: " + EnumerationUtils.toList(ourRequest.getHeaders("Host"))); ourLog.info("User-Agent: " + EnumerationUtils.toList(ourRequest.getHeaders("User-Agent"))); return retVal; }
@SuppressWarnings("unchecked") public static List<Pair<String, String>> extractHeaders(HttpServletRequest httpServletRequest) { List<Pair<String, String>> result = new ArrayList<>(); for (String headerName : (List<String>) EnumerationUtils.toList(httpServletRequest.getHeaderNames())) { result.add(Pair.of(headerName, httpServletRequest.getHeader(headerName))); } return result; }
/** * Gets all aliases in the {@link KeyStore}. */ @SuppressWarnings(UNCHECKED) public Collection<String> getAliases() { try { return EnumerationUtils.toList(crypto.getKeyStore().aliases()); } catch (KeyStoreException e) { // no way to recover throw new RuntimeException(e); } }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); ServletOutputStream out = resp.getOutputStream(); List<String> list = EnumerationUtils.toList(req.getHeaderNames()); for (String key : list) { out.print(String.format("%s = %s <br>", key, req.getHeader(key))); } out.flush(); }
@SuppressWarnings({ "unchecked" }) @Override public Collection<Object> getAttributeKeys() throws InvalidSessionException { return EnumerationUtils.toList( request.getAttributeNames() ); }
/** * Get the resource URLs Set under specified resource name and type * * @param classLoader * ClassLoader * @param resourceType * {@link ResourceType} Enum * @param resourceName * resource name ,e.g : <br /> <ul> <li>Resource Name :<code>"/com/abc/def.log"</code></li> <li>Class Name : * <code>"java.lang.String"</code></li> </ul> * @return the resource URL under specified resource name and type * @throws NullPointerException * If any argument is <code>null</code> * @throws IOException * @version 1.0.0 * @since 1.0.0 */ public static Set<URL> getResources(ClassLoader classLoader, ResourceType resourceType, String resourceName) throws NullPointerException, IOException { String normalizedResourceName = resourceType.resolve(resourceName); Enumeration<URL> resources = classLoader.getResources(normalizedResourceName); return resources != null && resources.hasMoreElements() ? Sets.newLinkedHashSet(EnumerationUtils.toList(resources)) : Collections.<URL>emptySet(); }