Search in sources :

Example 6 with OAuth1SignatureException

use of org.glassfish.jersey.oauth1.signature.OAuth1SignatureException in project jersey by jersey.

the class RequestTokenResource method get.

@POST
@Produces("text/plain")
public String get(@Context ContainerRequestContext request) {
    OAuthServerRequest osr = new OAuthServerRequest(request);
    OAuth1Secrets secrets = new OAuth1Secrets().consumerSecret("kd94hf93k423kf44");
    OAuth1Parameters params = new OAuth1Parameters().readRequest(osr);
    // ensure parameters correctly parsed into OAuth parameters object
    assertEquals(params.getConsumerKey(), "dpf43f3p2l4k3l03");
    assertEquals(params.getSignatureMethod(), "PLAINTEXT");
    assertEquals(params.getSignature(), secrets.getConsumerSecret() + "&");
    assertEquals(params.getTimestamp(), "1191242090");
    assertEquals(params.getNonce(), "hsu94j3884jdopsl");
    assertEquals(params.getVersion(), "1.0");
    try {
        // verify the plaintext signature
        assertTrue(oAuth1Signature.verify(osr, params, secrets));
    } catch (OAuth1SignatureException ose) {
        fail(ose.getMessage());
    }
    return "oauth_token=hh5s93j4hdidpola&oauth_token_secret=hdhd0244k9j7ao03";
}
Also used : OAuthServerRequest(org.glassfish.jersey.server.oauth1.internal.OAuthServerRequest) OAuth1Parameters(org.glassfish.jersey.oauth1.signature.OAuth1Parameters) OAuth1SignatureException(org.glassfish.jersey.oauth1.signature.OAuth1SignatureException) OAuth1Secrets(org.glassfish.jersey.oauth1.signature.OAuth1Secrets) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

OAuth1Parameters (org.glassfish.jersey.oauth1.signature.OAuth1Parameters)6 OAuth1Secrets (org.glassfish.jersey.oauth1.signature.OAuth1Secrets)6 OAuth1SignatureException (org.glassfish.jersey.oauth1.signature.OAuth1SignatureException)6 Produces (javax.ws.rs.Produces)5 POST (javax.ws.rs.POST)4 OAuthServerRequest (org.glassfish.jersey.server.oauth1.internal.OAuthServerRequest)3 Consumes (javax.ws.rs.Consumes)2 Form (javax.ws.rs.core.Form)2 OAuth1Consumer (org.glassfish.jersey.server.oauth1.OAuth1Consumer)2 OAuth1Exception (org.glassfish.jersey.server.oauth1.OAuth1Exception)2 OAuth1Token (org.glassfish.jersey.server.oauth1.OAuth1Token)2 TokenResource (org.glassfish.jersey.server.oauth1.TokenResource)2 GET (javax.ws.rs.GET)1 ProcessingException (javax.ws.rs.ProcessingException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)1