Moved SocialRequestManager from social/core to services
This commit is contained in:
parent
de6cd5f10a
commit
2ff46353bc
9 changed files with 23 additions and 27 deletions
|
@ -19,7 +19,9 @@
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
* 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.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
|
@ -8,7 +8,7 @@ import org.keycloak.models.picketlink.PicketlinkKeycloakSessionFactory;
|
||||||
import org.keycloak.models.picketlink.mappings.ApplicationEntity;
|
import org.keycloak.models.picketlink.mappings.ApplicationEntity;
|
||||||
import org.keycloak.models.picketlink.mappings.RealmEntity;
|
import org.keycloak.models.picketlink.mappings.RealmEntity;
|
||||||
import org.keycloak.services.utils.PropertiesManager;
|
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.PartitionManager;
|
||||||
import org.picketlink.idm.config.IdentityConfigurationBuilder;
|
import org.picketlink.idm.config.IdentityConfigurationBuilder;
|
||||||
import org.picketlink.idm.internal.DefaultPartitionManager;
|
import org.picketlink.idm.internal.DefaultPartitionManager;
|
||||||
|
|
|
@ -66,7 +66,7 @@ import org.keycloak.social.SocialConstants;
|
||||||
import org.keycloak.social.SocialProvider;
|
import org.keycloak.social.SocialProvider;
|
||||||
import org.keycloak.social.SocialProviderConfig;
|
import org.keycloak.social.SocialProviderConfig;
|
||||||
import org.keycloak.social.SocialProviderException;
|
import org.keycloak.social.SocialProviderException;
|
||||||
import org.keycloak.social.SocialRequestManager;
|
import org.keycloak.services.managers.SocialRequestManager;
|
||||||
import org.keycloak.social.SocialUser;
|
import org.keycloak.social.SocialUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,7 +186,6 @@ public class SocialResource {
|
||||||
MultivaluedMap<String, String> formData = fillRegistrationFormWithSocialData(socialUser);
|
MultivaluedMap<String, String> formData = fillRegistrationFormWithSocialData(socialUser);
|
||||||
|
|
||||||
RequestDetailsBuilder reqDetailsBuilder = RequestDetailsBuilder.createFromRequestDetails(requestData);
|
RequestDetailsBuilder reqDetailsBuilder = RequestDetailsBuilder.createFromRequestDetails(requestData);
|
||||||
reqDetailsBuilder.putSocialAttribute(SocialConstants.ATTR_SOCIAL_LINK, socialLink);
|
|
||||||
|
|
||||||
String requestId = UUID.randomUUID().toString();
|
String requestId = UUID.randomUUID().toString();
|
||||||
socialRequestManager.addRequest(requestId, reqDetailsBuilder.build());
|
socialRequestManager.addRequest(requestId, reqDetailsBuilder.build());
|
||||||
|
@ -281,7 +280,6 @@ public class SocialResource {
|
||||||
String scope = requestData.getClientAttribute("scope");
|
String scope = requestData.getClientAttribute("scope");
|
||||||
String state = requestData.getClientAttribute("state");
|
String state = requestData.getClientAttribute("state");
|
||||||
String redirectUri = requestData.getClientAttribute("redirectUri");
|
String redirectUri = requestData.getClientAttribute("redirectUri");
|
||||||
SocialLinkModel socialLink = (SocialLinkModel)requestData.getSocialAttribute(SocialConstants.ATTR_SOCIAL_LINK);
|
|
||||||
|
|
||||||
Response response1 = tokenService.processRegisterImpl(clientId, scope, state, redirectUri, formData, true);
|
Response response1 = tokenService.processRegisterImpl(clientId, scope, state, redirectUri, formData, true);
|
||||||
|
|
||||||
|
@ -297,7 +295,7 @@ public class SocialResource {
|
||||||
// Normally shouldn't happen
|
// Normally shouldn't happen
|
||||||
throw new IllegalStateException("User " + username + " not found in the realm");
|
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
|
// Expire cookie and invalidate requestData
|
||||||
String cookiePath = Urls.socialBase(uriInfo.getBaseUri()).build().getPath();
|
String cookiePath = Urls.socialBase(uriInfo.getBaseUri()).build().getPath();
|
||||||
|
|
|
@ -28,11 +28,11 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class AuthCallback {
|
public class AuthCallback {
|
||||||
|
|
||||||
private Map<String, Object> attributes;
|
private Map<String, String> attributes;
|
||||||
|
|
||||||
private Map<String, String[]> queryParams;
|
private Map<String, String[]> queryParams;
|
||||||
|
|
||||||
public AuthCallback(Map<String, Object> attributes, Map<String, String[]> queryParams) {
|
public AuthCallback(Map<String, String> attributes, Map<String, String[]> queryParams) {
|
||||||
this.attributes = attributes;
|
this.attributes = attributes;
|
||||||
this.queryParams = queryParams;
|
this.queryParams = queryParams;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@ public class AuthRequest {
|
||||||
|
|
||||||
private URI authUri;
|
private URI authUri;
|
||||||
|
|
||||||
private Map<String, Object> attributes;
|
private Map<String, String> attributes;
|
||||||
|
|
||||||
AuthRequest(String id, URI authUri, Map<String, Object> attributes) {
|
AuthRequest(String id, URI authUri, Map<String, String> attributes) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.authUri = authUri;
|
this.authUri = authUri;
|
||||||
this.attributes = attributes;
|
this.attributes = attributes;
|
||||||
|
@ -49,7 +49,7 @@ public class AuthRequest {
|
||||||
return authUri;
|
return authUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getAttributes() {
|
public Map<String, String> getAttributes() {
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class AuthRequestBuilder {
|
||||||
|
|
||||||
private UriBuilder b;
|
private UriBuilder b;
|
||||||
|
|
||||||
private Map<String, Object> attributes;
|
private Map<String, String> attributes;
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class AuthRequestBuilder {
|
||||||
AuthRequestBuilder req = new AuthRequestBuilder();
|
AuthRequestBuilder req = new AuthRequestBuilder();
|
||||||
req.id = id;
|
req.id = id;
|
||||||
req.b = UriBuilder.fromUri(path);
|
req.b = UriBuilder.fromUri(path);
|
||||||
req.attributes = new HashMap<String, Object>();
|
req.attributes = new HashMap<String, String>();
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class AuthRequestBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthRequestBuilder setAttribute(String name, Object value) {
|
public AuthRequestBuilder setAttribute(String name, String value) {
|
||||||
attributes.put(name, value);
|
attributes.put(name, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ public class RequestDetails {
|
||||||
|
|
||||||
private Map<String, String> clientAttributes;
|
private Map<String, String> clientAttributes;
|
||||||
|
|
||||||
private Map<String, Object> socialAttributes;
|
private Map<String, String> socialAttributes;
|
||||||
|
|
||||||
RequestDetails(String providerId, Map<String, String> clientAttributes, Map<String, Object> socialAttributes) {
|
RequestDetails(String providerId, Map<String, String> clientAttributes, Map<String, String> socialAttributes) {
|
||||||
this.providerId = providerId;
|
this.providerId = providerId;
|
||||||
this.clientAttributes = clientAttributes;
|
this.clientAttributes = clientAttributes;
|
||||||
this.socialAttributes = socialAttributes;
|
this.socialAttributes = socialAttributes;
|
||||||
|
@ -52,11 +52,11 @@ public class RequestDetails {
|
||||||
return clientAttributes;
|
return clientAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getSocialAttribute(String name) {
|
public String getSocialAttribute(String name) {
|
||||||
return socialAttributes.get(name);
|
return socialAttributes.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getSocialAttributes() {
|
public Map<String, String> getSocialAttributes() {
|
||||||
return socialAttributes;
|
return socialAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class RequestDetailsBuilder {
|
||||||
|
|
||||||
private Map<String, String> clientAttributes;
|
private Map<String, String> clientAttributes;
|
||||||
|
|
||||||
private Map<String, Object> socialAttributes;
|
private Map<String, String> socialAttributes;
|
||||||
|
|
||||||
private RequestDetailsBuilder() {
|
private RequestDetailsBuilder() {
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class RequestDetailsBuilder {
|
||||||
RequestDetailsBuilder req = new RequestDetailsBuilder();
|
RequestDetailsBuilder req = new RequestDetailsBuilder();
|
||||||
req.providerId = providerId;
|
req.providerId = providerId;
|
||||||
req.clientAttributes = new HashMap<String, String>();
|
req.clientAttributes = new HashMap<String, String>();
|
||||||
req.socialAttributes = new HashMap<String, Object>();
|
req.socialAttributes = new HashMap<String, String>();
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class RequestDetailsBuilder {
|
||||||
req.providerId = from.getProviderId();
|
req.providerId = from.getProviderId();
|
||||||
req.clientAttributes = new HashMap<String, String>();
|
req.clientAttributes = new HashMap<String, String>();
|
||||||
req.clientAttributes.putAll(from.getClientAttributes());
|
req.clientAttributes.putAll(from.getClientAttributes());
|
||||||
req.socialAttributes = new HashMap<String, Object>();
|
req.socialAttributes = new HashMap<String, String>();
|
||||||
req.socialAttributes.putAll(from.getSocialAttributes());
|
req.socialAttributes.putAll(from.getSocialAttributes());
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
@ -66,12 +66,12 @@ public class RequestDetailsBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RequestDetailsBuilder putSocialAttribute(String name, Object value) {
|
public RequestDetailsBuilder putSocialAttribute(String name, String value) {
|
||||||
socialAttributes.put(name, value);
|
socialAttributes.put(name, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RequestDetailsBuilder putSocialAttributes(Map<String, Object> attributes) {
|
public RequestDetailsBuilder putSocialAttributes(Map<String, String> attributes) {
|
||||||
socialAttributes.putAll(attributes);
|
socialAttributes.putAll(attributes);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,4 @@ public class SocialProviderConfig {
|
||||||
return secret;
|
return secret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSecret(String secret) {
|
|
||||||
this.secret = secret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue