diff --git a/social/core/src/main/java/org/keycloak/social/SocialRequestManager.java b/services/src/main/java/org/keycloak/services/managers/SocialRequestManager.java similarity index 96% rename from social/core/src/main/java/org/keycloak/social/SocialRequestManager.java rename to services/src/main/java/org/keycloak/services/managers/SocialRequestManager.java index 735ea6bd37..472ae7b4d6 100644 --- a/social/core/src/main/java/org/keycloak/social/SocialRequestManager.java +++ b/services/src/main/java/org/keycloak/services/managers/SocialRequestManager.java @@ -19,7 +19,9 @@ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ -package org.keycloak.social; +package org.keycloak.services.managers; + +import org.keycloak.social.RequestDetails; import java.util.HashMap; import java.util.Iterator; diff --git a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java index fba3aa9e83..96e922df88 100755 --- a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java +++ b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java @@ -8,7 +8,7 @@ import org.keycloak.models.picketlink.PicketlinkKeycloakSessionFactory; import org.keycloak.models.picketlink.mappings.ApplicationEntity; import org.keycloak.models.picketlink.mappings.RealmEntity; import org.keycloak.services.utils.PropertiesManager; -import org.keycloak.social.SocialRequestManager; +import org.keycloak.services.managers.SocialRequestManager; import org.picketlink.idm.PartitionManager; import org.picketlink.idm.config.IdentityConfigurationBuilder; import org.picketlink.idm.internal.DefaultPartitionManager; diff --git a/services/src/main/java/org/keycloak/services/resources/SocialResource.java b/services/src/main/java/org/keycloak/services/resources/SocialResource.java index 4d337b54db..85528c2522 100755 --- a/services/src/main/java/org/keycloak/services/resources/SocialResource.java +++ b/services/src/main/java/org/keycloak/services/resources/SocialResource.java @@ -66,7 +66,7 @@ import org.keycloak.social.SocialConstants; import org.keycloak.social.SocialProvider; import org.keycloak.social.SocialProviderConfig; import org.keycloak.social.SocialProviderException; -import org.keycloak.social.SocialRequestManager; +import org.keycloak.services.managers.SocialRequestManager; import org.keycloak.social.SocialUser; /** @@ -186,7 +186,6 @@ public class SocialResource { MultivaluedMap formData = fillRegistrationFormWithSocialData(socialUser); RequestDetailsBuilder reqDetailsBuilder = RequestDetailsBuilder.createFromRequestDetails(requestData); - reqDetailsBuilder.putSocialAttribute(SocialConstants.ATTR_SOCIAL_LINK, socialLink); String requestId = UUID.randomUUID().toString(); socialRequestManager.addRequest(requestId, reqDetailsBuilder.build()); @@ -281,7 +280,6 @@ public class SocialResource { String scope = requestData.getClientAttribute("scope"); String state = requestData.getClientAttribute("state"); String redirectUri = requestData.getClientAttribute("redirectUri"); - SocialLinkModel socialLink = (SocialLinkModel)requestData.getSocialAttribute(SocialConstants.ATTR_SOCIAL_LINK); Response response1 = tokenService.processRegisterImpl(clientId, scope, state, redirectUri, formData, true); @@ -297,7 +295,7 @@ public class SocialResource { // Normally shouldn't happen throw new IllegalStateException("User " + username + " not found in the realm"); } - realm.addSocialLink(user, socialLink); + realm.addSocialLink(user, new SocialLinkModel(requestData.getProviderId(), username)); // Expire cookie and invalidate requestData String cookiePath = Urls.socialBase(uriInfo.getBaseUri()).build().getPath(); diff --git a/social/core/src/main/java/org/keycloak/social/AuthCallback.java b/social/core/src/main/java/org/keycloak/social/AuthCallback.java index 8e21a2166a..d9c579a211 100644 --- a/social/core/src/main/java/org/keycloak/social/AuthCallback.java +++ b/social/core/src/main/java/org/keycloak/social/AuthCallback.java @@ -28,11 +28,11 @@ import java.util.Map; */ public class AuthCallback { - private Map attributes; + private Map attributes; private Map queryParams; - public AuthCallback(Map attributes, Map queryParams) { + public AuthCallback(Map attributes, Map queryParams) { this.attributes = attributes; this.queryParams = queryParams; } diff --git a/social/core/src/main/java/org/keycloak/social/AuthRequest.java b/social/core/src/main/java/org/keycloak/social/AuthRequest.java index 69731e9d2b..a88d80521a 100644 --- a/social/core/src/main/java/org/keycloak/social/AuthRequest.java +++ b/social/core/src/main/java/org/keycloak/social/AuthRequest.java @@ -33,9 +33,9 @@ public class AuthRequest { private URI authUri; - private Map attributes; + private Map attributes; - AuthRequest(String id, URI authUri, Map attributes) { + AuthRequest(String id, URI authUri, Map attributes) { this.id = id; this.authUri = authUri; this.attributes = attributes; @@ -49,7 +49,7 @@ public class AuthRequest { return authUri; } - public Map getAttributes() { + public Map getAttributes() { return attributes; } diff --git a/social/core/src/main/java/org/keycloak/social/AuthRequestBuilder.java b/social/core/src/main/java/org/keycloak/social/AuthRequestBuilder.java index c5dd66a7a0..600783dda2 100644 --- a/social/core/src/main/java/org/keycloak/social/AuthRequestBuilder.java +++ b/social/core/src/main/java/org/keycloak/social/AuthRequestBuilder.java @@ -33,7 +33,7 @@ public class AuthRequestBuilder { private UriBuilder b; - private Map attributes; + private Map attributes; private String id; @@ -44,7 +44,7 @@ public class AuthRequestBuilder { AuthRequestBuilder req = new AuthRequestBuilder(); req.id = id; req.b = UriBuilder.fromUri(path); - req.attributes = new HashMap(); + req.attributes = new HashMap(); return req; } @@ -53,7 +53,7 @@ public class AuthRequestBuilder { return this; } - public AuthRequestBuilder setAttribute(String name, Object value) { + public AuthRequestBuilder setAttribute(String name, String value) { attributes.put(name, value); return this; } diff --git a/social/core/src/main/java/org/keycloak/social/RequestDetails.java b/social/core/src/main/java/org/keycloak/social/RequestDetails.java index f77f59bbfa..0476a642c3 100644 --- a/social/core/src/main/java/org/keycloak/social/RequestDetails.java +++ b/social/core/src/main/java/org/keycloak/social/RequestDetails.java @@ -32,9 +32,9 @@ public class RequestDetails { private Map clientAttributes; - private Map socialAttributes; + private Map socialAttributes; - RequestDetails(String providerId, Map clientAttributes, Map socialAttributes) { + RequestDetails(String providerId, Map clientAttributes, Map socialAttributes) { this.providerId = providerId; this.clientAttributes = clientAttributes; this.socialAttributes = socialAttributes; @@ -52,11 +52,11 @@ public class RequestDetails { return clientAttributes; } - public Object getSocialAttribute(String name) { + public String getSocialAttribute(String name) { return socialAttributes.get(name); } - public Map getSocialAttributes() { + public Map getSocialAttributes() { return socialAttributes; } diff --git a/social/core/src/main/java/org/keycloak/social/RequestDetailsBuilder.java b/social/core/src/main/java/org/keycloak/social/RequestDetailsBuilder.java index aa86fbefd9..0c2c73d0ad 100644 --- a/social/core/src/main/java/org/keycloak/social/RequestDetailsBuilder.java +++ b/social/core/src/main/java/org/keycloak/social/RequestDetailsBuilder.java @@ -33,7 +33,7 @@ public class RequestDetailsBuilder { private Map clientAttributes; - private Map socialAttributes; + private Map socialAttributes; private RequestDetailsBuilder() { } @@ -42,7 +42,7 @@ public class RequestDetailsBuilder { RequestDetailsBuilder req = new RequestDetailsBuilder(); req.providerId = providerId; req.clientAttributes = new HashMap(); - req.socialAttributes = new HashMap(); + req.socialAttributes = new HashMap(); return req; } @@ -51,7 +51,7 @@ public class RequestDetailsBuilder { req.providerId = from.getProviderId(); req.clientAttributes = new HashMap(); req.clientAttributes.putAll(from.getClientAttributes()); - req.socialAttributes = new HashMap(); + req.socialAttributes = new HashMap(); req.socialAttributes.putAll(from.getSocialAttributes()); return req; } @@ -66,12 +66,12 @@ public class RequestDetailsBuilder { return this; } - public RequestDetailsBuilder putSocialAttribute(String name, Object value) { + public RequestDetailsBuilder putSocialAttribute(String name, String value) { socialAttributes.put(name, value); return this; } - public RequestDetailsBuilder putSocialAttributes(Map attributes) { + public RequestDetailsBuilder putSocialAttributes(Map attributes) { socialAttributes.putAll(attributes); return this; } diff --git a/social/core/src/main/java/org/keycloak/social/SocialProviderConfig.java b/social/core/src/main/java/org/keycloak/social/SocialProviderConfig.java index d6d1276f13..4989861e92 100644 --- a/social/core/src/main/java/org/keycloak/social/SocialProviderConfig.java +++ b/social/core/src/main/java/org/keycloak/social/SocialProviderConfig.java @@ -50,8 +50,4 @@ public class SocialProviderConfig { return secret; } - public void setSecret(String secret) { - this.secret = secret; - } - }