Merge pull request #3395 from stianst/master

KEYCLOAK-3772
This commit is contained in:
Stian Thorgersen 2016-10-20 19:27:03 +02:00 committed by GitHub
commit 1bf24d26a4
2 changed files with 9 additions and 9 deletions

View file

@ -93,10 +93,7 @@ public class ClientSessionCode {
return result;
}
try {
String[] parts = code.split("\\.");
String id = parts[1];
result.clientSession = session.sessions().getClientSession(realm, id);
result.clientSession = getClientSession(code, session, realm);
if (result.clientSession == null) {
result.clientSessionNotFound = true;
return result;
@ -117,10 +114,7 @@ public class ClientSessionCode {
public static ClientSessionCode parse(String code, KeycloakSession session, RealmModel realm) {
try {
String[] parts = code.split("\\.");
String id = parts[1];
ClientSessionModel clientSession = session.sessions().getClientSession(realm, id);
ClientSessionModel clientSession = getClientSession(code, session, realm);
if (clientSession == null) {
return null;
}
@ -135,6 +129,12 @@ public class ClientSessionCode {
}
}
public static ClientSessionModel getClientSession(String code, KeycloakSession session, RealmModel realm) {
String[] parts = code.split("\\.");
String id = parts[1];
return session.sessions().getClientSession(realm, id);
}
public ClientSessionModel getClientSession() {
return clientSession;
}

View file

@ -122,7 +122,7 @@ public class TwitterIdentityProvider extends AbstractIdentityProvider<OAuth2Iden
twitter.setOAuthConsumer(getConfig().getClientId(), getConfig().getClientSecret());
ClientSessionModel clientSession = parseClientSessionCode(state).getClientSession();
ClientSessionModel clientSession = ClientSessionCode.getClientSession(state, session, realm);
String twitterToken = clientSession.getNote("twitter_token");
String twitterSecret = clientSession.getNote("twitter_tokenSecret");