Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

fixed serialisation issues for the LinkedIn #333

Open
wants to merge 3 commits into
base: 2.4.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class OAuth1AuthProvider<U extends AuthUserIdentity, I extends O

private static final String CACHE_TOKEN = "pa.oauth1.rtoken";

public OAuth1AuthProvider(final Application app) {
public OAuth1AuthProvider(final Application app) {
super(app);
}

Expand Down Expand Up @@ -66,17 +66,62 @@ public static abstract class Constants {
public static final String OAUTH_ACCESS_DENIED = "access_denied";
}

public static class SerializableRequestToken extends RequestToken implements Serializable {
private static final long serialVersionUID = 1L;
public static class DefaultNonSerializableRequestToken extends RequestToken {

public SerializableRequestToken() {
super(null, null);
}
public DefaultNonSerializableRequestToken() {
super(null, null);
}

public DefaultNonSerializableRequestToken(String token, String secret) {
super(token, secret);
}

}

public static class SerializableRequestToken extends DefaultNonSerializableRequestToken implements Serializable {

private static final long serialVersionUID = 7258408812687395069L;

public String token;

public String secret;

public SerializableRequestToken() {
super();
}

public SerializableRequestToken(String token, String secret) {
super(token, secret);
this.token = token;
this.secret = secret;
}

public SerializableRequestToken(RequestToken source) {
super(source.token, source.secret);
this(source.token, source.secret);
}
}

public RequestToken getRequestToken() {
return new RequestToken(token, secret);
}

public String getToken() {
return token;
}

public void setToken(String token) {
super.token = token;
this.token = token;
}

public String getSecret() {
return secret;
}

public void setSecret(String secret) {
super.secret = secret;
this.secret = secret;
}
}

protected void checkError(Request request) throws AuthException{
final String error = request.getQueryString(Constants.OAUTH_PROBLEM);
Expand Down Expand Up @@ -119,12 +164,17 @@ public Object authenticate(final Context context, final Object payload)

if (uri.contains(Constants.OAUTH_VERIFIER)) {

final RequestToken rtoken = (RequestToken) PlayAuthenticate
.removeFromCache(context.session(), CACHE_TOKEN);
if (Logger.isDebugEnabled()) {
Logger.debug("Retrieving token from the cache....");
}

final SerializableRequestToken rtoken = PlayAuthenticate
.removeFromCache(context.session(), CACHE_TOKEN);

final String verifier = request.getQueryString(Constants.OAUTH_VERIFIER);
try {
final RequestToken response = service
.retrieveAccessToken(rtoken, verifier);
.retrieveAccessToken(rtoken.getRequestToken(), verifier);
final I i = buildInfo(response);
return transform(i);
} catch (RuntimeException ex) {
Expand Down