org.keycloak.servlet

## Class ServletOAuthClient

- java.lang.Object
- - org.keycloak.AbstractOAuthClient
  - - org.keycloak.servlet.ServletOAuthClient

-     public class ServletOAuthClient
      extends AbstractOAuthClient

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.apache.http.client.HttpClient` | `client`

    - ### Fields inherited from class org.keycloak.AbstractOAuthClient

      `authUrl, clientId, codeUrl, credentials, isSecure, publicClient, refreshUrl, relativeUrlsUsed, scope, stateCookieName, stateCookiePath`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServletOAuthClient()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static IDToken` | `extractIdToken(String idToken)`
    `AccessTokenResponse` | `getBearerToken(javax.servlet.http.HttpServletRequest request)` Obtain the code parameter from the url after being redirected back from the auth-server.
    `org.apache.http.client.HttpClient` | `getClient()`
    `protected String` | `getCode(javax.servlet.http.HttpServletRequest request)`
    `protected String` | `getCookieValue(String name, javax.servlet.http.HttpServletRequest request)`
    `void` | `redirect(String redirectUri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Start the process of obtaining an access token by redirecting the browser to the authentication server
    `void` | `redirectRelative(String relativePath, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Start the process of obtaining an access token by redirecting the browser to the authentication server
    `AccessTokenResponse` | `refreshToken(javax.servlet.http.HttpServletRequest request, String refreshToken)`
    `void` | `setClient(org.apache.http.client.HttpClient client)`
    `void` | `start()`
    `void` | `stop()` closes client

    - ### Methods inherited from class org.keycloak.AbstractOAuthClient

      `getAuthUrl, getClientId, getCodeUrl, getCredentials, getRefreshUrl, getRelativeUrlsUsed, getScope, getStateCode, getStateCookieName, getStateCookiePath, isPublicClient, setAuthUrl, setClientId, setCodeUrl, setCredentials, setPublicClient, setRefreshUrl, setRelativeUrlsUsed, setScope, setStateCookieName, setStateCookiePath, stripOauthParametersFromRedirect`

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

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

- - ### Field Detail

    - #### client

          protected org.apache.http.client.HttpClient client

  - ### Constructor Detail

    - #### ServletOAuthClient

          public ServletOAuthClient()

  - ### Method Detail

    - #### start

          public void start()

    - #### stop

          public void stop()

      closes client

    - #### getClient

          public org.apache.http.client.HttpClient getClient()

    - #### setClient

          public void setClient(org.apache.http.client.HttpClient client)

    - #### redirectRelative

          public void redirectRelative(String relativePath,
                              javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                                throws IOException

      Start the process of obtaining an access token by redirecting the browser to the authentication server
      Parameters:
        `relativePath` - path relative to context root you want auth server to redirect back to
        `request` -
        `response` -
      Throws:
        `IOException`

    - #### redirect

          public void redirect(String redirectUri,
                      javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
                        throws IOException

      Start the process of obtaining an access token by redirecting the browser to the authentication server
      Parameters:
        `redirectUri` - full URI you want auth server to redirect back to
        `request` -
        `response` -
      Throws:
        `IOException`

    - #### getCookieValue

          protected String getCookieValue(String name,
                              javax.servlet.http.HttpServletRequest request)

    - #### getCode

          protected String getCode(javax.servlet.http.HttpServletRequest request)

    - #### getBearerToken

          public AccessTokenResponse getBearerToken(javax.servlet.http.HttpServletRequest request)
                                             throws IOException,
                                                    ServerRequest.HttpFailure

      Obtain the code parameter from the url after being redirected back from the auth-server. Then do an authenticated request back to the auth-server to turn the access code into an access token.
      Parameters:
        `request` -
      Returns:
      Throws:
        `IOException`
        `ServerRequest.HttpFailure`

    - #### refreshToken

          public AccessTokenResponse refreshToken(javax.servlet.http.HttpServletRequest request,
                                         String refreshToken)
                                           throws IOException,
                                                  ServerRequest.HttpFailure

      Throws:
        `IOException`
        `ServerRequest.HttpFailure`

    - #### extractIdToken

          public static IDToken extractIdToken(String idToken)

Copyright © 2015. All Rights Reserved.