use of org.springframework.boot.autoconfigure.social.SocialProperties in project syndesis by syndesisio.
the class CredentialProviderRegistry method providerWithId.
@Override
public CredentialProvider providerWithId(final String providerId) {
final Connector connector = dataManager.fetch(Connector.class, providerId);
if (connector == null) {
throw new IllegalArgumentException("Unable to find connector with id: " + providerId);
}
final SocialProperties socialProperties;
final String providerToUse;
final Optional<String> authentication = connector.propertyTaggedWith(Credentials.AUTHENTICATION_TYPE_TAG);
if (authentication.isPresent()) {
providerToUse = authentication.get();
if ("oauth2".equalsIgnoreCase(authentication.get())) {
socialProperties = new OAuth2ConnectorProperties(connector);
} else {
socialProperties = new ConnectorSettings(connector);
}
} else {
socialProperties = new ConnectorSettings(connector);
providerToUse = providerId;
}
final CredentialProvider providerWithId = credentialProviderFactories.get(providerToUse).create(socialProperties);
if (providerWithId == null) {
throw new IllegalArgumentException("Unable to locate credential provider with id: " + providerId);
}
return providerWithId;
}
use of org.springframework.boot.autoconfigure.social.SocialProperties in project syndesis by syndesisio.
the class OAuth1ApplicatorTest method shouldApplyTokens.
@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();
}
use of org.springframework.boot.autoconfigure.social.SocialProperties in project syndesis by syndesisio.
the class OAuth2ApplicatorTest method shouldApplyAccessGrants.
@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();
}
Aggregations