当前位置: 首页>>代码示例>>Java>>正文


Java ConnectionFactory类代码示例

本文整理汇总了Java中org.springframework.social.connect.ConnectionFactory的典型用法代码示例。如果您正苦于以下问题:Java ConnectionFactory类的具体用法?Java ConnectionFactory怎么用?Java ConnectionFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConnectionFactory类属于org.springframework.social.connect包,在下文中一共展示了ConnectionFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleSignIn

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
private RedirectView handleSignIn(Connection<?> connection, ConnectionFactory<?> connectionFactory,
    NativeWebRequest request) {
    List<String> userIds = usersConnectionRepository.findUserIdsWithConnection(connection);
    if (userIds.isEmpty()) {
        ProviderSignInAttempt signInAttempt = new ProviderSignInAttempt(connection);
        sessionStrategy.setAttribute(request, ProviderSignInAttempt.SESSION_ATTRIBUTE, signInAttempt);
        return redirect(getSignUpUrl());
    } else if (userIds.size() == 1) {
        usersConnectionRepository.createConnectionRepository(userIds.get(0)).updateConnection(connection);
        String originalUrl = signInAdapter.signIn(userIds.get(0), connection, request);
        return originalUrl != null ? redirect(originalUrl) : redirect(POST_SIGN_IN_URL);
    } else {
        log.error("Find more than one user with connection key: {}", connection.getKey());
        return redirectOnError(connection.getKey().getProviderId());
    }
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:17,代码来源:SocialController.java

示例2: getConnectionFactory

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
@Override
public ConnectionFactory<?> getConnectionFactory(String providerId) {
    HttpServletRequest req = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes())
        .getRequest();
    String domain = TenantContext.getCurrent().getDomain();
    Optional<SocialConfig> config = socialConfigRepository.findOneByProviderIdAndDomain(providerId, domain);
    if (config.isPresent()) {
        SocialConfig sc = config.get();
        switch (sc.getProviderId()) {
            case "facebook":
                return new FacebookConnectionFactory(sc.getConsumerKey(), sc.getConsumerSecret());
            case "google":
                return new GoogleConnectionFactory(sc.getConsumerKey(), sc.getConsumerSecret());
            case "twitter":
                return new TwitterConnectionFactory(sc.getConsumerKey(), sc.getConsumerSecret());
            case "linkedin":
                return new LinkedInConnectionFactory(sc.getConsumerKey(), sc.getConsumerSecret());
            default:
                break;
        }
    }
    throw new IllegalArgumentException("No provider config found for " + providerId);
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:24,代码来源:DomainConnectionFactoryLocator.java

示例3: socialUserConnectionToConnection

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
private Connection<?> socialUserConnectionToConnection(final SocialUserConnection socialUserConnection) {
    final ConnectionData connectionData = new ConnectionData(socialUserConnection.getProviderId(),
            socialUserConnection.getProviderUserId(),
            socialUserConnection.getDisplayName(),
            socialUserConnection.getProfileURL(),
            socialUserConnection.getImageURL(),
            socialUserConnection.getAccessToken(),
            socialUserConnection.getSecret(),
            socialUserConnection.getRefreshToken(),
            socialUserConnection.getExpireTime());

    final ConnectionFactory<?> connectionFactory
            = connectionFactoryLocator.getConnectionFactory(connectionData.getProviderId());

    return connectionFactory.createConnection(connectionData);
}
 
开发者ID:vlsidlyarevich,项目名称:unity,代码行数:17,代码来源:CustomSocialConnectionRepository.java

示例4: createConnectionFactory

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
public ConnectionFactory<?> createConnectionFactory(String appId, String appSecret) {
	switch(this) {
	case facebook:
		return new FacebookConnectionFactory(appId, appSecret);
	case twitter:
		return new TwitterConnectionFactory(appId, appSecret);
	case google:
		GoogleConnectionFactory factory = new GoogleConnectionFactory(appId, appSecret);
		factory.setScope("openid profile");
		return factory;
	case linkedin:
		return new LinkedInConnectionFactory(appId, appSecret);
	case github:
		return new GitHubConnectionFactory(appId, appSecret);
	default:
		return null;
	}
}
 
开发者ID:openanalytics,项目名称:shinyproxy,代码行数:19,代码来源:SocialConfiguration.java

示例5: testCreateConnectionRepository

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
@Test
public void testCreateConnectionRepository() throws Exception {
  User user = new User(SocialTestUtils.USER_ONE);
  user.setId(idProvider.getAndIncrement());
  when(userRepository.findOneByPrimaryEmail(SocialTestUtils.USER_EMAIL_ONE))
      .thenReturn(user);

  Connection connection = mock(Connection.class);
  ArgumentCaptor<ConnectionData> connectionDataCaptor =
      ArgumentCaptor.forClass(ConnectionData.class);
  ConnectionFactory connectionFactoryOne = mock(ConnectionFactory.class);
  when(connectionFactoryLocator.getConnectionFactory(user.getAuthProviderId()))
      .thenReturn(connectionFactoryOne);
  when(connectionFactoryOne.createConnection(connectionDataCaptor.capture()))
      .thenReturn(connection);

  ConnectionRepository connectionRepository = usersConnectionRepository
      .createConnectionRepository(SocialTestUtils.USER_EMAIL_ONE);
  assertTrue(connectionRepository instanceof AwesomeAgileConnectionRepository);
}
 
开发者ID:cs71-caffeine,项目名称:awesome-agile,代码行数:21,代码来源:AwesomeAgileUsersConnectionRepositoryTest.java

示例6: signIn

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
@PostMapping(value = "/signin/{providerId}")
public RedirectView signIn(@PathVariable String providerId, NativeWebRequest request) {
    try {
        ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(providerId);
        MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
        return redirectAbsolute(connectSupport.buildOAuthUrl(connectionFactory, request, parameters));
    } catch (Exception e) {
        log.error("Exception while building authorization URL: ", e);
        return redirectOnError(providerId);
    }
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:12,代码来源:SocialController.java

示例7: buildOAuthUrl

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
/**
 * Builds the provider URL to redirect the user to for connection authorization.
 *
 * @param connectionFactory the service provider's connection factory e.g. FacebookConnectionFactory
 * @param request the current web request
 * @param additionalParameters parameters to add to the authorization URL.
 * @return the URL to redirect the user to for authorization
 * @throws IllegalArgumentException if the connection factory is not OAuth1 based.
 */
public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, NativeWebRequest request,
    MultiValueMap<String, String> additionalParameters) {
    if (connectionFactory instanceof OAuth1ConnectionFactory) {
        return buildOAuth1Url((OAuth1ConnectionFactory<?>) connectionFactory, request, additionalParameters);
    } else if (connectionFactory instanceof OAuth2ConnectionFactory) {
        return buildOAuth2Url((OAuth2ConnectionFactory<?>) connectionFactory, request, additionalParameters);
    } else {
        throw new IllegalArgumentException("ConnectionFactory not supported");
    }
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:20,代码来源:ConnectSupport.java

示例8: handleSignIn

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
private RedirectView handleSignIn(Connection<?> connection, ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
    List<String> userIds = usersConnectionRepository.findUserIdsWithConnection(connection);
    if (userIds.size() == 0) {
        ProviderSignInAttempt signInAttempt = new ProviderSignInAttempt(connection);
        sessionStrategy.setAttribute(request, ProviderSignInAttempt.SESSION_ATTRIBUTE, signInAttempt);
        return redirect(signUpUrl);
    } else if (userIds.size() == 1) {
        usersConnectionRepository.createConnectionRepository(userIds.get(0)).updateConnection(connection);
        String originalUrl = signInAdapter.signIn(userIds.get(0), connection, request);
        postSignIn(connectionFactory, connection, (WebRequest) request);
        return originalUrl != null ? redirect(originalUrl) : redirect(postSignInUrl);
    } else {
        return redirect(URIBuilder.fromUri(signInUrl).queryParam("error", "multiple_users").build().toString());
    }
}
 
开发者ID:tomwetjens,项目名称:spring-social-garmin,代码行数:16,代码来源:GarminSigninController.java

示例9: interceptingSignInTo

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
private List<ProviderSignInInterceptor<?>> interceptingSignInTo(ConnectionFactory<?> connectionFactory) {
    Class<?> serviceType = GenericTypeResolver.resolveTypeArgument(connectionFactory.getClass(), ConnectionFactory.class);
    List<ProviderSignInInterceptor<?>> typedInterceptors = signInInterceptors.get(serviceType);
    if (typedInterceptors == null) {
        typedInterceptors = Collections.emptyList();
    }
    return typedInterceptors;
}
 
开发者ID:tomwetjens,项目名称:spring-social-garmin,代码行数:9,代码来源:GarminSigninController.java

示例10: findAllConnections

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
@Override
public MultiValueMap<String, Connection<?>> findAllConnections() {
  User user = getUser();
  ConnectionFactory connectionFactory =
      connectionFactoryLocator.getConnectionFactory(user.getAuthProviderId());
  return toMultiValueMap(ImmutableMap.of(user.getAuthProviderId(),
          (List<Connection<?>>)ImmutableList.<Connection<?>>of(
              connectionFactory.createConnection(connectionData(user)))));
}
 
开发者ID:cs71-caffeine,项目名称:awesome-agile,代码行数:10,代码来源:AwesomeAgileConnectionRepository.java

示例11: findConnections

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
@Override
public <A> List<Connection<A>> findConnections(Class<A> apiType) {
  User user = getUser();
  ConnectionFactory<A> connectionFactory =
      connectionFactoryLocator.getConnectionFactory(apiType);
  if (connectionFactory != null) {
    return ImmutableList.of(connectionFactory.createConnection(connectionData(user)));
  }
  return ImmutableList.of();
}
 
开发者ID:cs71-caffeine,项目名称:awesome-agile,代码行数:11,代码来源:AwesomeAgileConnectionRepository.java

示例12: getConnection

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
@Override
public Connection<?> getConnection(ConnectionKey key) {
  User user = userRepository.findOneByAuthProviderUserId(
      key.getProviderId(), key.getProviderUserId());
  if (user.getId() == userId) {
    ConnectionFactory<?> connectionFactory = connectionFactoryLocator
        .getConnectionFactory(key.getProviderId());
    return connectionFactory.createConnection(connectionData(user));
  }
  throw new NoSuchConnectionException(key);
}
 
开发者ID:cs71-caffeine,项目名称:awesome-agile,代码行数:12,代码来源:AwesomeAgileConnectionRepository.java

示例13: findPrimaryConnection

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
@Override
public <A> Connection<A> findPrimaryConnection(Class<A> apiType) {
  ConnectionFactory<A> connectionFactory = getConnectionFactory(apiType);
  User user = getUser();
  String providerId = connectionFactory.getProviderId();
  if (providerId.equals(user.getAuthProviderId())) {
    return connectionFactory.createConnection(connectionData(user));
  }
  return null;
}
 
开发者ID:cs71-caffeine,项目名称:awesome-agile,代码行数:11,代码来源:AwesomeAgileConnectionRepository.java

示例14: authToConnection

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
private Connection<?> authToConnection(SocialAuthentication auth) {
    ConnectionFactory<?> connectionFactory = locator.getConnectionFactory(auth.getProviderId());
    ConnectionData data = new ConnectionData(auth.getProviderId(), auth.getProviderUserId(), null, null,
            auth.getImageUrl(), auth.getToken(), auth.getSecret(), auth.getRefreshToken(),
            auth.getExpirationTime());
    return connectionFactory.createConnection(data);
}
 
开发者ID:Glamdring,项目名称:scientific-publishing,代码行数:8,代码来源:JpaConnectionRepository.java

示例15: socialUserConnectionToConnection

import org.springframework.social.connect.ConnectionFactory; //导入依赖的package包/类
private Connection<?> socialUserConnectionToConnection(SocialUserConnection socialUserConnection) {
  ConnectionData connectionData = new ConnectionData(socialUserConnection.getProviderId(), socialUserConnection.getProviderUserId(),
    socialUserConnection.getDisplayName(), socialUserConnection.getProfileUrl(), socialUserConnection.getImageURL(),
    socialUserConnection.getAccessToken(), socialUserConnection.getSecret(), socialUserConnection.getRefreshToken(),
    socialUserConnection.getExpireTime());
  ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(connectionData.getProviderId());
  return connectionFactory.createConnection(connectionData);
}
 
开发者ID:priitl,项目名称:p2p-webtv,代码行数:9,代码来源:CustomSocialConnectionRepository.java


注:本文中的org.springframework.social.connect.ConnectionFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。