Class RestrictedTokenContext


  • public class RestrictedTokenContext
    extends Object
    Utility to attach the context for token restriction checking to the current thread and marshalling/unmarshalling context value
    • Constructor Detail

      • RestrictedTokenContext

        public RestrictedTokenContext()
    • Method Detail

      • getCurrent

        public static Object getCurrent()
        Returns the current context of the running thread
        Returns:
        object containing the current context
      • doUsing

        public static <T> T doUsing​(Object context,
                                    RestrictedTokenAction<T> action)
                             throws Exception
        Performs an action while temporary replacing the current token restriction checking context associated with the running thread After returning from action run() method original context is restored
        Parameters:
        context - context to be used with the action
        action - action to be performed
        Returns:
        object
        Throws:
        Exception - if the there was an error.
      • marshal

        public static String marshal​(Object context)
                              throws Exception
        Serialize the current context to a string
        Parameters:
        context - to be serialized
        Returns:
        string containing the serialized object
        Throws:
        Exception - if the there was an error.
      • unmarshal

        public static Object unmarshal​(String data)
                                throws Exception
        Deserialize the context from the string created by previous call to marshal()
        Parameters:
        data - string containing serialized context
        Returns:
        deserialized context object
        Throws:
        Exception - if the there was an error.
      • clear

        public static void clear()
        Clears the current context from this Thread Local