Implemented a simple UserIdSource, that stores the user in a cookie
[examples/facebook-app] / src / main / java / de / juplo / yourshouter / ProviderUserIdConnectionSignUp.java
1 package de.juplo.yourshouter;
2
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 import org.springframework.social.connect.Connection;
6 import org.springframework.social.connect.ConnectionKey;
7 import org.springframework.social.connect.ConnectionSignUp;
8 import org.springframework.stereotype.Service;
9
10
11 /**
12  * Extracts the local user-ID from the data given by the provider.
13  *
14  * @author Kai Moritz
15  */
16 @Service
17 public class ProviderUserIdConnectionSignUp implements ConnectionSignUp
18 {
19   private final Logger LOG =
20       LoggerFactory.getLogger(ProviderUserIdConnectionSignUp.class);
21
22
23   /**
24    * This implementation simply reuse the ID, that was provided by the provider.
25    *
26    * @param connection
27    *     The {@link Connection} for the unknown user.
28    * @return
29    *     The user-ID, that was provided by the provider.
30    */
31   @Override
32   public String execute(Connection<?> connection)
33   {
34     ConnectionKey key = connection.getKey();
35     LOG.info(
36         "signing up user {} from provider {}",
37         key.getProviderUserId(),
38         key.getProviderId()
39         );
40     return key.getProviderUserId();
41   }
42 }