rfc5849

an implementation of rfc5849

License

License

GroupId

GroupId

com.github.jinahya
ArtifactId

ArtifactId

rfc5849
Last Version

Last Version

1.1.8
Release Date

Release Date

Type

Type

jar
Description

Description

rfc5849
an implementation of rfc5849
Source Code Management

Source Code Management

https://github.com/jinahya/rfc5849

Download rfc5849

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.jinahya/rfc5849/ -->
<dependency>
    <groupId>com.github.jinahya</groupId>
    <artifactId>rfc5849</artifactId>
    <version>1.1.8</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.jinahya/rfc5849/
implementation 'com.github.jinahya:rfc5849:1.1.8'
// https://jarcasting.com/artifacts/com.github.jinahya/rfc5849/
implementation ("com.github.jinahya:rfc5849:1.1.8")
'com.github.jinahya:rfc5849:jar:1.1.8'
<dependency org="com.github.jinahya" name="rfc5849" rev="1.1.8">
  <artifact name="rfc5849" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.jinahya', module='rfc5849', version='1.1.8')
)
libraryDependencies += "com.github.jinahya" % "rfc5849" % "1.1.8"
[com.github.jinahya/rfc5849 "1.1.8"]

Dependencies

compile (1)

Group / Artifact Type Version
org.bouncycastle : bcprov-jdk16 Optional jar 1.46

test (5)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.1.8
commons-codec : commons-codec jar 1.10
commons-io : commons-io jar 2.5
org.apache.commons : commons-lang3 jar 3.5
org.testng : testng jar 6.10

Project Modules

There are no modules declared in this project.

rfc5849

implementation of The OAuth 1.0 Protocol.

Dependency Status Build Status Maven Central Javadocs

Components

OAuthBaseString

For building a Signature Base String.

final OAuthBaseString baseString = new OAuthBaseString();

You can use following methods to set values.

baseString.httpMethod(httpMethod);
baseString.baseUri(baseUri);
baseString.queryParameter(key, value);
baseString.protocolParameter(key, value); // key must start with 'oauth_'
baseString.entityParameter(key, value);

OAuthSignature

For generating a Signature.

class method platform
OAuthSignatureHmacSha1Bc HMAC-SHA1 BC
OAuthSignatureHmacSha1Jca HMAC-SHA1 JCA
OAuthSignatureRsaSha1Bc RSA-SHA1 BC
OAuthSignatureRsaSha1Jca RSA-SHA1 JCA
OAuthSignaturePlaintext PLAINTEXT

HMAC-SHA1

There are two implementations. One is for Java Cryptograph Architexture and the other is for Legion of the Bouncy Castle.

final OAuthSignatureHmacSha1 signature = new OAuthSignatureHmacSha1Bc(); // BC
final OAuthSignatureHmacSha1 signature = new OAuthSignatureHmacSha1Jca(); // JCA

You can use following methods to set values.

signature.consumerSecret(consumerSecret);
signature.tokenSecret(tokenSecret);
signature.baseString(baseString); // OAuthBaseString

RSA-SHA1

There are, again, two implementations. One is for Java Cryptograph Architexture and the other is for Legion of the Bouncy Castle.

final OAuthSignatureRsaSha1 signature = new OAuthSignatureRsaSha1Bc(); // BC
final OAuthSignatureRsaSha1 signature = new OAuthSignatureRsaSha1Jca(); // JCA

You can use following methods to set values.

signature.initParam(PrivateKey privateKey); // JCA
signature.initParam(CipherParameters cipherParameters); // BC

PLAINTEXT

new OAuthSignaturePlaintext();

OAuthProtocolParameters

final OAuthProtocolParameters protocolParameters = new OAuthProtocolParameters();
protocolParameters.realm(realm);
protocolParameters.signature(signature); // OAuthSignature

Three kinds of output defined in 3.5. Parameter Transmission are supported.

final String header = protocolParameters.authorizationHeader(); // Authorization Header
final String body = protocolParameters.formEncodedBody(); // Form-Encoded Body
final String query = protocolParameters.requestUriQuery(); // Request URI Query

Examples

final OAuthRequest protocolParameters = new OAuthRequest()
    .realm("Example")
    .signature(
        new OAuthSignatureHmacSha1Bc()
            .consumerSecret("j49sk3j29djd")
            .tokenSecret("dh893hdasih9")
            .baseString(
                new OAuthBaseString()
                    .httpMethod("POST")
                    .baseUri("http://example.com/request")
                    .queryParameter("b5", "=%3D")
                    .queryParameter("a3", "a")
                    .queryParameter("c@", "")
                    .queryParameter("a2", "r b")
                    .oauthConsumerKey("9djdj82h48djs9d2")
                    .oauthNonce("7d8f3e4a")
                    .oauthTimestamp("137131201")
                    .oauthToken("kkk9d7dh3k39sjv7")
                    .entityParameter("c2", "")
                    .entityParameter("a3", "2 q")
        )
    );

final String authorizationHeader = protocolParameters.authorizationHeader();

Versions

Version
1.1.8
1.1.7
1.1.5
1.1.4
1.1.2
1.1.1
1.1.0
1.0.0
0.9.5
0.9.2
0.9.1