/**
* Sign the specified http request.
*
* @param httpMethod The http request method({@link #HttpMethod})
* @param uri The uri string
* @param httpHeaders The http request headers
* @param secretAccessKeyId The user's secret access key
* @param algorithm The sign algorithm({@link #SignAlgorithm})
* @return Byte buffer of the signed result
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws URISyntaxException
*/
public static byte[] sign(HttpMethod httpMethod, URI uri,
LinkedListMultimap<String, String> httpHeaders, String secretAccessKeyId,
SignAlgorithm algorithm) throws NoSuchAlgorithmException,
InvalidKeyException {
Preconditions.checkNotNull(httpMethod);
Preconditions.checkNotNull(uri);
Preconditions.checkNotNull(secretAccessKeyId);
Preconditions.checkNotNull(algorithm);
String stringToSign = constructStringToSign(httpMethod,
uri, httpHeaders);
if (LOG.isDebugEnabled()) {
LOG.debug("Sign for request: " + httpMethod + " " + uri
+ ", stringToSign=" + stringToSign);
}
Mac mac = Mac.getInstance(algorithm.name());
mac.init(new SecretKeySpec(secretAccessKeyId.getBytes(), algorithm.name()));
return mac.doFinal(stringToSign.getBytes());
}
java类com.google.common.collect.LinkedListMultimap的实例源码
Signer.java 文件源码
项目:galaxy-fds-sdk-java
阅读 28
收藏 0
点赞 0
评论 0
AssistedParameters.java 文件源码
项目:error-prone
阅读 17
收藏 0
点赞 0
评论 0
private Multimap<Type, VariableTree> partitionParametersByType(
List<VariableTree> parameters, VisitorState state) {
Types types = state.getTypes();
Multimap<Type, VariableTree> multimap = LinkedListMultimap.create();
variables:
for (VariableTree node : parameters) {
// Normalize Integer => int
Type type = types.unboxedTypeOrType(ASTHelpers.getType(node));
for (Type existingType : multimap.keySet()) {
if (types.isSameType(existingType, type)) {
multimap.put(existingType, node);
continue variables;
}
}
// A new type for the map.
multimap.put(type, node);
}
return multimap;
}
ResultsAreaRenderableDefinition.java 文件源码
项目:magnolia-templating
阅读 22
收藏 0
点赞 0
评论 0
@Inject
public ResultsAreaRenderableDefinition(Node content, RD definition, RenderingModel<?> parent, FoundationTemplatingFunctions templatingFunctions, RenderingUtils renderingUtils) {
super(content, definition, parent, templatingFunctions);
this.renderingUtils = renderingUtils;
paramFilter = LinkedListMultimap.create();
Set<String> parameters = webContext.getParameters().keySet();
for (String parameterKey : parameters) {
if (allowedParameters().contains(parameterKey)) {
String[] parameterValues = webContext.getParameterValues(parameterKey);
for (String parameterValue : parameterValues) {
if (StringUtils.isNotEmpty(parameterValue)) {
paramFilter.get(parameterKey).add(parameterValue);
}
}
}
webContext.remove(parameterKey);
}
}
MergeVariationPointsHandler.java 文件源码
项目:SPLevo
阅读 15
收藏 0
点赞 0
评论 0
private Multimap<String, SoftwareElement> collectSoftwareElementsToMove(Set<VariationPoint> vpsToMerge,
VariationPoint survivingVP) {
Multimap<String, SoftwareElement> variantSoftwareElements = LinkedListMultimap.create();
for (VariationPoint vp : vpsToMerge) {
// skip the surviving vp to not modify the emf elements
if (survivingVP == vp) {
continue;
}
for (Variant variant : vp.getVariants()) {
variantSoftwareElements.putAll(variant.getId(), variant.getImplementingElements());
}
}
return variantSoftwareElements;
}
HDLFunctions.java 文件源码
项目:org.pshdl
阅读 16
收藏 0
点赞 0
评论 0
public static void init(CompilerInformation info, IServiceProvider sp) {
signatures = LinkedListMultimap.create();
provider = LinkedListMultimap.create();
dynamicProvider = LinkedListMultimap.create();
final Collection<IDynamicFunctionProvider> dyns = sp.getAllDynamicFunctionProvider();
for (final IDynamicFunctionProvider dynProv : dyns) {
final HDLQualifiedName[] registeredNames = dynProv.getDynamicFunctions();
for (final HDLQualifiedName hdlQualifiedName : registeredNames) {
dynamicProvider.put(hdlQualifiedName, dynProv);
}
}
final Collection<INativeFunctionProvider> nativeStaticProvider = sp.getAllNativeFunctionProvider();
for (final INativeFunctionProvider snfp : nativeStaticProvider) {
final HDLFunctionImplementation[] functionImpl = snfp.getStaticFunctions();
for (final HDLFunctionImplementation funcImpl : functionImpl) {
for (final HDLFunction hdlFunction : funcImpl.signatures()) {
final HDLQualifiedName fqnFunction = new HDLQualifiedName(hdlFunction.getName());
provider.put(fqnFunction, funcImpl);
signatures.put(fqnFunction, hdlFunction);
}
}
}
}
EnglishNLP.java 文件源码
项目:MuSICo
阅读 18
收藏 0
点赞 0
评论 0
public static void readVerbClasses(String path) throws IOException {
levin_verb_classes = LinkedListMultimap.create();
BufferedReader input = new BufferedReader( new FileReader(new File(path)) );
String aux = null;
String levin_class = null;
String[] verbs = null;
int n_classes = 0;
while ( ( aux = input.readLine() ) != null ) {
if ( aux.startsWith("VERB") ) {
String[] data = aux.split("\\s+",2);
levin_class = data[0];
n_classes++;
} else if ( aux.trim().length() != 0) {
verbs = aux.split("\\s+");
for (int z = 0; z < verbs.length; z++) levin_verb_classes.put(verbs[z],levin_class);
}
}
System.out.println("Total Levin classes: " + n_classes);
System.out.println("Number of unique verbs: " + levin_verb_classes.keySet().size());
input.close();
}
BuildEncyclopediaProcessor.java 文件源码
项目:bazel
阅读 18
收藏 0
点赞 0
评论 0
/**
* Create a mapping of rules based on rule type and family.
*/
private void createRuleMapping(Iterable<RuleDocumentation> docEntries,
Map<String, ListMultimap<RuleType, RuleDocumentation>> ruleMapping)
throws BuildEncyclopediaDocException {
for (RuleDocumentation ruleDoc : docEntries) {
RuleClass ruleClass = ruleClassProvider.getRuleClassMap().get(ruleDoc.getRuleName());
if (ruleClass != null) {
String ruleFamily = ruleDoc.getRuleFamily();
if (!ruleMapping.containsKey(ruleFamily)) {
ruleMapping.put(ruleFamily, LinkedListMultimap.<RuleType, RuleDocumentation>create());
}
if (ruleClass.isDocumented()) {
ruleMapping.get(ruleFamily).put(ruleDoc.getRuleType(), ruleDoc);
}
} else {
throw ruleDoc.createException("Can't find RuleClass for " + ruleDoc.getRuleName());
}
}
}
PreciseAspectResolver.java 文件源码
项目:bazel
阅读 14
收藏 0
点赞 0
评论 0
@Override
public ImmutableMultimap<Attribute, Label> computeAspectDependencies(Target target,
DependencyFilter dependencyFilter)
throws InterruptedException {
Multimap<Attribute, Label> result = LinkedListMultimap.create();
if (target instanceof Rule) {
Multimap<Attribute, Label> transitions =
((Rule) target).getTransitions(DependencyFilter.NO_NODEP_ATTRIBUTES);
for (Entry<Attribute, Label> entry : transitions.entries()) {
Target toTarget;
try {
toTarget = packageProvider.getTarget(eventHandler, entry.getValue());
result.putAll(
AspectDefinition.visitAspectsIfRequired(
target,
entry.getKey(),
toTarget,
dependencyFilter));
} catch (NoSuchThingException e) {
// Do nothing. One of target direct deps has an error. The dependency on the BUILD file
// (or one of the files included in it) will be reported in the query result of :BUILD.
}
}
}
return ImmutableMultimap.copyOf(result);
}
ImmutableSortedKeyListMultimapTest.java 文件源码
项目:bazel
阅读 17
收藏 0
点赞 0
评论 0
@Test
public void builderPutAllMultimap() {
Multimap<String, Integer> toPut = LinkedListMultimap.create();
toPut.put("foo", 1);
toPut.put("bar", 4);
toPut.put("foo", 2);
toPut.put("foo", 3);
Multimap<String, Integer> moreToPut = LinkedListMultimap.create();
moreToPut.put("foo", 6);
moreToPut.put("bar", 5);
moreToPut.put("foo", 7);
ImmutableSortedKeyListMultimap.Builder<String, Integer> builder
= ImmutableSortedKeyListMultimap.builder();
builder.putAll(toPut);
builder.putAll(moreToPut);
Multimap<String, Integer> multimap = builder.build();
assertThat(multimap).valuesForKey("foo").containsExactly(1, 2, 3, 6, 7).inOrder();
assertThat(multimap).valuesForKey("bar").containsExactly(4, 5).inOrder();
assertThat(multimap).hasSize(7);
}