- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我的pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mkyong.common</groupId>
<artifactId>RESTfulExample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>RESTfulExample Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<properties>
<project.build.java.target>1.6</project.build.java.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.0.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.28</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
<artifactId>oauth-server</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
<artifactId>oauth-signature</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
<artifactId>oauth-client</artifactId>
<version>1.18</version>
</dependency>
</dependencies>
<build>
<finalName>RESTfulExample</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.3.1</version>
<configuration>
<complianceLevel>1.6</complianceLevel>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<!--<goal>test-compile</goal> -->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
这是我的誓言过滤器类
public class OAuthAuthenticationFilter1 implements ContainerRequestFilter {
public ContainerRequest filter(ContainerRequest containerRequest) {
OAuthServerRequest request = new OAuthServerRequest(containerRequest);
OAuthParameters params = new OAuthParameters();
params.readRequest(request);
OAuthSecrets secrets = new OAuthSecrets();
OAuthParameters param=new OAuthParameters();
secrets.consumerSecret("OwnAccount");
param.consumerKey("OwnAccount");
try {
if(!OAuthSignature.verify(request, params, secrets)) {
throw new WebApplicationException(401);
}
} catch (OAuthSignatureException e) {
throw new WebApplicationException(e, 401);
}
return containerRequest;
}
}
这是我的客户
public class Sample1 {
public static final String HOSTNAME = "http://localhost:8080/RESTfulExample/rest/hello/planetext";
public static final String CONSUMER_KEY = "OwnAccount";
public static final String CONSUMER_SECRET = "OwnAccount";
/**
* @param args
*/
public static void main(String[] args) {
Client client = Client.create();
OAuthParameters params = new OAuthParameters().signatureMethod("HMAC-SHA1").consumerKey(CONSUMER_KEY);
OAuthSecrets secrets = new OAuthSecrets().consumerSecret(CONSUMER_SECRET);
OAuthClientFilter filter = new OAuthClientFilter(client.getProviders(), params, secrets);
WebResource res = client.resource(HOSTNAME );
res.addFilter(filter);
String responseString = res.get(String.class);
System.out.println(responseString);
}
}
我正在使用以下誓言和 Jersey pom 引用该网站 http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.sun.jersey.contribs.jersey-oauth%22
<dependency>
<groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
<artifactId>oauth-server</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
<artifactId>oauth-signature</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
<artifactId>oauth-client</artifactId>
<version>1.18</version>
</dependency>
当过滤器类的以下代码被调用时
try {
// exception is thrown from here
if(!OAuthSignature.verify(request, params, secrets)) {
throw new WebApplicationException(401);
}
} catch (OAuthSignatureException e) {
throw new WebApplicationException(e, 401);
}
我遇到了这个异常
com.sun.jersey.oauth.signature.UnsupportedSignatureMethodException:HMAC-SHA1 在 com.sun.jersey.oauth.signature.OAuthSignature.getSignatureMethod(OAuthSignature.java:257)
我正在使用 tomcat 7。
我在网上搜索但找不到 tomcat 的原因。我缺少什么?有人遇到过 tomcat 的问题吗?
最佳答案
当我将 jersey-server jar 更新到 1.18 时,我解决了这个问题。我之前使用的是 jersey-server 1.8 jar。
关于java - 不支持的 SignatureMethod 异常 : HMAC-SHA1 exception in tomcat with jerseyoauth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21677801/
我正在尝试在 Elixir 中编写亚马逊产品广告 API 客户端。开发者指南描述了 the process for signing an API request其中必须使用请求和“ secret 访问
我在AIX上运行脚本时遇到以下错误 Reading configuration data /ecmsq1vg1/home1/aradmin/.ssh/config Reading configurat
见 OpenSSL::HMAC documentation . 我正在尝试这个: require "openssl" puts OpenSSL::HMAC.hexdigest(:sha256, "se
我正在使用 https://github.com/DaGenix/rust-crypto并且有一些奇怪的错误: extern crate crypto; use crypto::sha2::{Sha2
我们有一个 python 网络服务。它需要一个散列作为参数。python中的hash就是这样生成的。 hashed_data = hmac.new("ant", "bat", hashlib.
这将是一个很长的问题,但我有一个非常奇怪的错误。我在 C++ 中使用 OpenSSL 来计算 HMAC,并将它们与使用 javax.crypto.Mac 的模拟实现进行比较。对于某些 key ,HMA
我在我的代码中发现了一个巨大的问题,我完全不知道是什么导致了这个问题。 所以,当我向我的服务器发送请求时,我对请求中的字符串进行哈希处理。这有时是用户输入。 我的应用是多语言的,所以我必须支持所有“ä
我想弄清楚为什么 openssl 中的 hmac 没有给我与 java 中的 hmac 相同的结果。 在开放的 ssl 中 echo -n "Hello" | openssl dgst -sha256
与: KEY='7vgd39eyxald9sucClM7' DATA='POST\nmultipart/form-data\nWed, 10 Jun 2015 07:27:43 GMT\n/1/cla
我正在尝试转换一个 secret 的 hmac 字符串,以允许我在 postman 中测试我的 api。 Postman 预装了 cryptojs。这是我在我的测试服务器上使用加密的过程: const
Security.Cryptography.HMACSHA256.Create() 和 Security.Cryptography.KeyedHashAlgorithm.Create("HmacSHA
图例 我公开了一个 API,它要求客户端通过发送两个 header 来签署请求: Authorization: MyCompany access_key: Unix-TimeStamp: 要创建签名
我在 Android 上遇到一些 HMAC 问题。我将 SHA1 算法与以下代码一起使用,在搜索 android hmac-sha1 时会在整个网络上显示。 String base_s
HS256 和 HS512 加密算法之间是否存在实际差异,或者与已经牢不可破的 key 相比,更长的 key 是否多余?我应该使用哪一个来加密 JWT token ? 是否有可能将 HS512 加密与
我需要使用 SHA512 加密的 cHMAC 我使用此方法获得的加密值和服务器端值不匹配他们使用 Java 的服务器端可以请帮助我解决这个问题。 服务器端加密值是 85d86c928825ef85d5
我从https://www.rfc-editor.org/rfc/rfc6238借用了HMAC-SHA1 Java代码并略微调整以对其进行硬编码,以使用具有已知输出的一对已知 key /消息。 然后我
我正在用 go 开发一个网络服务器, 在顶部我有 import ("net/http" "log" "fmt" "encoding/json" "encoding/he
使用 Node.js 加密模块时 const crypto = require('crypto'); HMACseed = crypto.createHmac('sha512', 'a55e3
我正在寻找用于密码加密的正确 Java 算法,我发现 Java SDK 提供了 PBKDF2WithHmacSHA1,但没有提供 PBKDF2WithHmacSHA256。 我听说 HMAC-SHA2
所以我一直在查看维基百科的 HMAC 伪代码,它看起来相对简单;如果您的 key 大小已经是块大小,则伪代码可归结为 3 行: o_key_pad ← key xor [0x5c * bloc
我是一名优秀的程序员,十分优秀!