public class ConnectionUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
AVATAR_LINK_ATTRIBUTE_NAME |
static String |
CONNECTIONS_ATTRIBUTE_NAME |
static String |
DISPLAY_NAME_ATTRIBUTE_NAME |
static String |
FIRST_NAME_ATTRIBUTE_NAME |
static String |
LAST_NAME_ATTRIBUTE_NAME |
| Constructor and Description |
|---|
ConnectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addConnectionData(Profile profile,
org.springframework.social.connect.ConnectionData connectionData,
org.craftercms.commons.crypto.TextEncryptor encryptor)
Adds the specified
ConnectionData to the profile. |
static void |
addProviderProfileInfo(Profile profile,
org.springframework.social.connect.UserProfile providerProfile)
Adds the info from the provider profile to the specified profile.
|
static Map<String,Object> |
connectionDataToMap(org.springframework.social.connect.ConnectionData connectionData,
org.craftercms.commons.crypto.TextEncryptor encryptor)
Creates a new map from the specified
ConnectionData. |
static Profile |
createProfile(org.springframework.social.connect.Connection<?> connection)
Creates a profile from the specified connection.
|
static List<org.springframework.social.connect.ConnectionData> |
getConnectionData(Profile profile,
String providerId,
org.craftercms.commons.crypto.TextEncryptor encryptor)
Returns the list of
ConnectionData associated to the provider ID of
the specified profile |
static org.springframework.social.connect.ConnectionData |
mapToConnectionData(String providerId,
Map<String,Object> map,
org.craftercms.commons.crypto.TextEncryptor encryptor)
Creates a new instance of
ConnectionData from the specified map. |
static void |
removeConnectionData(Profile profile,
String providerId)
Remove all
ConnectionData associated to the specified provider ID. |
static void |
removeConnectionData(String providerId,
String providerUserId,
Profile profile)
Remove the
ConnectionData associated to the provider ID and user ID. |
public static final String CONNECTIONS_ATTRIBUTE_NAME
public static final String FIRST_NAME_ATTRIBUTE_NAME
public static final String LAST_NAME_ATTRIBUTE_NAME
public static final String DISPLAY_NAME_ATTRIBUTE_NAME
public static final String AVATAR_LINK_ATTRIBUTE_NAME
public static Map<String,Object> connectionDataToMap(org.springframework.social.connect.ConnectionData connectionData, org.craftercms.commons.crypto.TextEncryptor encryptor) throws org.craftercms.commons.crypto.CryptoException
ConnectionData. Used when
connection data needs to be stored in a profile.connectionData - the connection data to convertencryptor - the encryptor used to encrypt the accessToken, secret and refreshToken (optional)org.craftercms.commons.crypto.CryptoExceptionpublic static org.springframework.social.connect.ConnectionData mapToConnectionData(String providerId, Map<String,Object> map, org.craftercms.commons.crypto.TextEncryptor encryptor) throws org.craftercms.commons.crypto.CryptoException
ConnectionData from the specified map.
Used when connection data needs to be retrieved from a profile.providerId - the provider ID of the connection (which is not stored in the map)map - the map to convertencryptor - the encryptor used to decrypt the accessToken, secret and refreshToken (optional)ConnectionDataorg.craftercms.commons.crypto.CryptoExceptionpublic static void addConnectionData(Profile profile, org.springframework.social.connect.ConnectionData connectionData, org.craftercms.commons.crypto.TextEncryptor encryptor) throws org.craftercms.commons.crypto.CryptoException
ConnectionData to the profile. If a connection
data with the same user ID already exists, it will be replaced with the new data.profile - the profileconnectionData - the connection data to addencryptor - the encryptor used to encrypt the accessToken, secret and refreshTokenorg.craftercms.commons.crypto.CryptoExceptionpublic static List<org.springframework.social.connect.ConnectionData> getConnectionData(Profile profile, String providerId, org.craftercms.commons.crypto.TextEncryptor encryptor) throws org.craftercms.commons.crypto.CryptoException
ConnectionData associated to the provider ID of
the specified profileprofile - the profile that contains the connection data in its attributesproviderId - the provider ID of the connectionencryptor - the encryptor used to decrypt the accessToken, secret and refreshTokenorg.craftercms.commons.crypto.CryptoExceptionpublic static void removeConnectionData(Profile profile, String providerId)
ConnectionData associated to the specified provider ID.profile - the profile where to remove the data fromproviderId - the provider ID of the connectionpublic static void removeConnectionData(String providerId, String providerUserId, Profile profile)
ConnectionData associated to the provider ID and user ID.providerId - the provider ID of the connectionproviderUserId - the provider user IDprofile - the profile where to remove the data frompublic static void addProviderProfileInfo(Profile profile, org.springframework.social.connect.UserProfile providerProfile)
profile - the target profileproviderProfile - the provider profile where to get the infopublic static Profile createProfile(org.springframework.social.connect.Connection<?> connection)
connection - the connection where to retrieve the profile info fromCopyright © 2023 CrafterCMS. All rights reserved.