All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.stormpath.sdk.impl.provider.DefaultTwitterAccountRequestBuilder Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 2.0.4-okta
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy