List of usage examples for java.util Collections enumeration
public static <T> Enumeration<T> enumeration(final Collection<T> c)
From source file:org.apache.wicket.protocol.http.mock.MockHttpServletRequest.java
/** * Get the names of all of the parameters. * /*from ww w . j av a 2s . c o m*/ * @return The parameter names */ @Override public Enumeration<String> getParameterNames() { return Collections.enumeration(getParameterMap().keySet()); }
From source file:org.apache.openejb.util.classloader.URLClassLoaderFirst.java
public static Enumeration<URL> filterResources(final String name, final Enumeration<URL> result) { if (isFilterableResource(name)) { final Collection<URL> values = Collections.list(result); if (values.size() > 1) { // remove openejb one final URL url = URLClassLoaderFirst.class.getResource("/" + name); if (url != null) { values.remove(url);//from w w w . ja v a2 s . c om } } return Collections.enumeration(values); } return result; }
From source file:org.sakaiproject.entitybroker.util.http.EntityHttpServletRequest.java
public Enumeration getHeaderNames() { return Collections.enumeration(headers.keySet()); }
From source file:org.sakaiproject.entitybroker.util.http.EntityHttpServletRequest.java
public Enumeration getHeaders(String name) { if (name == null || "".equals(name)) { throw new IllegalArgumentException("name cannot be null"); }/*from w ww .ja v a 2 s . co m*/ Vector<String> h = new Vector<String>(0); if (headers.containsKey(name)) { Vector<String> v = headers.get(name); if (v != null) { h = v; } } return Collections.enumeration(h); }
From source file:de.ingrid.admin.Config.java
@SuppressWarnings("rawtypes") public void writePlugdescriptionToProperties(PlugdescriptionCommandObject pd) { try {//ww w. j ava 2 s .c om Resource override = getOverrideConfigResource(); InputStream is = new FileInputStream(override.getFile().getAbsolutePath()); Properties props = new Properties() { private static final long serialVersionUID = 6956076060462348684L; @Override public synchronized Enumeration<Object> keys() { return Collections.enumeration(new TreeSet<Object>(super.keySet())); } }; props.load(is); for (Iterator<Object> it = pd.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); // do not write properties from plug description we do not want if (IGNORE_LIST.contains(key)) continue; Object valObj = pd.get(key); if (valObj instanceof String) { props.setProperty("plugdescription." + key, (String) valObj); } else if (valObj instanceof List) { props.setProperty("plugdescription." + key, convertListToString((List) valObj)); } else if (valObj instanceof Integer) { if ("IPLUG_ADMIN_GUI_PORT".equals(key)) { props.setProperty("jetty.port", String.valueOf(valObj)); } else { props.setProperty("plugdescription." + key, String.valueOf(valObj)); } } else if (valObj instanceof File) { props.setProperty("plugdescription." + key, ((File) valObj).getPath()); } else { if (valObj != null) { props.setProperty("plugdescription." + key, valObj.toString()); } else { log.warn("value of plugdescription field was NULL: " + key); } } } // always write working dir as relative path if it was set as such String workDir = pd.getRealWorkingDir(); if (workDir == null) { workDir = pd.getWorkinDirectory() == null ? "." : pd.getWorkinDirectory().getPath(); } props.setProperty("plugdescription.workingDirectory", workDir); props.setProperty("plugdescription.queryExtensions", convertQueryExtensionsToString(this.queryExtensions)); props.setProperty("index.searchInTypes", StringUtils.join(this.indexSearchInTypes, ',')); setDatatypes(props); IConfig externalConfig = JettyStarter.getInstance().getExternalConfig(); if (externalConfig != null) { externalConfig.setPropertiesFromPlugdescription(props, pd); externalConfig.addPlugdescriptionValues(pd); } // --------------------------- is.close(); try (OutputStream os = new FileOutputStream(override.getFile().getAbsolutePath())) { if (log.isDebugEnabled()) { log.debug("writing configuration to: " + override.getFile().getAbsolutePath()); } props.store(os, "Override configuration written by the application"); } } catch (Exception e) { log.error("Error writing properties:", e); } }
From source file:org.wso2.carbon.identity.oauth.endpoint.token.OAuth2TokenEndpointTest.java
@Test(dataProvider = "testGetAccessTokenDataProvider") public void testGetAccessToken(String grantType, String additionalParameters) throws Exception { Map<String, String[]> requestParams = new HashMap<>(); requestParams.put(OAuth.OAUTH_CLIENT_ID, new String[] { CLIENT_ID_VALUE }); requestParams.put(OAuth.OAUTH_GRANT_TYPE, new String[] { grantType }); requestParams.put(OAuth.OAUTH_SCOPE, new String[] { "scope1" }); // Required params for authorization_code grant type requestParams.put(OAuth.OAUTH_REDIRECT_URI, new String[] { APP_REDIRECT_URL }); requestParams.put(OAuth.OAUTH_CODE, new String[] { "auth_code" }); // Required params for password grant type requestParams.put(OAuth.OAUTH_USERNAME, new String[] { USERNAME }); requestParams.put(OAuth.OAUTH_PASSWORD, new String[] { "password" }); // Required params for refresh token grant type requestParams.put(OAuth.OAUTH_REFRESH_TOKEN, new String[] { REFRESH_TOKEN }); // Required params for saml2 bearer grant type requestParams.put(OAuth.OAUTH_ASSERTION, new String[] { "dummyAssertion" }); // Required params for IWA_NLTM grant type requestParams.put(OAuthConstants.WINDOWS_TOKEN, new String[] { "dummyWindowsToken" }); HttpServletRequest request = mockHttpRequest(requestParams, new HashMap<String, Object>()); when(request.getHeader(OAuthConstants.HTTP_REQ_HEADER_AUTHZ)).thenReturn(AUTHORIZATION_HEADER); when(request.getHeaderNames()).thenReturn(Collections.enumeration(new ArrayList<String>() { {/*ww w . j av a2 s . c om*/ add(OAuthConstants.HTTP_REQ_HEADER_AUTHZ); } })); Map<String, Class<? extends OAuthValidator<HttpServletRequest>>> grantTypeValidators = new Hashtable<>(); grantTypeValidators.put(GrantType.PASSWORD.toString(), PasswordValidator.class); grantTypeValidators.put(GrantType.CLIENT_CREDENTIALS.toString(), ClientCredentialValidator.class); grantTypeValidators.put(GrantType.AUTHORIZATION_CODE.toString(), AuthorizationCodeValidator.class); grantTypeValidators.put(GrantType.REFRESH_TOKEN.toString(), RefreshTokenValidator.class); grantTypeValidators.put(org.wso2.carbon.identity.oauth.common.GrantType.IWA_NTLM.toString(), NTLMAuthenticationValidator.class); grantTypeValidators.put(org.wso2.carbon.identity.oauth.common.GrantType.SAML20_BEARER.toString(), SAML2GrantValidator.class); mockOAuthServerConfiguration(); when(oAuthServerConfiguration.getSupportedGrantTypeValidators()).thenReturn(grantTypeValidators); spy(EndpointUtil.class); doReturn(oAuth2Service).when(EndpointUtil.class, "getOAuth2Service"); final Map<String, String> parametersSetToRequest = new HashMap<>(); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { OAuth2AccessTokenReqDTO request = (OAuth2AccessTokenReqDTO) invocation.getArguments()[0]; parametersSetToRequest.put(OAuth.OAUTH_CODE, request.getAuthorizationCode()); parametersSetToRequest.put(OAuth.OAUTH_USERNAME, request.getResourceOwnerUsername()); parametersSetToRequest.put(OAuth.OAUTH_PASSWORD, request.getResourceOwnerPassword()); parametersSetToRequest.put(OAuth.OAUTH_REFRESH_TOKEN, request.getRefreshToken()); parametersSetToRequest.put(OAuth.OAUTH_ASSERTION, request.getAssertion()); parametersSetToRequest.put(OAuthConstants.WINDOWS_TOKEN, request.getWindowsToken()); parametersSetToRequest.put(OAuth.OAUTH_GRANT_TYPE, request.getGrantType()); OAuth2AccessTokenRespDTO tokenRespDTO = new OAuth2AccessTokenRespDTO(); return tokenRespDTO; } }).when(oAuth2Service).issueAccessToken(any(OAuth2AccessTokenReqDTO.class)); CarbonOAuthTokenRequest oauthRequest = new CarbonOAuthTokenRequest(request); Class<?> clazz = OAuth2TokenEndpoint.class; Object tokenEndpointObj = clazz.newInstance(); Method getAccessToken = tokenEndpointObj.getClass().getDeclaredMethod("issueAccessToken", CarbonOAuthTokenRequest.class); getAccessToken.setAccessible(true); OAuth2AccessTokenRespDTO tokenRespDTO = (OAuth2AccessTokenRespDTO) getAccessToken.invoke(tokenEndpointObj, oauthRequest); assertNotNull(tokenRespDTO, "ResponseDTO is null"); String[] paramsToCheck = additionalParameters.split(","); for (String param : paramsToCheck) { assertNotNull(parametersSetToRequest.get(param), "Required parameter " + param + " is not set for " + grantType + "grant type"); } }
From source file:net.lightbody.bmp.proxy.jetty.http.HttpContext.java
/** Get context init parameter. * @return Enumeration of names */ public Enumeration getInitParameterNames() { return Collections.enumeration(_initParams.keySet()); }
From source file:org.ireland.jnetty.http.HttpServletRequestImpl.java
@Override // OK public Enumeration<String> getHeaderNames() { return Collections.enumeration(headers.names()); }
From source file:org.xwoot.jxta.JxtaPeer.java
/** {@inheritDoc} **/ public Enumeration<Advertisement> getKnownDirectCommunicationPipeAdvertisements() { Enumeration<Advertisement> en = this.getKnownAdvertisements(PipeAdvertisement.NameTag, this.getDirectCommunicationPipeNamePrefix() + "*"); ArrayList<Advertisement> pipeAdvs = new ArrayList<Advertisement>(); while (en.hasMoreElements()) { Advertisement adv = en.nextElement(); // Get only PipeAdvertisements that are different from this peer's. if (adv instanceof PipeAdvertisement) { PipeAdvertisement pipeAdv = (PipeAdvertisement) adv; if (!pipeAdv.equals(this.getMyDirectCommunicationPipeAdvertisement()) && pipeAdv.getName().startsWith(this.getDirectCommunicationPipeNamePrefix())) { pipeAdvs.add(adv);//from w w w.ja v a 2 s. c o m } } } return Collections.enumeration(pipeAdvs); }
From source file:net.lightbody.bmp.proxy.jetty.http.HttpMessage.java
/** Get Attribute names. * @return Enumeration of Strings/*from ww w .j av a 2 s. c o m*/ */ public Enumeration getAttributeNames() { if (_attributes == null) return Collections.enumeration(Collections.EMPTY_LIST); return Collections.enumeration(_attributes.keySet()); }