Examples of ConnectionRepository


Examples of org.springframework.social.connect.ConnectionRepository

    return connectionRepository.findConnections(providerId).size() > 0;
  }

  private ConnectionRepository getConnectionRepository(final IContext context) {
    ApplicationContext applicationContext = getSpringApplicationContextFromThymeleafContext(context);
    ConnectionRepository connectionRepository = applicationContext.getBean(ConnectionRepository.class);
    return connectionRepository;
  }
View Full Code Here

Examples of org.springframework.social.connect.ConnectionRepository

   *
   */
  @Override
  public UserDetails loadUserByUsername(String userName)
      throws UsernameNotFoundException {
    ConnectionRepository connectionRepository = usersConnectionRepository
        .createConnectionRepository(userName);
    SpringSocialProfile springSocialProfile = signUpService.getUserProfile(userName);
    List<Connection<?>> allConnections = getConnections(connectionRepository,userName);
    if (allConnections.size() > 0) {
       
View Full Code Here

Examples of org.springframework.social.connect.ConnectionRepository

  }

  @Override
  public SpringSocialProfile getUserProfile(String userId)
      throws UsernameNotFoundException {
    ConnectionRepository connectionRepository = usersConnectionRepository.createConnectionRepository(userId);
    List<Connection<SpringSocialSecurity>> connections = connectionRepository.findConnections(SpringSocialSecurity.class);
    if (connections.size() ==1)
    {
      return connections.get(0).getApi().getUserProfile();
    }
    else
View Full Code Here

Examples of org.springframework.social.connect.ConnectionRepository

    } else if (!authService.getConnectionCardinality().isMultiUserId() && !connectedUserIds.isEmpty()) {
      // providerUserId already connected to different userId and no multi user allowed
      return null;
    }

    ConnectionRepository repo = usersConnectionRepository.createConnectionRepository(userId);

    if (!authService.getConnectionCardinality().isMultiProviderUserId()) {
      List<Connection<?>> connections = repo.findConnections(connectionKey.getProviderId());
      if (!connections.isEmpty()) {
        // TODO maybe throw an exception to allow UI feedback?
        return null;
      }
    }

    // add new connection
    repo.addConnection(connection);
    return connection;
  }
View Full Code Here

Examples of org.springframework.social.connect.ConnectionRepository

  private void updateConnections(SocialAuthenticationService<?> authService, SocialAuthenticationToken token, Authentication success) {
    if (updateConnections) {
      String userId = ((SocialUserDetails)success.getPrincipal()).getUserId();
      Connection<?> connection = token.getConnection();
      ConnectionRepository repo = getUsersConnectionRepository().createConnectionRepository(userId);
      repo.updateConnection(connection);
    }
  }
View Full Code Here

Examples of org.springframework.social.connect.ConnectionRepository

      logger.info("Deauthorization request received for Facebook User ID: " + userId + "; Removing connections.");
      Set<String> providerUserIds = new HashSet<String>();
      providerUserIds.add(userId);
      Set<String> localUserIds = usersConnectionRepository.findUserIdsConnectedTo("facebook", providerUserIds);
      for (String localUserId : localUserIds) {
        ConnectionRepository connectionRepository = usersConnectionRepository.createConnectionRepository(localUserId);
        logger.info("  Removing Facebook connection for local user '" + localUserId + "'");
        connectionRepository.removeConnection(new ConnectionKey("facebook", userId));
      }   
      return new ResponseEntity<String>(HttpStatus.NO_CONTENT);
    } catch (SignedRequestException e) {
      return new ResponseEntity<String>(HttpStatus.BAD_REQUEST);
    }
View Full Code Here

Examples of org.springframework.social.connect.ConnectionRepository

  @Test
  public void disconnect() throws Exception {
    FacebookConnectionFactory connectionFactory = new FacebookConnectionFactory("clientId", CLIENT_SECRET);
    Connection<Facebook> connection = connectionFactory.createConnection(new ConnectionData("facebook", "738140579", "", "", "", "", "", "", null));
    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    ConnectionRepository connectionRepository = usersConnectionRepository.createConnectionRepository("habuma");
    connectionRepository.addConnection(connection);
    assertEquals(1, connectionRepository.findAllConnections().size());
    DisconnectController controller = new DisconnectController(usersConnectionRepository, CLIENT_SECRET);
    MockMvc mockMvc = standaloneSetup(controller).build();
    mockMvc.perform(post("/disconnect/facebook").param("signed_request", SIGNED_REQUEST))
      .andExpect(status().isNoContent());   
    assertEquals(0, connectionRepository.findAllConnections().size());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.