org.apache.commons.collections.iterators.IteratorEnumeration Java Examples

The following examples show how to use org.apache.commons.collections.iterators.IteratorEnumeration. 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: JdbcConfiguration.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
private void setSqlTypes() {

        @SuppressWarnings("unchecked")
        Enumeration<String> keys = new IteratorEnumeration(configuration.keySet().iterator());

        while (keys.hasMoreElements()) {
            String key = keys.nextElement();
            Matcher matcher = EXTRACT_CONFIG_PATTERN.matcher(key);
            if (!matcher.matches()) {
                continue;
            }
            matcher.reset();
            matcher.find();
            if (!matcher.group(1).equals("sqltype")) {
                continue;
            }
            String itemType = matcher.group(2);
            if (!itemType.startsWith("table")) {
              itemType = itemType.toUpperCase() + "ITEM";
            }
            String value = (String) configuration.get(key);
            logger.debug("JDBC::updateConfig: set sqlTypes: itemType={} value={}", itemType, value);
            dBDAO.sqlTypes.put(itemType, value);
        }
    }
 
Example #2
Source File: InternalMessages.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
public synchronized Enumeration<String> getKeys() {
    HashSet<String> set = new HashSet<String>(INITIAL_CAPACITY);

    addAllElements(set, messageBundle.getKeys());
    if (parent != null) {
        addAllElements(set, parent.getKeys());
    }
    return new IteratorEnumeration(set.iterator());
}
 
Example #3
Source File: RhnMockHttpSession.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Enumeration getAttributeNames() {
    return new IteratorEnumeration(attributes.keySet().iterator());
}
 
Example #4
Source File: LogsearchKRBAuthenticationFilter.java    From ambari-logsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void init(FilterConfig conf) throws ServletException {
  final FilterConfig globalConf = conf;
  String hostName = logSearchSpnegoConfig.getHostName();
  final Map<String, String> params = new HashMap<String, String>();
  if (spnegoEnable) {
    authType = KerberosAuthenticationHandler.TYPE;
  }
  params.put(AUTH_TYPE,authType);
  params.put(NAME_RULES_PARAM, logSearchSpnegoConfig.getNameRules());
  params.put(TOKEN_VALID_PARAM, logSearchSpnegoConfig.getTokenValid());
  params.put(COOKIE_DOMAIN_PARAM, logSearchSpnegoConfig.getCookieDomain());
  params.put(COOKIE_PATH_PARAM, logSearchSpnegoConfig.getCookiePath());
  params.put(PRINCIPAL_PARAM, logSearchSpnegoConfig.getPrincipal());
  params.put(KEYTAB_PARAM, logSearchSpnegoConfig.getKeyTab());
  FilterConfig myConf = new FilterConfig() {
    @Override
    public ServletContext getServletContext() {
      if (globalConf != null) {
        return globalConf.getServletContext();
      } else {
        return NO_SERVLET_CONTEXT;
      }
    }

    @SuppressWarnings("unchecked")
    @Override
    public Enumeration<String> getInitParameterNames() {
      return new IteratorEnumeration(params.keySet().iterator());
    }

    @Override
    public String getInitParameter(String param) {
      return params.get(param);
    }

    @Override
    public String getFilterName() {
      return "KerberosFilter";
    }
  };
  super.init(myConf);
}
 
