Java的OAuth解析和验证包 joauth
openkk
12年前
joauth 是 Java 实现用来解析和验证 OAuth 请求的类库。
- Supports OAuth 1.0a and 2.0
- Uses thrust.HttpRequest, which can be used to wrap HttpServletRequests or other HTTP Request representations
- Unpacks Requests, extracts and verifies OAuth parameters from headers, GET, and POST
- Incidentally parses Non-OAuth GET and POST parameters and makes them accessible via a callback
- Custom callbacks to obtain scheme and path from the request in a non-standard way
- Configurable timestamp checking
- Correctly works around various weird URLEncoder bugs in the JVM
- Written in Scala, but should work pretty well with Java
示例代码:
import com.推ter.joauth.{Verifier, VerifierResult} val verify = Verifier() verify(oAuth1Request, tokenSecret, consumerSecret) match { case VerifierResult.BAD_NONCE => // handle bad nonce case VerifierResult.BAD_SIGNATURE => // handle bad signature case VerifierResult.BAD_TIMESTAMP => // handle bad timestamp case VerifierResult.OK => //success! }