Interface CTSPersistentStore

  • All Known Implementing Classes:
    CTSPersistentStoreImpl, CTSPersistentStoreProxy

    public interface CTSPersistentStore
    Core Token Service Persistent Store is responsible for the storage and retrieval of Tokens from a persistent store. The Core Token Service is exposed through a series of CRUDL operations which require the use of TokenAdapters to convert from objects to be stored into the expected Core Token Service format. This allows the Tokens to be stored in a generic storage. The current main use cases for the CTS are: - Session fail-over - OAuth token storage - SAML Federation token storage - Forgotten Password The implementation of this interface must be thread safe as this service will often be on a direct call path from the front end of the Server hosting OpenAM, and so multiple calls to the service can occur at the same time from different calling threads.
    See Also:
    TokenAdapter, Token
    • Method Detail

      • create

        void create​(Token token)
             throws CoreTokenException
        Creates a Token in the persistent store synchronously.
        Parameters:
        token - Non null Token to create.
        Throws:
        CoreTokenException - If there was an error while performing the different TokenBlobStrategys on the provided Token, or if the operation itself has failed.
      • create

        void create​(Token token,
                    org.forgerock.util.Options options)
             throws CoreTokenException
        Creates a Token in the persistent store synchronously.
        Parameters:
        token - Non null Token to create.
        options - Non null Options for the operation.
        Throws:
        CoreTokenException - If there was an error while performing the different TokenBlobStrategys on the provided Token, or if the operation itself has failed.
      • createAsync

        void createAsync​(Token token)
                  throws CoreTokenException
        Creates a Token in the persistent store asynchronously. The result of the operation (success/failure) is ignored.
        Parameters:
        token - Non null Token to create.
        Throws:
        CoreTokenException - If there was an error while performing the different TokenBlobStrategys on the provided Token.
      • createAsync

        void createAsync​(Token token,
                         org.forgerock.util.Options options)
                  throws CoreTokenException
        Creates a Token in the persistent store asynchronously. The result of the operation (success/failure) is ignored.
        Parameters:
        token - Non null Token to create.
        options - Non null Options for the operation.
        Throws:
        CoreTokenException - If there was an error while performing the different TokenBlobStrategys on the provided Token.
      • read

        Token read​(String tokenId)
            throws CoreTokenException
        Read a Token from the persistent store synchronously.
        Parameters:
        tokenId - The non null Token Id that the Token was created with.
        Returns:
        Null if there was no matching Token. Otherwise a fully populated Token will be returned.
        Throws:
        CoreTokenException - If there was an error while performing the different TokenBlobStrategys on the returned Token, or if the operation itself has failed.
      • read

        Token read​(String tokenId,
                   org.forgerock.util.Options options)
            throws CoreTokenException
        Read a Token from the persistent store synchronously.
        Parameters:
        tokenId - The non null Token Id that the Token was created with.
        options - The non null Options for the operation.
        Returns:
        Null if there was no matching Token. Otherwise a fully populated Token will be returned.
        Throws:
        CoreTokenException - If there was an error while performing the different TokenBlobStrategys on the returned Token, or if the operation itself has failed.
      • update

        void update​(Token token,
                    org.forgerock.util.Options options)
             throws CoreTokenException
        Updates an existing Token in the store synchronously. If the Token does not exist in the store then a Token is created. If the Token did exist in the store then it is updated. Not all fields of the Token can be updated, see the Token class for more details.
        Parameters:
        token - Non null Token to update.
        options - Non null Options for the operation.
        Throws:
        CoreTokenException - If there was an error while performing the different TokenBlobStrategys on the provided Token, or if the operation itself has failed.
        See Also:
        Token.isFieldReadOnly(org.forgerock.openam.tokens.CoreTokenField)
      • updateAsync

        void updateAsync​(Token token,
                         org.forgerock.util.Options options)
                  throws CoreTokenException
        Updates an existing Token in the store asynchronously. If the Token does not exist in the store then a Token is created. If the Token did exist in the store then it is updated. Not all fields of the Token can be updated, see the Token class for more details.
        Parameters:
        token - Non null Token to update.
        options - Non null Options for the operation.
        Throws:
        CoreTokenException - If there was an error while performing the different TokenBlobStrategys on the provided Token.
        See Also:
        Token.isFieldReadOnly(org.forgerock.openam.tokens.CoreTokenField)
      • delete

        void delete​(Token token)
             throws CoreTokenException
        Delete the Token from the store synchronously.
        Parameters:
        token - Non null Token to be deleted from the store.
        Throws:
        CoreTokenException - If the delete operation has failed.
      • deleteAsync

        void deleteAsync​(Token token)
                  throws CoreTokenException
        Deletes the Token from the store asynchronously.
        Parameters:
        token - Non null Token to be deleted from the store.
        Throws:
        CoreTokenException
      • delete

        void delete​(String tokenId)
             throws CoreTokenException
        Delete the Token from the store synchronously based on its id. Note: It is often more efficient to delete the token based on the Id if you already have this information, rather than reading the Token first before removing it.
        Parameters:
        tokenId - The non null Token Id of the token to remove.
        Throws:
        CoreTokenException - If the delete operation has failed.
      • delete

        void delete​(String tokenId,
                    org.forgerock.util.Options options)
             throws CoreTokenException
        Delete the Token from the store synchronously based on its id. Note: It is often more efficient to delete the token based on the Id if you already have this information, rather than reading the Token first before removing it.
        Parameters:
        tokenId - The non null Token Id of the token to remove.
        options - The non null Options for the operation.
        Throws:
        CoreTokenException - If the delete operation has failed.
      • deleteAsync

        void deleteAsync​(String tokenId)
                  throws CoreTokenException
        Delete the Token from the store asynchronously based on its id. Note: It is often more efficient to delete the token based on the Id if you already have this information, rather than reading the Token first before removing it.
        Parameters:
        tokenId - The non null Token Id of the token to remove.
        Throws:
        CoreTokenException
      • deleteAsync

        void deleteAsync​(String tokenId,
                         org.forgerock.util.Options options)
                  throws CoreTokenException
        Delete the Token from the store asynchronously based on its id. Note: It is often more efficient to delete the token based on the Id if you already have this information, rather than reading the Token first before removing it.
        Parameters:
        tokenId - The non null Token Id of the token to remove.
        options - The non null Options for the operation.
        Throws:
        CoreTokenException
      • delete

        int delete​(Map<CoreTokenField,​Object> query)
            throws CoreTokenException
        Delete a collection of Tokens from the Token Store asynchronously using a filter to narrow down the Tokens to be deleted.
        Parameters:
        query - Non null filters which will be combined logically using AND.
        Returns:
        total number of tokens deleted by query.
        Throws:
        CoreTokenException - If there was an error while looking up the deletable Tokens.
      • addContinuousQueryListener

        void addContinuousQueryListener​(ContinuousQueryListener listener,
                                        TokenFilter filter)
                                 throws CoreTokenException
        Performs a continuous query against the persistent store using the provided TokenFilter. The filter is assembled by the TokenFilterBuilder which provides the options on how to turn the query being performed. The filter is appropriate to the underlying persistent layer type. The continuous query will begin and the listener will be attached.
        Parameters:
        listener - A listener which is capable of handling the results from this continuous query.
        filter - Non null filter.
        Throws:
        CoreTokenException - If there was any error whilst performing the query.
        See Also:
        TokenFilter, TokenFilterBuilder
      • query

        Collection<Token> query​(TokenFilter filter)
                         throws CoreTokenException
        Performs a synchronous query against the persistent store using the provided TokenFilter. The filter is assembled by the TokenFilterBuilder which provides the options on how to turn the query being performed.
        Parameters:
        filter - Non null filter.
        Returns:
        Non null, but maybe empty.
        Throws:
        CoreTokenException - If there was any error whilst performing the query.
        See Also:
        TokenFilter, TokenFilterBuilder
      • deleteOnQueryAsync

        void deleteOnQueryAsync​(TokenFilter tokenFilter)
                         throws CoreTokenException
        Performs an asynchronous query against the persistent store using the provided TokenFilter and then deletes the matching tokens from the store.
        Parameters:
        tokenFilter - Non null filter.
        Throws:
        CoreTokenException - If there was a problem queuing the task to be performed.
        See Also:
        TokenFilterBuilder