Package org.springframework.social.connect

Examples of org.springframework.social.connect.ConnectionRepository


  protected boolean isVisible(Arguments arguments, Element element, String attributeName) {
    final String providerId = element.getAttributeValue(attributeName);
    if (providerId == null || providerId.trim().equals("")) {
      return false;
    }
    ConnectionRepository connectionRepository = getConnectionRepository(arguments.getContext());
    return connectionRepository.findConnections(providerId).size() > 0;
  }
View Full Code Here


      applicationContext = getSpringApplicationContextForThymeleaf3(context);
    } else {
      throw new ConfigurationException("Neither Thymeleaf 3 SpringWebContext nor Thymeleaf 4 SpringWebContext is in "
          + "the application classpath.");
    }
    ConnectionRepository connectionRepository = applicationContext.getBean(ConnectionRepository.class);
    return connectionRepository;
  }
View Full Code Here

    }

    private GitHub getGitHub(Principal principal) {
        MemberProfile profile = teamService.fetchMemberProfile(new Long(principal.getName()));
        String githubId = profile.getGithubId().toString();
        ConnectionRepository connectionRepository = usersConnectionRepository.createConnectionRepository(githubId);
        Connection<GitHub> connection = connectionRepository.findPrimaryConnection(GitHub.class);
        if (connection != null) {
            return connection.getApi();
        }
        throw new RuntimeException("Unable to obtain GitHub connection");
    }
View Full Code Here

      public String getUserId() {
        return "habuma";
      }
    };

    ConnectionRepository connRepo = mock(ConnectionRepository.class);
    when(uconnRepo.createConnectionRepository("habuma")).thenReturn(connRepo);
    ReconnectFilter filter = new ReconnectFilter(uconnRepo, userIdSource);
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("GET");
    request.setServletPath(servletPath);
View Full Code Here

  public void addConnection() {
    UsersConnectionRepository usersConnectionRepository = mock(UsersConnectionRepository.class);
    SocialAuthenticationFilter filter = new SocialAuthenticationFilter(null, null, usersConnectionRepository, null);
   
    SocialAuthenticationService<Object> authService = mock(SocialAuthenticationService.class);
    ConnectionRepository connectionRepository = mock(ConnectionRepository.class);
    ConnectionFactory<Object> connectionFactory = mock(MockConnectionFactory.class);
   
    MockHttpServletRequest request = new MockHttpServletRequest();
    ConnectionData data = new ConnectionData("dummyprovider", "1234", null, null, null, null, null, null, null);
    String userId = "joe";
View Full Code Here

      filter = new SocialAuthenticationFilter(authManager, mock(UserIdSource.class), mock(UsersConnectionRepository.class), new SocialAuthenticationServiceRegistry());
      filter.setServletContext(context);
      filter.setRememberMeServices(new NullRememberMeServices());
      filter.setSignupUrl(signupUrl);
     
      ConnectionRepository repo = mock(ConnectionRepository.class);
      when(filter.getUsersConnectionRepository().createConnectionRepository(Mockito.anyString())).thenReturn(repo);
     
      auth = new SocialAuthenticationToken(DummyConnection.dummy("provider", "user"), null);

      Collection<? extends GrantedAuthority> authorities = Collections.emptyList();
View Full Code Here

  }

  @Test
  public void jdbcConnectionRepository_addAndRemoveAConnection() {
    ConnectionFactoryLocator cfl = context.getBean(ConnectionFactoryLocator.class);
    ConnectionRepository connectionRepository = context.getBean(ConnectionRepository.class);
    testConnectionRepository(cfl, connectionRepository);
  }
View Full Code Here

  }

  @Test
  public void jdbcConnectionRepository_addConnection() {
    ConnectionFactoryLocator cfl = context.getBean(ConnectionFactoryLocator.class);
    ConnectionRepository connectionRepository = context.getBean(ConnectionRepository.class);
    testConnectionRepository(cfl, connectionRepository);
  }
View Full Code Here

      return null;
    } else if (!authService.getConnectionCardinality().isMultiUserId() && !connectedUserIds.isEmpty()) {
      return null;
    }

    ConnectionRepository repo = usersConnectionRepository.createConnectionRepository(userId);

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

    // add new connection
    Connection<?> connection = authService.getConnectionFactory().createConnection(data);
    connection.sync();
    repo.addConnection(connection);
    return connection;
  }
View Full Code Here

  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

TOP

Related Classes of org.springframework.social.connect.ConnectionRepository

Copyright © 2018 www.massapicom. 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.