Example #5
Source File: AtlasAuthenticationFilter.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
/**
 * Initialize the filter.
 *
 * @param filterConfig filter configuration.
 * @throws ServletException thrown if the filter could not be initialized.
 */
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    LOG.info("AtlasAuthenticationFilter initialization started");
    final FilterConfig globalConf = filterConfig;
    final Map<String, String> params = new HashMap<>();
    try {
        configuration = ApplicationProperties.get();
    } catch (Exception e) {
        throw new ServletException(e);
    }

    if (configuration != null) {
        headerProperties = ConfigurationConverter.getProperties(configuration.subset("atlas.headers"));
    }

    FilterConfig filterConfig1 = new FilterConfig() {
        @Override
        public ServletContext getServletContext() {
            if (globalConf != null) {
                return globalConf.getServletContext();
            } else {
                return nullContext;
            }
        }

        @SuppressWarnings("unchecked")
        @Override
        public Enumeration<String> getInitParameterNames() {
            return new IteratorEnumeration(params.keySet().iterator());
        }

        @Override
        public String getInitParameter(String param) {
            return params.get(param);
        }

        @Override
        public String getFilterName() {
            return "AtlasAuthenticationFilter";
        }
    };

    super.init(filterConfig1);

    optionsServlet = new HttpServlet() {
    };
    optionsServlet.init();
}
 
Example #6
Source File: RangerKRBAuthenticationFilter.java    From ranger with Apache License 2.0 4 votes vote down vote up
@Override
public void init(FilterConfig conf) throws ServletException {
	final FilterConfig globalConf = conf;
	final Map<String, String> params = new HashMap<String, String>();
	params.put(AUTH_TYPE, PropertiesUtil.getProperty(RANGER_AUTH_TYPE, "simple"));
	params.put(NAME_RULES_PARAM, PropertiesUtil.getProperty(NAME_RULES, "DEFAULT"));
	params.put(TOKEN_VALID_PARAM, PropertiesUtil.getProperty(TOKEN_VALID,"30"));
	params.put(COOKIE_DOMAIN_PARAM, PropertiesUtil.getProperty(COOKIE_DOMAIN, PropertiesUtil.getProperty(HOST_NAME, "localhost")));
	params.put(COOKIE_PATH_PARAM, PropertiesUtil.getProperty(COOKIE_PATH, "/"));
	params.put(ALLOW_TRUSTED_PROXY, PropertiesUtil.getProperty(ALLOW_TRUSTED_PROXY, "false"));
	params.put(RULES_MECHANISM_PARAM, PropertiesUtil.getProperty(RULES_MECHANISM, "hadoop"));
	try {
		params.put(PRINCIPAL_PARAM, SecureClientLogin.getPrincipal(PropertiesUtil.getProperty(PRINCIPAL,""), PropertiesUtil.getProperty(HOST_NAME)));
	} catch (IOException ignored) {
           // do nothing
	}
	params.put(KEYTAB_PARAM, PropertiesUtil.getProperty(KEYTAB,""));

	FilterConfig myConf = new FilterConfig() {
		@Override
		public ServletContext getServletContext() {
			if (globalConf != null) {
				return globalConf.getServletContext();
			} else {
				return noContext;
			}
		}

		@SuppressWarnings("unchecked")
		@Override
		public Enumeration<String> getInitParameterNames() {
			return new IteratorEnumeration(params.keySet().iterator());
		}

		@Override
		public String getInitParameter(String param) {
			return params.get(param);
		}

		@Override
		public String getFilterName() {
			return "KerberosFilter";
		}
	};
	super.init(myConf);
	Configuration conf1 = this.getProxyuserConfiguration();
	ProxyUsers.refreshSuperUserGroupsConfiguration(conf1, PROXY_PREFIX);
}
 
Example #7
Source File: KualiActionServlet.java    From rice with Educational Community License v2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Enumeration<String> getInitParameterNames() {
          return new IteratorEnumeration( initParameters.keySet().iterator() );
      }
 
Example #8
Source File: IteratorUtils.java    From Penetration_Testing_POC with Apache License 2.0 3 votes vote down vote up
/**
 * Gets an enumeration that wraps an iterator.
 *
 * @param iterator  the iterator to use, not null
 * @return a new enumeration
 * @throws NullPointerException if iterator is null
 */
public static Enumeration asEnumeration(Iterator iterator) {
    if (iterator == null) {
        throw new NullPointerException("Iterator must not be null");
    }
    return new IteratorEnumeration(iterator);
}