com.stormpath.sdk.impl.provider.DefaultTwitterAccountRequestBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stormpath-sdk-impl Show documentation
Show all versions of stormpath-sdk-impl Show documentation
The Stormpath Java SDK core implemenation .jar is used at runtime to support API invocations. This
implementation jar should be a runtime dependency only and should NOT be depended on at compile time by
your code. The implementations within this jar can change at any time without warning - use it with runtime
scope only.
package com.stormpath.sdk.impl.provider;
import com.stormpath.sdk.lang.Assert;
import com.stormpath.sdk.provider.ProviderAccountRequest;
import com.stormpath.sdk.provider.ProviderData;
import com.stormpath.sdk.provider.TwitterAccountRequestBuilder;
import java.util.HashMap;
import java.util.Map;
import static com.stormpath.sdk.lang.Strings.hasText;
/**
* @since 1.3.0
*/
public class DefaultTwitterAccountRequestBuilder extends AbstractSocialProviderAccountRequestBuilder implements TwitterAccountRequestBuilder {
protected String accessTokenSecret;
@Override
protected ProviderAccountRequest doBuild(Map map) {
Assert.state(hasText(super.accessToken) && hasText(this.accessTokenSecret), "Both accessToken and accessTokenSecret must be provided before building.");
Map properties = new HashMap<>(map);
properties.put("accessToken", accessToken);
properties.put("accessTokenSecret", accessTokenSecret);
ProviderData providerData = newProviderData(properties);
return new DefaultProviderAccountRequest(providerData, redirectUri);
}
@Override
protected String getConcreteProviderId() {
return IdentityProviderType.TWITTER.getNameKey();
}
@Override
protected ProviderData newProviderData(Map properties) {
return new DefaultTwitterProviderData(null, properties);
}
@Override
public TwitterAccountRequestBuilder setAccessTokenSecret(String accessTokenSecret) {
this.accessTokenSecret = accessTokenSecret;
return this;
}
}