Package io.token

Class TokenClient

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class TokenClient
    extends java.lang.Object
    implements java.io.Closeable
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      io.reactivex.Observable<java.lang.String> beginRecovery​(io.token.proto.common.alias.AliasProtos.Alias alias)
      Begins account recovery.
      java.lang.String beginRecoveryBlocking​(io.token.proto.common.alias.AliasProtos.Alias alias)
      Begins account recovery.
      static TokenClient.Builder builder()
      Creates a new TokenClient.Builder instance that is used to configure and build a TokenClient instance.
      void close()  
      io.reactivex.Observable<Member> completeRecoveryImpl​(java.lang.String memberId, java.util.List<io.token.proto.common.member.MemberProtos.MemberRecoveryOperation> recoveryOperations, io.token.proto.common.security.SecurityProtos.Key privilegedKey, CryptoEngine cryptoEngine)
      Completes account recovery.
      io.reactivex.Observable<Member> completeRecoveryWithDefaultRuleImpl​(java.lang.String memberId, java.lang.String verificationId, java.lang.String code, CryptoEngine cryptoEngine)
      Completes account recovery if the default recovery rule was set.
      static TokenClient create​(TokenClient.TokenCluster cluster, java.lang.String developerKey)
      Creates a new instance of TokenClient that's configured to use the specified environment.
      protected io.reactivex.Observable<Member> createMemberImpl​(io.token.proto.common.alias.AliasProtos.Alias alias, io.token.proto.common.member.MemberProtos.CreateMemberType memberType, java.lang.String partnerId, java.lang.String recoveryAgent, java.lang.String realmId)
      Creates a new Token member with a set of auto-generated keys, an alias, and member type.
      io.reactivex.Observable<io.token.proto.common.member.MemberProtos.MemberRecoveryOperation.Authorization> createRecoveryAuthorization​(java.lang.String memberId, io.token.proto.common.security.SecurityProtos.Key privilegedKey)
      Create a recovery authorization for some agent to sign.
      io.token.proto.common.member.MemberProtos.MemberRecoveryOperation.Authorization createRecoveryAuthorizationBlocking​(java.lang.String memberId, io.token.proto.common.security.SecurityProtos.Key privilegedKey)
      Create a recovery authorization for some agent to sign.
      io.reactivex.Observable<java.util.List<io.token.proto.common.bank.BankProtos.Bank>> getBanks​(java.lang.String search, java.lang.String country, java.lang.Integer page, java.lang.Integer perPage, java.lang.String sort, java.lang.String provider)
      Returns a list of token enabled banks.
      io.reactivex.Observable<java.util.List<io.token.proto.common.bank.BankProtos.Bank>> getBanks​(java.util.List<java.lang.String> bankIds, java.lang.Integer page, java.lang.Integer perPage)
      Returns a list of token enabled banks.
      io.reactivex.Observable<java.util.List<io.token.proto.common.bank.BankProtos.Bank>> getBanks​(java.util.List<java.lang.String> bankIds, java.lang.String search, java.lang.String country, java.lang.Integer page, java.lang.Integer perPage, java.lang.String sort, java.lang.String provider)
      Returns a list of token enabled banks.
      io.reactivex.Observable<java.util.List<io.token.proto.common.bank.BankProtos.Bank>> getBanks​(java.util.List<java.lang.String> bankIds, java.lang.String search, java.lang.String country, java.lang.Integer page, java.lang.Integer perPage, java.lang.String sort, java.lang.String provider, io.token.proto.common.bank.BankProtos.BankFilter.BankFeatures bankFeatures)
      Returns a list of token enabled banks.
      java.util.List<io.token.proto.common.bank.BankProtos.Bank> getBanksBlocking​(java.lang.String search, java.lang.String country, java.lang.Integer page, java.lang.Integer perPage, java.lang.String sort, java.lang.String provider)
      Returns a list of token enabled banks.
      java.util.List<io.token.proto.common.bank.BankProtos.Bank> getBanksBlocking​(java.util.List<java.lang.String> bankIds, java.lang.Integer page, java.lang.Integer perPage)
      Returns a list of token enabled banks.
      java.util.List<io.token.proto.common.bank.BankProtos.Bank> getBanksBlocking​(java.util.List<java.lang.String> bankIds, java.lang.String search, java.lang.String country, java.lang.Integer page, java.lang.Integer perPage, java.lang.String sort, java.lang.String provider)
      Returns a list of token enabled banks.
      io.reactivex.Observable<java.util.List<java.lang.String>> getCountries​(java.lang.String provider)
      Returns a list of countries with Token-enabled banks.
      java.util.List<java.lang.String> getCountriesBlocking​(java.lang.String provider)
      Returns a list of countries with Token-enabled banks.
      io.reactivex.Observable<java.lang.String> getMemberId​(io.token.proto.common.alias.AliasProtos.Alias alias)
      Looks up member id for a given alias.
      java.lang.String getMemberIdBlocking​(io.token.proto.common.alias.AliasProtos.Alias alias)
      Looks up member id for a given alias.
      protected io.reactivex.Observable<Member> getMemberImpl​(java.lang.String memberId, Client client)
      Return a Member set up to use some Token member's keys (assuming we have them).
      io.reactivex.Observable<io.token.proto.common.member.MemberProtos.MemberRecoveryOperation> getRecoveryAuthorization​(java.lang.String verificationId, java.lang.String code, io.token.proto.common.security.SecurityProtos.Key key)
      Gets recovery authorization from Token.
      io.token.proto.common.member.MemberProtos.MemberRecoveryOperation getRecoveryAuthorizationBlocking​(java.lang.String verificationId, java.lang.String code, io.token.proto.common.security.SecurityProtos.Key key)
      Gets recovery authorization from Token.
      io.reactivex.Observable<io.token.proto.common.token.TokenProtos.TokenMember> resolveAlias​(io.token.proto.common.alias.AliasProtos.Alias alias)
      Resolve an alias to a TokenMember object, containing member ID and the alias with the correct type.
      io.token.proto.common.token.TokenProtos.TokenMember resolveAliasBlocking​(io.token.proto.common.alias.AliasProtos.Alias alias)
      Resolve an alias to a TokenMember object, containing member ID and the alias with the correct type.
      protected io.reactivex.Observable<Member> setUpMemberImpl​(io.token.proto.common.alias.AliasProtos.Alias alias, java.lang.String memberId, java.lang.String agent)
      Sets up a member given a specific ID of a member that already exists in the system.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TokenClient

        protected TokenClient​(io.grpc.ManagedChannel channel,
                              CryptoEngineFactory cryptoFactory,
                              TokenClient.TokenCluster tokenCluster)
        Creates an instance of a Token SDK.
        Parameters:
        channel - GRPC channel
        cryptoFactory - crypto factory instance
        tokenCluster - token cluster
    • Method Detail

      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • create

        public static TokenClient create​(TokenClient.TokenCluster cluster,
                                         java.lang.String developerKey)
        Creates a new instance of TokenClient that's configured to use the specified environment.
        Parameters:
        cluster - token cluster to connect to
        developerKey - developer key
        Returns:
        TokenClient instance
      • resolveAlias

        public io.reactivex.Observable<io.token.proto.common.token.TokenProtos.TokenMember> resolveAlias​(io.token.proto.common.alias.AliasProtos.Alias alias)
        Resolve an alias to a TokenMember object, containing member ID and the alias with the correct type.
        Parameters:
        alias - alias to resolve
        Returns:
        TokenMember
      • resolveAliasBlocking

        public io.token.proto.common.token.TokenProtos.TokenMember resolveAliasBlocking​(io.token.proto.common.alias.AliasProtos.Alias alias)
        Resolve an alias to a TokenMember object, containing member ID and the alias with the correct type.
        Parameters:
        alias - alias to resolve
        Returns:
        TokenMember
      • getMemberId

        public io.reactivex.Observable<java.lang.String> getMemberId​(io.token.proto.common.alias.AliasProtos.Alias alias)
        Looks up member id for a given alias.
        Parameters:
        alias - alias to check
        Returns:
        member id, or throws exception if member not found
      • getMemberIdBlocking

        public java.lang.String getMemberIdBlocking​(io.token.proto.common.alias.AliasProtos.Alias alias)
        Looks up member id for a given alias.
        Parameters:
        alias - alias to check
        Returns:
        member id, or throws exception if member not found
      • createMemberImpl

        protected io.reactivex.Observable<Member> createMemberImpl​(io.token.proto.common.alias.AliasProtos.Alias alias,
                                                                   io.token.proto.common.member.MemberProtos.CreateMemberType memberType,
                                                                   @Nullable
                                                                   java.lang.String partnerId,
                                                                   @Nullable
                                                                   java.lang.String recoveryAgent,
                                                                   @Nullable
                                                                   java.lang.String realmId)
        Creates a new Token member with a set of auto-generated keys, an alias, and member type.

        Impl method returns incomplete member object that can be used for its instance fields but will not be able to make calls.

        Parameters:
        alias - nullable member alias to use, must be unique. If null, then no alias will be created with the member.
        memberType - the type of member to register
        partnerId - ID of the partner member
        recoveryAgent - member id of the primary recovery agent
        realmId - member id of an existing Member to whom the new member belongs.
        Returns:
        newly created member
      • setUpMemberImpl

        protected io.reactivex.Observable<Member> setUpMemberImpl​(io.token.proto.common.alias.AliasProtos.Alias alias,
                                                                  java.lang.String memberId,
                                                                  java.lang.String agent)
        Sets up a member given a specific ID of a member that already exists in the system. If the member ID already has keys, this will not succeed. Used for testing since this gives more control over the member creation process.

        Impl method returns incomplete member object that can be used for its instance fields but will not be able to make calls.

        Adds an alias and a set of auto-generated keys to the member.

        Parameters:
        alias - nullable member alias to use, must be unique. If null, then no alias will be created with the member
        memberId - member id
        agent - member id of the primary recovery agent.
        Returns:
        newly created member
      • getMemberImpl

        protected io.reactivex.Observable<Member> getMemberImpl​(java.lang.String memberId,
                                                                Client client)
        Return a Member set up to use some Token member's keys (assuming we have them).

        Impl method returns incomplete member object that can be used for its instance fields but will not be able to make calls.

        Parameters:
        memberId - member id
        client - client
        Returns:
        member
      • completeRecoveryImpl

        public io.reactivex.Observable<Member> completeRecoveryImpl​(java.lang.String memberId,
                                                                    java.util.List<io.token.proto.common.member.MemberProtos.MemberRecoveryOperation> recoveryOperations,
                                                                    io.token.proto.common.security.SecurityProtos.Key privilegedKey,
                                                                    CryptoEngine cryptoEngine)
        Completes account recovery.

        Impl method returns incomplete member object that can be used for its instance fields but will not be able to make calls.

        Parameters:
        memberId - the member id
        recoveryOperations - the member recovery operations
        privilegedKey - the privileged public key in the member recovery operations
        cryptoEngine - the new crypto engine
        Returns:
        an observable of the updated member
      • completeRecoveryWithDefaultRuleImpl

        public io.reactivex.Observable<Member> completeRecoveryWithDefaultRuleImpl​(java.lang.String memberId,
                                                                                   java.lang.String verificationId,
                                                                                   java.lang.String code,
                                                                                   CryptoEngine cryptoEngine)
        Completes account recovery if the default recovery rule was set.

        Impl method returns incomplete member object that can be used for its instance fields but will not be able to make calls.

        Parameters:
        memberId - the member id
        verificationId - the verification id
        code - the code
        cryptoEngine - crypto engine
        Returns:
        the new member
      • beginRecovery

        public io.reactivex.Observable<java.lang.String> beginRecovery​(io.token.proto.common.alias.AliasProtos.Alias alias)
        Begins account recovery.
        Parameters:
        alias - the alias used to recover
        Returns:
        the verification id
      • beginRecoveryBlocking

        public java.lang.String beginRecoveryBlocking​(io.token.proto.common.alias.AliasProtos.Alias alias)
        Begins account recovery.
        Parameters:
        alias - the alias used to recover
        Returns:
        the verification id
      • createRecoveryAuthorization

        public io.reactivex.Observable<io.token.proto.common.member.MemberProtos.MemberRecoveryOperation.Authorization> createRecoveryAuthorization​(java.lang.String memberId,
                                                                                                                                                    io.token.proto.common.security.SecurityProtos.Key privilegedKey)
        Create a recovery authorization for some agent to sign.
        Parameters:
        memberId - Id of member we claim to be.
        privilegedKey - new privileged key we want to use.
        Returns:
        authorization structure for agent to sign
      • createRecoveryAuthorizationBlocking

        public io.token.proto.common.member.MemberProtos.MemberRecoveryOperation.Authorization createRecoveryAuthorizationBlocking​(java.lang.String memberId,
                                                                                                                                   io.token.proto.common.security.SecurityProtos.Key privilegedKey)
        Create a recovery authorization for some agent to sign.
        Parameters:
        memberId - Id of member we claim to be.
        privilegedKey - new privileged key we want to use.
        Returns:
        authorization structure for agent to sign
      • getRecoveryAuthorization

        public io.reactivex.Observable<io.token.proto.common.member.MemberProtos.MemberRecoveryOperation> getRecoveryAuthorization​(java.lang.String verificationId,
                                                                                                                                   java.lang.String code,
                                                                                                                                   io.token.proto.common.security.SecurityProtos.Key key)
                                                                                                                            throws VerificationException
        Gets recovery authorization from Token.
        Parameters:
        verificationId - the verification id
        code - the code
        key - the privileged key
        Returns:
        the member recovery operation
        Throws:
        VerificationException - if the code verification fails
      • getRecoveryAuthorizationBlocking

        public io.token.proto.common.member.MemberProtos.MemberRecoveryOperation getRecoveryAuthorizationBlocking​(java.lang.String verificationId,
                                                                                                                  java.lang.String code,
                                                                                                                  io.token.proto.common.security.SecurityProtos.Key key)
                                                                                                           throws VerificationException
        Gets recovery authorization from Token.
        Parameters:
        verificationId - the verification id
        code - the code
        key - the privileged key
        Returns:
        the member recovery operation
        Throws:
        VerificationException - if the code verification fails
      • getBanks

        public io.reactivex.Observable<java.util.List<io.token.proto.common.bank.BankProtos.Bank>> getBanks​(@Nullable
                                                                                                            java.util.List<java.lang.String> bankIds,
                                                                                                            @Nullable
                                                                                                            java.lang.Integer page,
                                                                                                            @Nullable
                                                                                                            java.lang.Integer perPage)
        Returns a list of token enabled banks.
        Parameters:
        bankIds - If specified, return banks whose 'id' matches any one of the given ids (case-insensitive). Can be at most 1000.
        page - Result page to retrieve. Default to 1 if not specified.
        perPage - Maximum number of records per page. Can be at most 200. Default to 200 if not specified.
        Returns:
        a list of banks
      • getBanks

        public io.reactivex.Observable<java.util.List<io.token.proto.common.bank.BankProtos.Bank>> getBanks​(@Nullable
                                                                                                            java.lang.String search,
                                                                                                            @Nullable
                                                                                                            java.lang.String country,
                                                                                                            @Nullable
                                                                                                            java.lang.Integer page,
                                                                                                            @Nullable
                                                                                                            java.lang.Integer perPage,
                                                                                                            @Nullable
                                                                                                            java.lang.String sort,
                                                                                                            @Nullable
                                                                                                            java.lang.String provider)
        Returns a list of token enabled banks.
        Parameters:
        search - If specified, return banks whose 'name' or 'identifier' contains the given search string (case-insensitive)
        country - If specified, return banks whose 'country' matches the given ISO 3166-1 alpha-2 country code (case-insensitive)
        page - Result page to retrieve. Default to 1 if not specified.
        perPage - Maximum number of records per page. Can be at most 200. Default to 200 if not specified.
        sort - The key to sort the results. Could be one of: name, provider and country. Defaults to name if not specified.
        provider - If specified, return banks whose 'provider' matches the given provider (case insensitive).
        Returns:
        a list of banks
      • getBanks

        public io.reactivex.Observable<java.util.List<io.token.proto.common.bank.BankProtos.Bank>> getBanks​(@Nullable
                                                                                                            java.util.List<java.lang.String> bankIds,
                                                                                                            @Nullable
                                                                                                            java.lang.String search,
                                                                                                            @Nullable
                                                                                                            java.lang.String country,
                                                                                                            @Nullable
                                                                                                            java.lang.Integer page,
                                                                                                            @Nullable
                                                                                                            java.lang.Integer perPage,
                                                                                                            @Nullable
                                                                                                            java.lang.String sort,
                                                                                                            @Nullable
                                                                                                            java.lang.String provider)
        Returns a list of token enabled banks.
        Parameters:
        bankIds - If specified, return banks whose 'id' matches any one of the given ids (case-insensitive). Can be at most 1000.
        search - If specified, return banks whose 'name' or 'identifier' contains the given search string (case-insensitive)
        country - If specified, return banks whose 'country' matches the given ISO 3166-1 alpha-2 country code (case-insensitive)
        page - Result page to retrieve. Default to 1 if not specified.
        perPage - Maximum number of records per page. Can be at most 200. Default to 200 if not specified.
        sort - The key to sort the results. Could be one of: name, provider and country. Defaults to name if not specified.
        provider - If specified, return banks whose 'provider' matches the given provider (case insensitive).
        Returns:
        a list of banks
      • getBanks

        public io.reactivex.Observable<java.util.List<io.token.proto.common.bank.BankProtos.Bank>> getBanks​(@Nullable
                                                                                                            java.util.List<java.lang.String> bankIds,
                                                                                                            @Nullable
                                                                                                            java.lang.String search,
                                                                                                            @Nullable
                                                                                                            java.lang.String country,
                                                                                                            @Nullable
                                                                                                            java.lang.Integer page,
                                                                                                            @Nullable
                                                                                                            java.lang.Integer perPage,
                                                                                                            @Nullable
                                                                                                            java.lang.String sort,
                                                                                                            @Nullable
                                                                                                            java.lang.String provider,
                                                                                                            @Nullable
                                                                                                            io.token.proto.common.bank.BankProtos.BankFilter.BankFeatures bankFeatures)
        Returns a list of token enabled banks.
        Parameters:
        bankIds - If specified, return banks whose 'id' matches any one of the given ids (case-insensitive). Can be at most 1000.
        search - If specified, return banks whose 'name' or 'identifier' contains the given search string (case-insensitive)
        country - If specified, return banks whose 'country' matches the given ISO 3166-1 alpha-2 country code (case-insensitive)
        page - Result page to retrieve. Default to 1 if not specified.
        perPage - Maximum number of records per page. Can be at most 200. Default to 200 if not specified.
        sort - The key to sort the results. Could be one of: name, provider and country. Defaults to name if not specified.
        provider - If specified, return banks whose 'provider' matches the given provider (case insensitive).
        bankFeatures - If specified, return banks who meet the bank features requirement.
        Returns:
        a list of banks
      • getBanksBlocking

        public java.util.List<io.token.proto.common.bank.BankProtos.Bank> getBanksBlocking​(@Nullable
                                                                                           java.util.List<java.lang.String> bankIds,
                                                                                           @Nullable
                                                                                           java.lang.Integer page,
                                                                                           @Nullable
                                                                                           java.lang.Integer perPage)
        Returns a list of token enabled banks.
        Parameters:
        bankIds - If specified, return banks whose 'id' matches any one of the given ids (case-insensitive). Can be at most 1000.
        page - Result page to retrieve. Default to 1 if not specified.
        perPage - Maximum number of records per page. Can be at most 200. Default to 200 if not specified.
        Returns:
        a list of banks
      • getBanksBlocking

        public java.util.List<io.token.proto.common.bank.BankProtos.Bank> getBanksBlocking​(@Nullable
                                                                                           java.lang.String search,
                                                                                           @Nullable
                                                                                           java.lang.String country,
                                                                                           @Nullable
                                                                                           java.lang.Integer page,
                                                                                           @Nullable
                                                                                           java.lang.Integer perPage,
                                                                                           @Nullable
                                                                                           java.lang.String sort,
                                                                                           @Nullable
                                                                                           java.lang.String provider)
        Returns a list of token enabled banks.
        Parameters:
        search - If specified, return banks whose 'name' or 'identifier' contains the given search string (case-insensitive)
        country - If specified, return banks whose 'country' matches the given ISO 3166-1 alpha-2 country code (case-insensitive)
        page - Result page to retrieve. Default to 1 if not specified.
        perPage - Maximum number of records per page. Can be at most 200. Default to 200 if not specified.
        sort - The key to sort the results. Could be one of: name, provider and country. Defaults to name if not specified.
        provider - If specified, return banks whose 'provider' matches the given provider (case insensitive).
        Returns:
        a list of banks
      • getBanksBlocking

        public java.util.List<io.token.proto.common.bank.BankProtos.Bank> getBanksBlocking​(@Nullable
                                                                                           java.util.List<java.lang.String> bankIds,
                                                                                           @Nullable
                                                                                           java.lang.String search,
                                                                                           @Nullable
                                                                                           java.lang.String country,
                                                                                           @Nullable
                                                                                           java.lang.Integer page,
                                                                                           @Nullable
                                                                                           java.lang.Integer perPage,
                                                                                           @Nullable
                                                                                           java.lang.String sort,
                                                                                           @Nullable
                                                                                           java.lang.String provider)
        Returns a list of token enabled banks.
        Parameters:
        bankIds - If specified, return banks whose 'id' matches any one of the given ids (case-insensitive). Can be at most 1000.
        search - If specified, return banks whose 'name' or 'identifier' contains the given search string (case-insensitive)
        country - If specified, return banks whose 'country' matches the given ISO 3166-1 alpha-2 country code (case-insensitive)
        page - Result page to retrieve. Default to 1 if not specified.
        perPage - Maximum number of records per page. Can be at most 200. Default to 200 if not specified.
        sort - The key to sort the results. Could be one of: name, provider and country. Defaults to name if not specified.
        provider - If specified, return banks whose 'provider' matches the given provider (case insensitive).
        Returns:
        a list of banks
      • getCountries

        public io.reactivex.Observable<java.util.List<java.lang.String>> getCountries​(java.lang.String provider)
        Returns a list of countries with Token-enabled banks.
        Parameters:
        provider - If specified, return banks whose 'provider' matches the given provider (case insensitive).
        Returns:
        a list of country codes
      • getCountriesBlocking

        public java.util.List<java.lang.String> getCountriesBlocking​(java.lang.String provider)
        Returns a list of countries with Token-enabled banks.
        Parameters:
        provider - If specified, return banks whose 'provider' matches the given provider (case insensitive).
        Returns:
        a list of country codes