use of org.glassfish.jersey.server.oauth1.internal.OAuthServerRequest 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";
}
Aggregations