Java 类org.springframework.boot.autoconfigure.social.SocialProperties 实例源码

项目:syndesis    文件:OAuth2CredentialProviderFactory.java   
@Override
public CredentialProvider create(final SocialProperties properties) {
    final OAuth2ConnectorProperties oauth2Properties = (OAuth2ConnectorProperties) properties;

    final String appId = oauth2Properties.getAppId();
    final String appSecret = oauth2Properties.getAppSecret();
    final String authorizationUrl = oauth2Properties.getAuthorizationUrl();
    final String authenticationUrl = oauth2Properties.getAuthenticationUrl();
    final String accessTokenUrl = oauth2Properties.getAccessTokenUrl();
    final boolean useParametersForClientCredentials = oauth2Properties.isUseParametersForClientCredentials();
    final TokenStrategy tokenStrategy = oauth2Properties.getTokenStrategy();
    final String scope = oauth2Properties.getScope();

    final OAuth2ServiceProvider<RestOperations> serviceProvider = new GenericOAuth2ServiceProvider(appId, appSecret, authorizationUrl,
        authenticationUrl, accessTokenUrl, useParametersForClientCredentials, tokenStrategy);

    final OAuth2ConnectionFactory<RestOperations> connectionFactory = new OAuth2ConnectionFactory<>("oauth2", serviceProvider, null);
    connectionFactory.setScope(scope);

    final OAuth2Applicator applicator = new OAuth2Applicator(properties);
    applicator.setAccessTokenProperty("accessToken");

    return new OAuth2CredentialProvider<>("oauth2", connectionFactory, applicator);
}
项目:syndesis    文件:OAuth1ApplicatorTest.java   
@Test
public void shouldApplyTokens() {
    final SocialProperties properties = new SocialProperties() {
    };
    properties.setAppId("appId");
    properties.setAppSecret("appSecret");

    final OAuth1Applicator applicator = new OAuth1Applicator(properties);
    applicator.setAccessTokenSecretProperty("accessTokenSecretProperty");
    applicator.setAccessTokenValueProperty("accessTokenValueProperty");
    applicator.setConsumerKeyProperty("consumerKeyProperty");
    applicator.setConsumerSecretProperty("consumerSecretProperty");

    final Connection connection = new Connection.Builder().build();

    final Connection result = applicator.applyTo(connection, new OAuthToken("tokenValue", "tokenSecret"));

    final Connection expected = new Connection.Builder()
        .putConfiguredProperty("accessTokenSecretProperty", "tokenSecret")
        .putConfiguredProperty("accessTokenValueProperty", "tokenValue")
        .putConfiguredProperty("consumerKeyProperty", "appId")
        .putConfiguredProperty("consumerSecretProperty", "appSecret").build();

    assertThat(result).isEqualToIgnoringGivenFields(expected, "lastUpdated");
    assertThat(result.getLastUpdated()).isPresent();
}
项目:syndesis    文件:OAuth2ApplicatorTest.java   
@Test
public void shouldApplyAccessGrants() {
    final SocialProperties properties = new SocialProperties() {
    };
    properties.setAppId("appId");
    properties.setAppSecret("appSecret");

    final OAuth2Applicator applicator = new OAuth2Applicator(properties);
    applicator.setAccessTokenProperty("accessTokenProperty");
    applicator.setClientIdProperty("clientIdProperty");
    applicator.setClientSecretProperty("clientSecretProperty");
    applicator.setRefreshTokenProperty("refreshTokenProperty");

    final Connection connection = new Connection.Builder().build();

    final Connection result = applicator.applyTo(connection,
        new AccessGrant("accessToken", "scope", "refreshToken", 1L));

    final Connection expected = new Connection.Builder().putConfiguredProperty("accessTokenProperty", "accessToken")
        .putConfiguredProperty("clientIdProperty", "appId")
        .putConfiguredProperty("clientSecretProperty", "appSecret")
        .putConfiguredProperty("refreshTokenProperty", "refreshToken").build();

    assertThat(result).isEqualToIgnoringGivenFields(expected, "lastUpdated");
    assertThat(result.getLastUpdated()).isPresent();
}
项目:syndesis-rest    文件:OAuth1ApplicatorTest.java   
@Test
public void shouldApplyTokens() {
    final SocialProperties properties = new SocialProperties() {
    };
    properties.setAppId("appId");
    properties.setAppSecret("appSecret");

    final OAuth1Applicator applicator = new OAuth1Applicator(properties);
    applicator.setAccessTokenSecretProperty("accessTokenSecretProperty");
    applicator.setAccessTokenValueProperty("accessTokenValueProperty");
    applicator.setConsumerKeyProperty("consumerKeyProperty");
    applicator.setConsumerSecretProperty("consumerSecretProperty");

    final Connection connection = new Connection.Builder().build();

    final Connection result = applicator.applyTo(connection, new OAuthToken("tokenValue", "tokenSecret"));

    final Connection expected = new Connection.Builder()
        .putConfiguredProperty("accessTokenSecretProperty", "tokenSecret")
        .putConfiguredProperty("accessTokenValueProperty", "tokenValue")
        .putConfiguredProperty("consumerKeyProperty", "appId")
        .putConfiguredProperty("consumerSecretProperty", "appSecret").build();

    assertThat(result).isEqualToIgnoringGivenFields(expected, "lastUpdated");
    assertThat(result.getLastUpdated()).isPresent();
}
项目:syndesis-rest    文件:OAuth2ApplicatorTest.java   
@Test
public void shouldApplyAccessGrants() {
    final SocialProperties properties = new SocialProperties() {
    };
    properties.setAppId("appId");
    properties.setAppSecret("appSecret");

    final OAuth2Applicator applicator = new OAuth2Applicator(properties);
    applicator.setAccessTokenProperty("accessTokenProperty");
    applicator.setClientIdProperty("clientIdProperty");
    applicator.setClientSecretProperty("clientSecretProperty");
    applicator.setRefreshTokenProperty("refreshTokenProperty");

    final Connection connection = new Connection.Builder().build();

    final Connection result = applicator.applyTo(connection,
        new AccessGrant("accessToken", "scope", "refreshToken", 1L));

    final Connection expected = new Connection.Builder().putConfiguredProperty("accessTokenProperty", "accessToken")
        .putConfiguredProperty("clientIdProperty", "appId")
        .putConfiguredProperty("clientSecretProperty", "appSecret")
        .putConfiguredProperty("refreshTokenProperty", "refreshToken").build();

    assertThat(result).isEqualToIgnoringGivenFields(expected, "lastUpdated");
    assertThat(result.getLastUpdated()).isPresent();
}
项目:syndesis    文件:TestCredentialProviderFactory.java   
@Override
public CredentialProvider create(final SocialProperties properties) {
    @SuppressWarnings("unchecked")
    final OAuth2ConnectionFactory<Object> connectionFactory = mock(OAuth2ConnectionFactory.class);
    when(connectionFactory.generateState()).thenReturn("test-state");

    properties.setAppId("appId");
    properties.setAppSecret("appSecret");

    final OAuth2Applicator applicator = new OAuth2Applicator(properties);
    applicator.setAccessTokenProperty("accessToken");
    applicator.setClientIdProperty("clientId");
    applicator.setClientSecretProperty("clientSecret");
    applicator.setRefreshTokenProperty("refreshToken");

    final CredentialProvider credentialProvider = new OAuth2CredentialProvider<>("test-provider", connectionFactory,
        applicator);

    @SuppressWarnings({ "unchecked", "rawtypes" })
    final Class<MultiValueMap<String, String>> additionalParametersType = (Class) MultiValueMap.class;
    final OAuth2Operations operations = spy(new OAuth2Template("testClientId", "testClientSecret",
        "https://test/oauth2/authorize", "https://test/oauth2/token"));
    doReturn(new AccessGrant("token")).when(operations).exchangeForAccess(Matchers.anyString(),
        Matchers.anyString(), Matchers.any(additionalParametersType));

    when(connectionFactory.getOAuthOperations()).thenReturn(operations);

    return credentialProvider;
}
项目:syndesis    文件:TwitterCredentialProviderFactory.java   
static CredentialProvider createCredentialProvider(final SocialProperties properties) {
    final TwitterConnectionFactory twitter = new TwitterConnectionFactory(properties.getAppId(),
        properties.getAppSecret());
    final OAuth1Applicator applicator = new OAuth1Applicator(properties);
    applicator.setConsumerKeyProperty("consumerKey");
    applicator.setConsumerSecretProperty("consumerSecret");
    applicator.setAccessTokenSecretProperty("accessTokenSecret");
    applicator.setAccessTokenValueProperty("accessToken");

    return new OAuth1CredentialProvider<>("twitter", twitter, applicator);
}
项目:syndesis    文件:SalesforceCredentialProviderFactory.java   
static SalesforceConnectionFactory
    createConnectionFactory(final SocialProperties salesforceProperties) {
    final SalesforceConnectionFactory salesforce = new SalesforceConnectionFactory(salesforceProperties.getAppId(),
        salesforceProperties.getAppSecret());

    final OAuth2Template oAuthOperations = (OAuth2Template) salesforce.getOAuthOperations();

    // Salesforce requires OAuth client id and secret on the OAuth request
    oAuthOperations.setUseParametersForClientAuthentication(true);

    return salesforce;
}
项目:syndesis    文件:SalesforceConfiguration.java   
public SalesforceApplicator(final SalesforceConnectionFactory salesforce,
    final SocialProperties socialProperties) {
    super(socialProperties);
    this.salesforce = salesforce;

    setClientIdProperty("clientId");
    setClientSecretProperty("clientSecret");
    setRefreshTokenProperty("refreshToken");
}
项目:syndesis-rest    文件:TestCredentialProviderFactory.java   
@Override
public CredentialProvider create(final SocialProperties properties) {
    @SuppressWarnings("unchecked")
    final OAuth2ConnectionFactory<Object> connectionFactory = mock(OAuth2ConnectionFactory.class);
    when(connectionFactory.generateState()).thenReturn("test-state");

    properties.setAppId("appId");
    properties.setAppSecret("appSecret");

    final OAuth2Applicator applicator = new OAuth2Applicator(properties);
    applicator.setAccessTokenProperty("accessToken");
    applicator.setClientIdProperty("clientId");
    applicator.setClientSecretProperty("clientSecret");
    applicator.setRefreshTokenProperty("refreshToken");

    final CredentialProvider credentialProvider = new OAuth2CredentialProvider<>("test-provider", connectionFactory,
        applicator);

    final OAuth2Operations operations = spy(new OAuth2Template("testClientId", "testClientSecret",
        "https://test/oauth2/authorize", "https://test/oauth2/token"));
    doReturn(new AccessGrant("token")).when(operations).exchangeForAccess(Matchers.anyString(),
        Matchers.anyString(), Matchers.any(MultiValueMap.class));

    when(connectionFactory.getOAuthOperations()).thenReturn(operations);

    return credentialProvider;
}
项目:syndesis-rest    文件:TwitterCredentialProviderFactory.java   
static CredentialProvider createCredentialProvider(final SocialProperties properties) {
    final TwitterConnectionFactory twitter = new TwitterConnectionFactory(properties.getAppId(),
        properties.getAppSecret());
    final OAuth1Applicator applicator = new OAuth1Applicator(properties);
    applicator.setConsumerKeyProperty("consumerKey");
    applicator.setConsumerSecretProperty("consumerSecret");
    applicator.setAccessTokenSecretProperty("accessTokenSecret");
    applicator.setAccessTokenValueProperty("accessToken");

    return new OAuth1CredentialProvider<>("twitter", twitter, applicator);
}
项目:syndesis-rest    文件:SalesforceCredentialProviderFactory.java   
static SalesforceConnectionFactory
    createConnectionFactory(final SocialProperties salesforceProperties) {
    final SalesforceConnectionFactory salesforce = new SalesforceConnectionFactory(salesforceProperties.getAppId(),
        salesforceProperties.getAppSecret());

    final OAuth2Template oAuthOperations = (OAuth2Template) salesforce.getOAuthOperations();

    // Salesforce requires OAuth client id and secret on the OAuth request
    oAuthOperations.setUseParametersForClientAuthentication(true);

    return salesforce;
}
项目:syndesis-rest    文件:SalesforceConfiguration.java   
public SalesforceApplicator(final SalesforceConnectionFactory salesforce,
    final SocialProperties socialProperties) {
    super(socialProperties);
    this.salesforce = salesforce;

    setClientIdProperty("clientId");
    setClientSecretProperty("clientSecret");
    setRefreshTokenProperty("refreshToken");
}
项目:syndesis    文件:TwitterCredentialProviderFactory.java   
@Override
public CredentialProvider create(final SocialProperties properties) {
    return createCredentialProvider(properties);
}
项目:syndesis    文件:OAuth2Applicator.java   
public OAuth2Applicator(final SocialProperties socialProperties) {
    this.socialProperties = socialProperties;
}
项目:syndesis    文件:OAuth1Applicator.java   
public OAuth1Applicator(final SocialProperties properties) {
    consumerKey = properties.getAppId();
    consumerSecret = properties.getAppSecret();
}
项目:syndesis    文件:SalesforceCredentialProviderFactory.java   
@Override
public CredentialProvider create(final SocialProperties properties) {
    return createCredentialProvider(properties);
}
项目:syndesis    文件:SalesforceCredentialProviderFactory.java   
static CredentialProvider createCredentialProvider(final SocialProperties properties) {
    final SalesforceConnectionFactory connectionFactory = createConnectionFactory(properties);

    return new OAuth2CredentialProvider<>("salesforce", connectionFactory,
        new SalesforceApplicator(connectionFactory, properties));
}
项目:syndesis    文件:TestCredentialProviderFactory.java   
public TestCredentialProvider(final SocialProperties properties) {
    this.properties = properties;
}
项目:syndesis    文件:TestCredentialProviderFactory.java   
public SocialProperties getProperties() {
    return properties;
}
项目:syndesis    文件:TestCredentialProviderFactory.java   
@Override
public CredentialProvider create(final SocialProperties properties) {
    return new TestCredentialProvider(properties);
}
项目:syndesis-rest    文件:TwitterCredentialProviderFactory.java   
@Override
public CredentialProvider create(final SocialProperties properties) {
    return createCredentialProvider(properties);
}
项目:syndesis-rest    文件:OAuth2Applicator.java   
public OAuth2Applicator(final SocialProperties socialProperties) {
    this.socialProperties = socialProperties;
}
项目:syndesis-rest    文件:OAuth1Applicator.java   
public OAuth1Applicator(final SocialProperties properties) {
    consumerKey = properties.getAppId();
    consumerSecret = properties.getAppSecret();
}
项目:syndesis-rest    文件:SalesforceCredentialProviderFactory.java   
@Override
public CredentialProvider create(final SocialProperties properties) {
    return createCredentialProvider(properties);
}
项目:syndesis-rest    文件:SalesforceCredentialProviderFactory.java   
static CredentialProvider createCredentialProvider(final SocialProperties properties) {
    final SalesforceConnectionFactory connectionFactory = createConnectionFactory(properties);

    return new OAuth2CredentialProvider<>("salesforce", connectionFactory,
        new SalesforceApplicator(connectionFactory, properties));
}
项目:syndesis-rest    文件:TestCredentialProviderFactory.java   
public TestCredentialProvider(final SocialProperties properties) {
    this.properties = properties;
}
项目:syndesis-rest    文件:TestCredentialProviderFactory.java   
public SocialProperties getProperties() {
    return properties;
}
项目:syndesis-rest    文件:TestCredentialProviderFactory.java   
@Override
public CredentialProvider create(final SocialProperties properties) {
    return new TestCredentialProvider(properties);
}
项目:syndesis    文件:CredentialProviderFactory.java   
CredentialProvider create(final SocialProperties properties);
项目:syndesis-rest    文件:CredentialProviderFactory.java   
CredentialProvider create(final SocialProperties properties);