List of usage examples for java.util Map remove
V remove(Object key);
From source file:com.centurylink.mdw.services.util.AuthUtils.java
/** * <p>//from w w w . jav a2 s . c o m * Currently uses the metainfo property "Authorization" and checks * specifically for Basic Authentication or MDW-JWT Authentication. * In the future, probably change this. * </p> * <p> * TODO: call this from every protocol channel * If nothing else we should to this to avoid spoofing the AUTHENTICATED_USER_HEADER. * </p> * @param headers * @return */ private static boolean authenticateAuthorizationHeader(Map<String, String> headers) { String hdr = headers.get(Listener.AUTHORIZATION_HEADER_NAME); if (hdr == null) hdr = headers.get(Listener.AUTHORIZATION_HEADER_NAME.toLowerCase()); headers.remove(Listener.AUTHORIZATION_HEADER_NAME); headers.remove(Listener.AUTHORIZATION_HEADER_NAME.toLowerCase()); if (hdr != null && hdr.startsWith("Basic")) return checkBasicAuthenticationHeader(hdr, headers); else if (hdr != null && hdr.startsWith("Bearer")) return checkBearerAuthenticationHeader(hdr, headers); return false; }
From source file:com.pkrete.xrd4j.rest.util.ClientUtil.java
/** * Builds the target URL based on the given based URL and parameters Map. * @param url base URL// w w w. java2s .co m * @param params URL parameters * @return comlete URL containing the base URL with all the parameters * appended */ public static String buildTargetURL(String url, Map<String, String> params) { logger.debug("Target URL : \"{}\".", url); if (params == null || params.isEmpty()) { logger.debug("URL parameters list is null or empty. Nothing to do here. Return target URL."); return url; } if (params.containsKey("resourceId")) { logger.debug("Resource ID found from parameters map. Resource ID value : \"{}\".", params.get("resourceId")); if (!url.endsWith("/")) { url += "/"; } url += params.get("resourceId"); params.remove("resourceId"); logger.debug("Resource ID added to URL : \"{}\".", url); } StringBuilder paramsString = new StringBuilder(); for (String key : params.keySet()) { if (paramsString.length() > 0) { paramsString.append("&"); } paramsString.append(key).append("=").append(params.get(key)); logger.debug("Parameter : \"{}\"=\"{}\"", key, params.get(key)); } if (!url.contains("?") && !params.isEmpty()) { url += "?"; } else if (url.contains("?") && !params.isEmpty()) { if (!url.endsWith("?") && !url.endsWith("&")) { url += "&"; } } url += paramsString.toString(); logger.debug("Request parameters added to URL : \"{}\".", url); return url; }
From source file:edu.cornell.mannlib.vitro.webapp.beans.VClassGroup.java
public static void removeEmptyClassGroups(Map groups) { if (groups == null) return;//from w w w. ja v a 2 s .c o m List keysToRemove = new LinkedList(); Iterator it = groups.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); Object grp = groups.get(key); if (grp != null && grp instanceof AbstractCollection) { if (((AbstractCollection) grp).isEmpty()) keysToRemove.add(key); } } it = keysToRemove.iterator(); while (it.hasNext()) { groups.remove(it.next()); } }
From source file:org.grails.datastore.mapping.core.DatastoreUtils.java
/** * Process all Datastore Sessions that have been registered for deferred close * for the given SessionFactory./*from w w w.ja v a2 s.c o m*/ * @param datastore the Datastore to process deferred close for * @see #initDeferredClose * @see #releaseSession */ public static void processDeferredClose(Datastore datastore) { Assert.notNull(datastore, "No Datastore specified"); Map<Datastore, Set<Session>> holderMap = deferredCloseHolder.get(); if (holderMap == null || !holderMap.containsKey(datastore)) { throw new IllegalStateException("Deferred close not active for Datastore [" + datastore + "]"); } logger.debug("Processing deferred close of Datastore Sessions"); Set<Session> sessions = holderMap.remove(datastore); for (Session session : sessions) { closeSession(session); } if (holderMap.isEmpty()) { deferredCloseHolder.set(null); } }
From source file:com.sccl.attech.modules.sys.web.LoginController.java
/** * ???// ww w .j a va 2 s . c om * @param useruame ?? * @param isFail 1 * @param clean * @return */ @SuppressWarnings("unchecked") public static boolean isValidateCodeLogin(String useruame, boolean isFail, boolean clean) { Map<String, Integer> loginFailMap = (Map<String, Integer>) CacheUtils.get("loginFailMap"); if (loginFailMap == null) { loginFailMap = Maps.newHashMap(); CacheUtils.put("loginFailMap", loginFailMap); } Integer loginFailNum = loginFailMap.get(useruame); if (loginFailNum == null) { loginFailNum = 0; } if (isFail) { loginFailNum++; loginFailMap.put(useruame, loginFailNum); } if (clean) { loginFailMap.remove(useruame); } return loginFailNum >= 100;//??? }
From source file:com.baidu.rigel.biplatform.parser.util.ConditionUtil.java
/** * contexCondition??/*from w w w .ja v a2 s . c o m*/ * simpleMergeContexsCondition * @param contexs * @return */ public static Map<Condition, Set<String>> simpleMergeContexsCondition(Collection<CompileContext> contexs) { Map<Condition, Set<String>> result = new HashMap<Condition, Set<String>>(); if (CollectionUtils.isNotEmpty(contexs)) { Map<Condition, Set<String>> condition = null; for (CompileContext contex : contexs) { // ????? condition = new HashMap<Condition, Set<String>>(contex.getConditionVariables()); if (result.isEmpty()) { result.putAll(condition); } else if (MapUtils.isNotEmpty(condition)) { for (Entry<Condition, Set<String>> entry : result.entrySet()) { if (condition.containsKey(entry.getKey())) { entry.getValue().addAll(condition.get(entry.getKey())); condition.remove(entry.getKey()); } } if (MapUtils.isNotEmpty(condition)) { result.putAll(condition); } } } } return result; }
From source file:com.eucalyptus.ws.util.HmacUtils.java
public static String makeV2SubjectString(String httpMethod, String host, String path, final Map<String, String> parameters) { parameters.remove(""); StringBuilder sb = new StringBuilder(); sb.append(httpMethod);/* www. j a va 2 s.c om*/ sb.append("\n"); sb.append(host); sb.append("\n"); sb.append(path); sb.append("\n"); String prefix = sb.toString(); sb = new StringBuilder(); NavigableSet<String> sortedKeys = new TreeSet<String>(); sortedKeys.addAll(parameters.keySet()); String firstKey = sortedKeys.pollFirst(); if (firstKey != null) { sb.append(urlEncode(firstKey)).append("=") .append(urlEncode(parameters.get(firstKey).replaceAll("\\+", " "))); } while ((firstKey = sortedKeys.pollFirst()) != null) { sb.append("&").append(urlEncode(firstKey)).append("=") .append(urlEncode(parameters.get(firstKey).replaceAll("\\+", " "))); } String subject = prefix + sb.toString(); LOG.trace("VERSION2: " + subject); return subject; }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditSubmission.java
public static void clearEditSubmissionInSession(HttpSession sess, EditSubmission editSub) { if (sess == null) return;/* w w w. java 2 s . c o m*/ if (editSub == null) return; Map<String, EditSubmission> submissions = (Map<String, EditSubmission>) sess .getAttribute("EditSubmissions"); if (submissions == null) { throw new Error("EditSubmission: could not get a Map of EditSubmissions from the session."); } submissions.remove(editSub.editKey); }
From source file:fr.duminy.jbackup.core.ConfigurationManagerTest.java
private static Map describe(BackupConfiguration config) { Map properties; try {//from w w w . ja va 2s.c o m properties = PropertyUtils.describe(config); } catch (Exception e) { LOG.error("unable to extract properties from configuration", e); properties = Collections.EMPTY_MAP; } properties.remove("class"); properties.put("archiveFactory", config.getArchiveFactory().getClass().getName()); List<BackupConfiguration.Source> sources = (List<BackupConfiguration.Source>) properties.remove("sources"); properties.put("sources.size", sources.size()); for (int i = 0; i < sources.size(); i++) { Map sourceProperties = null; try { sourceProperties = PropertyUtils.describe(sources.get(i)); } catch (Exception e) { LOG.error("unable to extract source #" + i, e); } sourceProperties.remove("class"); properties.put("sources[" + i + "]", sourceProperties); } return properties; }
From source file:com.formkiq.core.form.bean.ObjectBuilder.java
/** * Get Field Value Map from Object.// w w w . j a v a 2 s. co m * @param bean {@link BeanUtilsBean} * @param obj {@link Object} * @param fieldNames {@link Collection} of {@link String} * @return {@link Map} * @throws IllegalAccessException IllegalAccessException * @throws InvocationTargetException InvocationTargetException * @throws NoSuchMethodException NoSuchMethodException */ private static Map<String, String> getFieldValueMap(final BeanUtilsBean bean, final Object obj, final Collection<String> fieldNames) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Map<String, String> m = bean.describe(obj); if (!isEmpty(fieldNames)) { Map<String, String> r = new HashMap<>(fieldNames.size()); for (String fieldname : fieldNames) { r.put(fieldname, m.getOrDefault(fieldname, "")); } m = r; } else { m.remove("class"); } return m; }