Enum Class RedirectStatusCode

Object
Enum<RedirectStatusCode>
se.curity.identityserver.sdk.http.RedirectStatusCode
All Implemented Interfaces:
Serializable, Comparable<RedirectStatusCode>, Constable

public enum RedirectStatusCode extends Enum<RedirectStatusCode>
HTTP status codes that represent some sort of redirect.

Use SEE_OTHER whenever redirecting after collecting a credential (i.e., some proof of who the user is, like a password or token). Do not use MOVED_TEMPORARILY or MOVED_PERMANENTLY because the user agent may automatically make a request to the URI in the Location header using the same HTTP method and contents. In such a case, the URI to be redirected to may be another server that should not gain access to the credential. Only SEE_OTHER guarantees that the method will be changed to GET.

The following table from RFC 7238 gives a good overview of the different kinds of redirects:

Overview of Kinds of Redirect Status Codes
  Permanent Temporary
Allows changing the request method from POST to GET MOVED_PERMANENTLY MOVED_TEMPORARILY
Does not allow changing the request method from POST to GET PERMANENT_REDIRECT TEMPORARY_REDIRECT
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Status code (301) indicating that the resource has permanently moved to a new location, and that future references should use a new URI with their requests.
    Status code (302) indicating that the resource has temporarily moved to another location, but that future references should still use the original URI to access the resource.
    Status code (308) indicating that the requested resource permanently resides at a different URI and the user agent may not change the request method from POST to GET (if applicable).
    Status code (303) indicating that the response to the request can be found under a different URI.
    Status code (307) indicating that the requested resource resides temporarily under a different URI.
    Deprecated.
    As of RFC 7231, this status code has been deprecated.
  • Method Summary

    Modifier and Type
    Method
    Description
    fromInt(int redirectStatusCode)
    Creates a redirect status code.
    fromInt(int redirectStatusCode, int defaultValue)
    Creates a redirect status code using the default value if the input is not acceptable.
    int
    Gets the integer value of the redirect status code.
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • MOVED_PERMANENTLY

      public static final RedirectStatusCode MOVED_PERMANENTLY
      Status code (301) indicating that the resource has permanently moved to a new location, and that future references should use a new URI with their requests.
    • MOVED_TEMPORARILY

      public static final RedirectStatusCode MOVED_TEMPORARILY
      Status code (302) indicating that the resource has temporarily moved to another location, but that future references should still use the original URI to access the resource.

      This definition is being retained for backwards compatibility. SC_FOUND is now the preferred definition.

    • SEE_OTHER

      public static final RedirectStatusCode SEE_OTHER
      Status code (303) indicating that the response to the request can be found under a different URI.
    • TEMPORARY_REDIRECT

      public static final RedirectStatusCode TEMPORARY_REDIRECT
      Status code (307) indicating that the requested resource resides temporarily under a different URI. The temporary URI SHOULD be given by the Location field in the response. When following such a redirect, the user agent may not change the request method from POST to GET (if applicable).
    • USE_PROXY

      @Deprecated public static final RedirectStatusCode USE_PROXY
      Deprecated.
      As of RFC 7231, this status code has been deprecated.
      Status code (305) indicating that the requested resource MUST be accessed through the proxy given by the Location field.
    • PERMANENT_REDIRECT

      public static final RedirectStatusCode PERMANENT_REDIRECT
      Status code (308) indicating that the requested resource permanently resides at a different URI and the user agent may not change the request method from POST to GET (if applicable).
      See Also:
  • Method Details

    • values

      public static RedirectStatusCode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static RedirectStatusCode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • value

      public int value()
      Gets the integer value of the redirect status code.
      Returns:
      the redirect status code
    • fromInt

      public static RedirectStatusCode fromInt(int redirectStatusCode)
      Creates a redirect status code.

      Valid values are 301, 302, 303, 305, 307, or 308.

      Parameters:
      redirectStatusCode - the redirect status code to convert
      Returns:
      the redirect status code
      Throws:
      IllegalArgumentException - if redirectStatusCode is not one of the valid redirect status codes
    • fromInt

      public static RedirectStatusCode fromInt(int redirectStatusCode, int defaultValue)
      Creates a redirect status code using the default value if the input is not acceptable.

      Valid values are 301, 302, 305, 307, or 308. If redirectStatusCode is any other value, then defaultValue will be used. If defaultValue is not one of these values, then an error will be thrown.

      Parameters:
      redirectStatusCode - the redirect status code to convert
      defaultValue - the default value to use if redirectStatusCode is invalid
      Returns:
      the redirect status code
      Throws:
      IllegalArgumentException - if redirectStatusCode and defaultValue are not one of the valid redirect status codes
      Since:
      3.0.0