Class SalesforceAccessToken

  • All Implemented Interfaces:
    ComponentLifecycle, AccessTokenBuilder

    public class SalesforceAccessToken
    extends java.lang.Object
    implements AccessTokenBuilder
    Wraps the salesforce username/password OAuth authentication flow for machine/machine data flow.

    Based on the java example available within the salesforce-rest-starter project and relies on the jackson json jars being available on the classpath (built against com.fasterxml.jackson.core:jackson-databind:2.6.2) which has been marked as optional in the dependency list to avoid additional jars if you want to just use Apache HTTP.

    It is perfectly possible to achieve the same thing with standard configuration; it would be a combination of AddMetadataService + CreateQueryStringFromMetadata + (StandardHttpProducer || ApacheHttpProducer) + JsonPathService + AddFormattedMetadataService. This encapsulates all of that into a single class.

    See Also:
    GetOauthToken, AccessTokenBuilder

    In the adapter configuration file this class is aliased as salesforce-access-token which is the preferred alternative to the fully qualified classname when building your configuration.

    • Field Detail

      • DEFAULT_TOKEN_URL

        public static final java.lang.String DEFAULT_TOKEN_URL
        The default URL for getting access tokens "https://login.salesforce.com/services/oauth2/token".
        See Also:
        Constant Field Values
    • Constructor Detail

      • SalesforceAccessToken

        public SalesforceAccessToken()
    • Method Detail

      • withUsernamePassword

        public SalesforceAccessToken withUsernamePassword​(java.lang.String user,
                                                          java.lang.String password)
      • withConsumerCredentials

        public SalesforceAccessToken withConsumerCredentials​(java.lang.String key,
                                                             java.lang.String secret)
      • getUsername

        public java.lang.String getUsername()
      • setUsername

        public void setUsername​(java.lang.String s)
        Set the username.
        Parameters:
        s - the username
      • getPassword

        public java.lang.String getPassword()
      • setPassword

        public void setPassword​(java.lang.String s)
        Set the password.

        Remember the password is really your password + security token

        Parameters:
        s - the password which may be encoded via Password.encode(String, String)
      • getConsumerKey

        public java.lang.String getConsumerKey()
      • setConsumerKey

        public void setConsumerKey​(java.lang.String s)
        Set your consumer key.
        Parameters:
        s - the consumer key
      • getConsumerSecret

        public java.lang.String getConsumerSecret()
      • setConsumerSecret

        public void setConsumerSecret​(java.lang.String s)
        Set your consumer secret.
        Parameters:
        s - the consumer secret which may be encoded via Password.encode(String, String)
      • getHttpProxy

        public java.lang.String getHttpProxy()
      • setHttpProxy

        public void setHttpProxy​(java.lang.String proxy)
        Explicitly configure a proxy server.
        Parameters:
        proxy - the httpProxy to generally scheme://host:port or more simply host:port
      • getTokenUrl

        public java.lang.String getTokenUrl()