Class HttpHeaderTokenWriter

  • All Implemented Interfaces:
    TokenWriter

    @Singleton
    @Requires(property="micronaut.security.token.writer.header.enabled",notEquals="false") @Requires(beans=io.micronaut.security.token.writer.HttpHeaderTokenWriterConfiguration.class)
    public class HttpHeaderTokenWriter
    extends java.lang.Object
    implements TokenWriter
    Write the token in an HTTP header.
    Since:
    1.0
    Author:
    Sergio del Amo
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected io.micronaut.security.token.writer.HttpHeaderTokenWriterConfiguration httpHeaderTokenWriterConfiguration  
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpHeaderTokenWriter​(io.micronaut.security.token.writer.HttpHeaderTokenWriterConfiguration httpHeaderTokenWriterConfiguration)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String getHeaderName()  
      protected java.lang.String headerValue​(java.lang.String token)  
      void writeToken​(io.micronaut.http.MutableHttpRequest<?> request, java.lang.String token)
      Writes the token to the request.
      • Methods inherited from class java.lang.Object

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

      • httpHeaderTokenWriterConfiguration

        protected final io.micronaut.security.token.writer.HttpHeaderTokenWriterConfiguration httpHeaderTokenWriterConfiguration
    • Constructor Detail

      • HttpHeaderTokenWriter

        public HttpHeaderTokenWriter​(io.micronaut.security.token.writer.HttpHeaderTokenWriterConfiguration httpHeaderTokenWriterConfiguration)
        Parameters:
        httpHeaderTokenWriterConfiguration - The HttpHeaderTokenWriter configuration
    • Method Detail

      • getHeaderName

        protected java.lang.String getHeaderName()
        Returns:
        the HTTP Header name where the token will be written to
      • writeToken

        public void writeToken​(io.micronaut.http.MutableHttpRequest<?> request,
                               java.lang.String token)
        Writes the token to the request.
        Specified by:
        writeToken in interface TokenWriter
        Parameters:
        request - The MutableHttpRequest instance
        token - A token ( e.g. JWT token, basic auth token...)
      • headerValue

        protected java.lang.String headerValue​(java.lang.String token)
        Parameters:
        token - the token being written
        Returns:
        the value which will be written to an HTTP Header