List of usage examples for java.util LinkedHashSet iterator
Iterator<E> iterator();
From source file:Main.java
public static void main(String[] args) { LinkedHashSet<Integer> lhashSet = new LinkedHashSet<Integer>(); lhashSet.add(new Integer("1")); lhashSet.add(new Integer("2")); lhashSet.add(new Integer("3")); Iterator itr = lhashSet.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); }/* w ww.jav a 2s .c om*/ }
From source file:org.openhab.binding.network.service.NetworkService.java
/** * Starts the DiscoveryThread for each IP on the Networks * * @param allNetworkIPs/*from w ww.j a v a 2 s .c om*/ */ private static void startDiscovery(final LinkedHashSet<String> networkIPs, final DiscoveryCallback discoveryCallback, ScheduledExecutorService scheduledExecutorService) { final int PING_TIMEOUT_IN_MS = 500; ExecutorService executorService = Executors .newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 10); for (Iterator<String> it = networkIPs.iterator(); it.hasNext();) { final String ip = it.next(); executorService.execute(new Runnable() { @Override public void run() { if (ip != null) { try { if (Ping.checkVitality(ip, 0, PING_TIMEOUT_IN_MS)) { discoveryCallback.newDevice(ip); } } catch (IOException e) { } } } }); } try { executorService.awaitTermination(PING_TIMEOUT_IN_MS * networkIPs.size(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { } executorService.shutdown(); }
From source file:com.wso2telco.reqpathsequencehandler.MIFERequestPathBasedSequenceHandler.java
/** * Configure mife req path authenticators. * * @param request the request// w w w. j a v a 2s .c om * @param context the context */ private void configureMIFEReqPathAuthenticators(HttpServletRequest request, AuthenticationContext context) { LinkedHashSet<?> acrs = this.getACRValues(request); String selectedLOA = (String) acrs.iterator().next(); AuthenticationLevels config = configurationService.getDataHolder().getAuthenticationLevels(); Map<String, MIFEAuthentication> authenticationMap = configurationService.getDataHolder() .getAuthenticationLevelMap(); MIFEAuthentication mifeAuthentication = authenticationMap.get(selectedLOA); List<MIFEAuthentication.MIFEAbstractAuthenticator> authenticatorList = mifeAuthentication .getAuthenticatorList(); SequenceConfig sequenceConfig = context.getSequenceConfig(); // Clear existing ReqPathAuthenticators list sequenceConfig.setReqPathAuthenticators(new ArrayList<AuthenticatorConfig>()); for (MIFEAuthentication.MIFEAbstractAuthenticator mifeAuthenticator : authenticatorList) { AuthenticatorConfig authenticatorConfig = new AuthenticatorConfig(); ApplicationAuthenticator applicationAuthenticator = FrameworkUtils .getAppAuthenticatorByName(mifeAuthenticator.getAuthenticator()); authenticatorConfig.setName(mifeAuthenticator.getAuthenticator()); authenticatorConfig.setApplicationAuthenticator(applicationAuthenticator); } context.setSequenceConfig(sequenceConfig); }
From source file:com.wso2telco.claimhandler.MIFEClaimHandler.java
@Override public Map<String, String> handleClaimMappings(StepConfig stepConfig, AuthenticationContext context, Map<String, String> remoteAttributes, boolean isFederatedClaims) throws FrameworkException { Map<String, String> localClaims = super.handleClaimMappings(stepConfig, context, remoteAttributes, isFederatedClaims);//from w ww .j ava2 s .c o m // Map<String, String> localClaims = new HashMap<String, String>(); try { String sdk = context.getCallerSessionKey(); SessionDataCacheKey sessionDataCacheKey = new SessionDataCacheKey(sdk); SessionDataCacheEntry sdce = (SessionDataCacheEntry) SessionDataCache.getInstance() .getValueFromCache(sessionDataCacheKey); localClaims.put("sessionId", context.getContextIdentifier()); // Add acr to claims map LinkedHashSet<?> acrValues = sdce.getoAuth2Parameters().getACRValues(); Iterator<?> it = acrValues.iterator(); if (null != acrValues && it.hasNext()) { String loaLevel; if (null != (loaLevel = (String) it.next())) { localClaims.put("acr", loaLevel); } } // Add amr to claims map Object amrValue = context.getProperty("amr"); if (null != amrValue && amrValue instanceof ArrayList<?>) { @SuppressWarnings("unchecked") List<String> amr = (ArrayList<String>) amrValue; if (!amr.isEmpty()) { localClaims.put("amr", amr.get(amr.size() - 1)); } else { localClaims.put("amr", ""); } } //this becomes null for scenario where user is already authenticated //ex: accessing tokens from two SPs from a same browser. user is already //authenticated for the first SP // todo: confirm this scenario if (null == amrValue) { Map<Integer, StepConfig> stepMap = context.getSequenceConfig().getStepMap(); List<String> amr = new ArrayList<String>(); for (Map.Entry<Integer, StepConfig> entry : stepMap.entrySet()) { StepConfig stpConf = entry.getValue(); if (stpConf != null && stepConfig.getAuthenticatedAutenticator().getName() != null) { amr.add(stepConfig.getAuthenticatedAutenticator().getName()); } } localClaims.put("amr", StringUtils.join(amr, ',')); } // Adding nonce to claim map String nonce = sdce.getoAuth2Parameters().getNonce(); if (DEBUG) { log.debug("nonce values from getoAuth2Parameters " + nonce); } AuthenticationRequest authRequest = context.getAuthenticationRequest(); if (authRequest.getRequestQueryParams().containsKey(IDToken.NONCE)) { if (authRequest.getRequestQueryParams().get(IDToken.NONCE).length != 0) { nonce = authRequest.getRequestQueryParams().get(IDToken.NONCE)[0]; } } if (authRequest.getRequestQueryParams().get("state").length != 0) { String state = authRequest.getRequestQueryParams().get("state")[0]; localClaims.put("state", state); if (DEBUG) { log.debug("state : " + state); } } else { if (DEBUG) { log.debug("state is empty"); } } if (DEBUG) { log.debug(" nonce values from getoAuth2Parameters " + nonce); } if (null != nonce) { localClaims.put(IDToken.NONCE, nonce); } } catch (NullPointerException e) { // Possible exception during dashboard login // Should continue even if NPE is thrown } return localClaims; }
From source file:org.agiso.tempel.core.RecursiveTemplateVerifier.java
/** * Weryfikuje poprawno szablonu, szablonu nadrzdnego i rekurencyjne * sprawdza wszystkie szablony uywane. Kontroluje, czy drzewie wywoa * szablonw nie wystpuje zaptlenie./*from w w w. ja v a2s .com*/ * * @param template Szablon do weryfikacji. * @param templates Zbir identyfikatorw szablonw gazi. Wykorzystywany * do wykrywania zaptle wywoa. */ private void verifyTemplate(Template<?> template, LinkedHashSet<String> templates) { String id = template.getKey(); // Sprawdzanie, czy w gazi wywoa szablonw nie ma zaptlenia: if (templates.contains(id)) { // Wywietlanie gazi z zaptleniem i wyrzucanie wyjtku: Iterator<String> t = templates.iterator(); System.out.print(t.next()); while (t.hasNext()) { System.out.print("->" + t.next()); } System.out.println("->" + id); throw new IllegalStateException("Zaptlenie wywoa szablonu '" + id + "'"); } // Szablon OK. Dodawanie do zbioru szablonw gazi: templates.add(id); // // Sprawdzanie kadego z podszablonw szablonu: // if(template.getReferences() != null) { // for(TemplateReference reference : template.getReferences()) { // verifyTemplate(reference, templates); // } // } }
From source file:org.tdar.core.service.BulkUploadTemplateService.java
/** * For the set of @link ResourceType entries, get all of the valid @link * BulkImportField fields that should be used. * /*from w ww. ja v a 2 s . c o m*/ * @param resourceTypes * @return */ public LinkedHashSet<CellMetadata> getAllValidFieldNames(ResourceType... resourceTypes) { List<ResourceType> resourceClasses = new ArrayList<ResourceType>(Arrays.asList(resourceTypes)); if (ArrayUtils.isEmpty(resourceTypes)) { resourceClasses = Arrays.asList(getResourceTypesSupportingBulkUpload()); } CellMetadata filename = CellMetadata.FILENAME; LinkedHashSet<CellMetadata> nameSet = new LinkedHashSet<CellMetadata>(); nameSet.add(filename); for (ResourceType clas : resourceClasses) { nameSet.addAll(reflectionService.findBulkAnnotationsOnClass(clas.getResourceClass())); } Iterator<CellMetadata> fields = nameSet.iterator(); while (fields.hasNext()) { CellMetadata field = fields.next(); String displayName = field.getDisplayName(); String key = field.getKey(); logger.trace(field.getKey() + "-" + field.getName() + " " + displayName); if (!TdarConfiguration.getInstance().getLicenseEnabled()) { if ((key.equals(InformationResource.LICENSE_TEXT) || key.equals(InformationResource.LICENSE_TYPE))) { fields.remove(); } } if (!TdarConfiguration.getInstance().getCopyrightMandatory()) { if ((key.equals(InformationResource.COPYRIGHT_HOLDER)) || displayName.contains(CellMetadata .getDisplayLabel(MessageHelper.getInstance(), InformationResource.COPYRIGHT_HOLDER))) { fields.remove(); } } } return nameSet; }
From source file:com.wso2telco.gsma.authenticators.GSMAMSISDNAuthenticator.java
@Override protected void initiateAuthenticationRequest(HttpServletRequest request, HttpServletResponse response, AuthenticationContext context) throws AuthenticationFailedException { log.info("Initiating authentication request"); // Retrieve entry LOA and set to authentication context LinkedHashSet<?> acrs = getACRValues(request); String selectedLOA = (String) acrs.iterator().next(); context.setProperty("entryLOA", selectedLOA); String loginPage = ConfigurationFacade.getInstance().getAuthenticationEndpointURL(); String queryParams = FrameworkUtils.getQueryStringWithFrameworkContextId(context.getQueryParams(), context.getCallerSessionKey(), context.getContextIdentifier()); if (log.isDebugEnabled()) { log.debug("Query parameters : " + queryParams); }//from ww w . j a v a2s . co m try { String retryParam = ""; if (context.isRetrying()) { retryParam = "&authFailure=true&authFailureMsg=login.fail.message"; } response.sendRedirect(response.encodeRedirectURL(loginPage + ("?" + queryParams)) + "&authenticators=" + getName() + ":" + "LOCAL" + retryParam); } catch (IOException e) { throw new AuthenticationFailedException(e.getMessage(), e); } }
From source file:gr.forth.ics.isl.webservice.XPathsWebservice.java
/** * Constructs a LinkedHashSet that has a Map<String,String> * to accomplish the format we want/*from w w w . ja v a 2 s.c om*/ * * @param hashSet * @return */ private LinkedHashSet<Map<String, String>> FormatHashSet(LinkedHashSet<String> hashSet) { LinkedHashSet<Map<String, String>> newHashSet = new LinkedHashSet<Map<String, String>>(); Iterator<String> it = hashSet.iterator(); for (; it.hasNext();) {//iterates HashSet //builds a map with 2 key-value pair {"id" : "", "text" : ""} Map<String, String> hashMap = new HashMap<String, String>(); String path = it.next(); hashMap.put("id", path); hashMap.put("text", path); //Stores map in the HashSet that is to be returned newHashSet.add(hashMap); } return newHashSet; }
From source file:com.geewhiz.pacify.TestCheckTargetFileExist.java
@Test public void checkRegExDoesNotMatchInArchive() throws ArchiveException, IOException { Logger logger = LogManager.getLogger(TestArchive.class.getName()); LoggingUtils.setLogLevel(logger, Level.INFO); String testFolder = "checkTargetFileExistTest/wrong/regExArchive"; LinkedHashSet<Defect> defects = createPrepareAndExecuteValidator(testFolder, createPropertyResolveManager(Collections.<String, String>emptyMap()), new CheckTargetFileExist()); Assert.assertEquals("We should get a defect.", 1, defects.size()); Assert.assertEquals("We expect FileDoesNotExistDefect", FileDoesNotExistDefect.class, defects.iterator().next().getClass()); }
From source file:org.apereo.portal.spring.security.RemoteUserSettingFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final String remoteUser = StringUtils.trimToNull(FileUtils.readFileToString(this.remoteUserFile)); if (remoteUser != null) { request = new HttpServletRequestWrapper((HttpServletRequest) request) { /* (non-Javadoc) * @see javax.servlet.http.HttpServletRequestWrapper#getRemoteUser() *//*from w w w .ja v a 2s . com*/ @Override public String getRemoteUser() { return remoteUser; } /* (non-Javadoc) * @see javax.servlet.http.HttpServletRequestWrapper#getHeader(java.lang.String) */ @Override public String getHeader(String name) { if ("REMOTE_USER".equals(name)) { return remoteUser; } return super.getHeader(name); } /* (non-Javadoc) * @see javax.servlet.http.HttpServletRequestWrapper#getHeaders(java.lang.String) */ @Override public Enumeration<String> getHeaders(String name) { if ("REMOTE_USER".equals(name)) { return Iterators.asEnumeration(Collections.singleton(remoteUser).iterator()); } return super.getHeaders(name); } /* (non-Javadoc) * @see javax.servlet.http.HttpServletRequestWrapper#getHeaderNames() */ @Override public Enumeration<String> getHeaderNames() { final LinkedHashSet<String> headers = new LinkedHashSet<String>(); for (final Enumeration<String> headersEnum = super.getHeaderNames(); headersEnum .hasMoreElements();) { headers.add(headersEnum.nextElement()); } headers.add("REMOTE_USER"); return Iterators.asEnumeration(headers.iterator()); } /* (non-Javadoc) * @see javax.servlet.http.HttpServletRequestWrapper#getIntHeader(java.lang.String) */ @Override public int getIntHeader(String name) { if ("REMOTE_USER".equals(name)) { return Integer.valueOf(remoteUser); } return super.getIntHeader(name); } }; } chain.doFilter(request, response); }