org.apache.http.impl.auth

## Class SPNegoScheme

- java.lang.Object
- - org.apache.http.impl.auth.AuthSchemeBase
  - - org.apache.http.impl.auth.GGSSchemeBase
    - - org.apache.http.impl.auth.SPNegoScheme

- All Implemented Interfaces:
    AuthScheme, ContextAwareAuthScheme

      public class SPNegoScheme
      extends GGSSchemeBase

  SPNEGO (Simple and Protected GSSAPI Negotiation Mechanism) authentication scheme.
  Since:
    4.2

- - ### Field Summary

    - ### Fields inherited from class org.apache.http.impl.auth.AuthSchemeBase

      `challengeState`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SPNegoScheme()`
    `SPNegoScheme(boolean stripPort)`
    `SPNegoScheme(boolean stripPort, boolean useCanonicalHostname)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.apache.http.Header` | `authenticate(Credentials credentials, org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context)` Produces SPNEGO authorization Header based on token created by processChallenge.
    `protected byte[]` | `generateToken(byte[] input, String authServer)`
    `protected byte[]` | `generateToken(byte[] input, String authServer, Credentials credentials)`
    `String` | `getParameter(String name)` There are no valid parameters for SPNEGO authentication so this method always returns `null`.
    `String` | `getRealm()` The concept of an authentication realm is not supported by the Negotiate authentication scheme.
    `String` | `getSchemeName()` Returns textual designation of the given authentication scheme.
    `boolean` | `isConnectionBased()` Returns `true`.

    - ### Methods inherited from class org.apache.http.impl.auth.GGSSchemeBase

      `authenticate, generateGSSToken, generateGSSToken, getManager, isComplete, parseChallenge`

    - ### Methods inherited from class org.apache.http.impl.auth.AuthSchemeBase

      `getChallengeState, isProxy, processChallenge, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SPNegoScheme

          public SPNegoScheme(boolean stripPort,
                      boolean useCanonicalHostname)

      Since:
        4.4

    - #### SPNegoScheme

          public SPNegoScheme(boolean stripPort)

    - #### SPNegoScheme

          public SPNegoScheme()

  - ### Method Detail

    - #### getSchemeName

          public String getSchemeName()

      Description copied from interface: `AuthScheme`
      Returns textual designation of the given authentication scheme.
      Returns:
        the name of the given authentication scheme

    - #### authenticate

          public org.apache.http.Header authenticate(Credentials credentials,
                                            org.apache.http.HttpRequest request,
                                            org.apache.http.protocol.HttpContext context)
                                              throws AuthenticationException

      Produces SPNEGO authorization Header based on token created by processChallenge.
      Specified by:
        `authenticate` in interface `ContextAwareAuthScheme`
      Overrides:
        `authenticate` in class `GGSSchemeBase`
      Parameters:
        `credentials` - not used by the SPNEGO scheme.
        `request` - The request being authenticated
        `context` - HTTP context
      Returns:
        SPNEGO authentication Header
      Throws:
        `AuthenticationException` - if authentication string cannot be generated due to an authentication failure

    - #### generateToken

          protected byte[] generateToken(byte[] input,
                             String authServer)
                                  throws GSSException

      Overrides:
        `generateToken` in class `GGSSchemeBase`
      Throws:
        `GSSException`

    - #### generateToken

          protected byte[] generateToken(byte[] input,
                             String authServer,
                             Credentials credentials)
                                  throws GSSException

      Overrides:
        `generateToken` in class `GGSSchemeBase`
      Throws:
        `GSSException`

    - #### getParameter

          public String getParameter(String name)

      There are no valid parameters for SPNEGO authentication so this method always returns `null`.
      Parameters:
        `name` - The name of the parameter to be returned
      Returns:
        `null`

    - #### getRealm

          public String getRealm()

      The concept of an authentication realm is not supported by the Negotiate authentication scheme. Always returns `null`.
      Returns:
        `null`

    - #### isConnectionBased

          public boolean isConnectionBased()

      Returns `true`. SPNEGO authentication scheme is connection based.
      Returns:
        `true`.

Copyright © 1999–2022 The Apache Software Foundation. All rights reserved.