List of usage examples for com.google.common.collect ImmutableMap get
V get(Object key);
From source file:com.facebook.buck.features.go.GoCompile.java
@Nullable private ImmutableList<Path> getHeaderSources(ImmutableMap<String, ImmutableList<Path>> groupedSrcs) { return groupedSrcs.get("h"); }
From source file:com.google.caliper.platform.jvm.JvmPlatform.java
@Override public File customVmHomeDir(Map<String, String> vmGroupMap, String vmConfigName) throws VirtualMachineException { // Configuration can either be: // vm.<vmConfigName>.home = <homeDir> // or/*from w ww. j av a 2 s.c o m*/ // vm.baseDirectory = <baseDir> // homeDir = <baseDir>/<vmConfigName> ImmutableMap<String, String> vmMap = Util.subgroupMap(vmGroupMap, vmConfigName); return getJdkHomeDir(vmGroupMap.get("baseDirectory"), vmMap.get("home"), vmConfigName); }
From source file:org.jboss.aerogear.security.hawk.authz.HawkAuthenticator.java
/** * @param request Hawk HTTP <i>Authorization</i> request * @param response Hawk HTTP response to authenticated requests with a <i>Server-Authorization</i> header * @throws Exception/*ww w .j a v a 2s . c om*/ */ public void authenticate(HttpServletRequest request, HttpServletResponse response) throws Exception { String hash = null; try { URI uri = getUri(request); ImmutableMap<String, String> authorizationHeaders = server .splitAuthorizationHeader(request.getHeader(AUTHORIZATION)); HawkCredentials credentials = credentialProvider.findByKey(authorizationHeaders.get("id")); if (authorizationHeaders.get(CALCULATED_HASH) != null) { hash = Hawk.calculateMac(credentials, CharStreams.toString(new InputStreamReader(request.getInputStream(), ENCODING))); } server.authenticate(credentials, uri, request.getMethod(), authorizationHeaders, hash, hasBody(request)); addAuthenticateHeader(response); } catch (Throwable de) { throw new Exception(de); } }
From source file:com.vmware.photon.controller.common.dcp.QueryTaskUtils.java
/** * Builds a QueryTask.QuerySpecification which will query for documents of type T. * Any other filter clauses are optional. * This allows for a query that returns all documents of type T. * This also expands the content of the resulting documents. * * @param documentType//from w w w .j av a 2 s. c o m * @param terms * @return */ public static QueryTask.QuerySpecification buildQuerySpec(Class documentType, ImmutableMap<String, String> terms) { checkNotNull(documentType, "Cannot build query spec for unspecified documentType"); QueryTask.QuerySpecification spec = new QueryTask.QuerySpecification(); QueryTask.Query documentKindClause = new QueryTask.Query() .setTermPropertyName(ServiceDocument.FIELD_NAME_KIND) .setTermMatchValue(Utils.buildKind(documentType)); if (terms == null || terms.isEmpty()) { // since there are no other clauses // skip adding boolean clauses // to workaround the DCP requirement to have at least 2 // boolean clauses for a valid query spec.query = documentKindClause; } else { spec.query.addBooleanClause(documentKindClause); for (String key : terms.keySet()) { QueryTask.Query clause = new QueryTask.Query().setTermPropertyName(key) .setTermMatchValue(terms.get(key)); spec.query.addBooleanClause(clause); } } return spec; }
From source file:com.facebook.buck.cxx.AbstractElfExtractSectionsStep.java
private ImmutableList<String> getObjcopyCommand(ImmutableMap<String, Long> addresses) { ImmutableList.Builder<String> args = ImmutableList.builder(); args.addAll(getObjcopyPrefix());//from w w w . j av a 2 s . c o m for (String section : getSections()) { Long address = addresses.get(section); if (address != null) { args.add("--only-section", section, "--change-section-address", String.format("%s=0x%x", section, address)); } } args.add(getInput().toString()); args.add(getOutput().toString()); return args.build(); }
From source file:com.wealdtech.hawk.jersey.HawkAuthenticator.java
/** * Authenticate a request from an authentication header. * @param request the HTTP request/*from w ww .j a v a 2s. c o m*/ * @return the authenticated principal, or <code>Optional.absent()</code> if the request was not authenticated * @throws DataError if there is a problem with the data that prevents the authentication attempt */ private Optional<T> authenticateFromHeader(final ContainerRequest request) { final ImmutableMap<String, String> authorizationHeaders = server .splitAuthorizationHeader(request.getHeaderValue(ContainerRequest.AUTHORIZATION)); checkNotNull(authorizationHeaders.get("id"), "Missing required Hawk authorization header \"id\""); checkNotNull(authorizationHeaders.get("ts"), "Missing required Hawk authorization header \"ts\""); checkNotNull(authorizationHeaders.get("mac"), "Missing required Hawk authorization header \"mac\""); checkNotNull(authorizationHeaders.get("nonce"), "Missing required Hawk authorization header \"nonce\""); String hash = null; final URI uri = request.getRequestUri(); final String method = request.getMethod(); final Optional<T> principal = provider.getFromKey(authorizationHeaders.get("id")); if (!principal.isPresent()) { // Could not find the principal, reject this authentication request return Optional.absent(); } final HawkCredentials credentials = principal.get().getHawkCredentials(authorizationHeaders.get("id")); if (authorizationHeaders.get("hash") != null) { try { List<String> contentTypes = request.getRequestHeader(ContainerRequest.CONTENT_TYPE); if ((contentTypes == null) || (contentTypes.size() == 0)) { throw new DataError.Bad("Missing content type header for body verification"); } hash = Hawk.calculateBodyMac(credentials, contentTypes.get(0), CharStreams.toString(new InputStreamReader(request.getEntityInputStream(), "UTF-8"))); } catch (IOException ioe) { throw new DataError.Bad("Failed to read the message body to calculate hash", ioe); } } final boolean hasBody = request.getHeaderValue(ContainerRequest.CONTENT_LENGTH) != null ? true : false; this.server.authenticate(credentials, uri, method, authorizationHeaders, hash, hasBody); return principal; }
From source file:com.facebook.buck.features.project.intellij.IjModuleGraph.java
public ImmutableMap<IjModule, DependencyType> getDependentModulesFor(IjModule source) { ImmutableMap<IjProjectElement, DependencyType> deps = getDepsFor(source); return deps.keySet().stream().filter(dep -> dep instanceof IjModule).map(module -> (IjModule) module) .collect(ImmutableMap.toImmutableMap(k -> k, input -> Objects.requireNonNull(deps.get(input)))); }
From source file:com.vmware.photon.controller.common.xenon.QueryTaskUtils.java
/** * Builds a QueryTask.QuerySpecification which will query for documents of type T. * Any other filter clauses are optional. * This allows for a query that returns all documents of type T. * This also expands the content of the resulting documents. * * @param documentType//from w w w . j a va 2 s . c om * @param terms * @return */ public static QueryTask.QuerySpecification buildQuerySpec(Class documentType, ImmutableMap<String, String> terms) { checkNotNull(documentType, "Cannot build query spec for unspecified documentType"); QueryTask.QuerySpecification spec = new QueryTask.QuerySpecification(); QueryTask.Query documentKindClause = new QueryTask.Query() .setTermPropertyName(ServiceDocument.FIELD_NAME_KIND) .setTermMatchValue(Utils.buildKind(documentType)); if (terms == null || terms.isEmpty()) { // since there are no other clauses // skip adding boolean clauses // to workaround the Xenon requirement to have at least 2 // boolean clauses for a valid query spec.query = documentKindClause; } else { spec.query.addBooleanClause(documentKindClause); for (String key : terms.keySet()) { QueryTask.Query clause = new QueryTask.Query().setTermPropertyName(key) .setTermMatchValue(terms.get(key)); spec.query.addBooleanClause(clause); } } return spec; }
From source file:com.baasbox.security.SessionTokenProvider.java
@Override public ImmutableMap<SessionKeys, ? extends Object> getSession(String token) { if (isExpired(token)) { return null; }/* w ww. j a va2 s.c o m*/ ImmutableMap<SessionKeys, ? extends Object> info = sessions.get(token); ImmutableMap<SessionKeys, ? extends Object> newInfo = ImmutableMap.of(SessionKeys.APP_CODE, info.get(SessionKeys.APP_CODE), SessionKeys.TOKEN, token, SessionKeys.USERNAME, info.get(SessionKeys.USERNAME), SessionKeys.PASSWORD, info.get(SessionKeys.PASSWORD), SessionKeys.EXPIRE_TIME, (new Date()).getTime() + expiresInMilliseconds); sessions.put(token, newInfo); return newInfo; }
From source file:com.facebook.buck.features.project.intellij.IjModuleGraph.java
public ImmutableMap<IjLibrary, DependencyType> getDependentLibrariesFor(IjModule source) { ImmutableMap<IjProjectElement, DependencyType> deps = getDepsFor(source); return deps.keySet().stream().filter(dep -> dep instanceof IjLibrary).map(library -> (IjLibrary) library) .collect(ImmutableMap.toImmutableMap(k -> k, input -> Objects.requireNonNull(deps.get(input)))); }