Package de.kosmos_lab.web.client
Class MyTestClient
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.client.HttpClient
-
- de.kosmos_lab.web.client.AuthedHTTPClient
-
- de.kosmos_lab.web.client.MyTestClient
-
- All Implemented Interfaces:
org.eclipse.jetty.util.component.Container,org.eclipse.jetty.util.component.Destroyable,org.eclipse.jetty.util.component.Dumpable,org.eclipse.jetty.util.component.Dumpable.DumpableContainer,org.eclipse.jetty.util.component.LifeCycle
public class MyTestClient extends AuthedHTTPClient
test client, primarly used for testing
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener
-
-
Constructor Summary
Constructors Constructor Description MyTestClient(String baseurl, String user, String pass)create a new Client
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidauthorizeRequest(org.eclipse.jetty.client.api.Request request)implement this method to add your login information to the requestvoidclearToken()org.eclipse.jetty.client.api.ContentResponsegetResponse(String url, org.eclipse.jetty.http.HttpMethod method, Object body, int maxRetries, Integer expectedStatus)get the response for a given result, if 401 is returned the jwt will be renewed, and it will be tried againStringgetToken()booleanisConnected()Stringlogin()booleanrefreshToken()get a new JWT token (try to login)booleanrefreshTokenIfNeeded()-
Methods inherited from class de.kosmos_lab.web.client.AuthedHTTPClient
createRequest, getBase, getMaxRetries, getResponse, getResponse, getResponse, setMaxRetries
-
Methods inherited from class org.eclipse.jetty.client.HttpClient
copyRequest, createOrigin, doStart, doStop, dump, findProtocolHandler, FORM, FORM, GET, GET, getAcceptEncodingField, getAddressResolutionTimeout, getAuthenticationStore, getBindAddress, getByteBufferPool, getConnectTimeout, getContentDecoderFactories, getCookieStore, getDefaultRequestContentType, getDestinations, getExecutor, getHttpCompliance, getIdleTimeout, getMaxConnectionsPerDestination, getMaxRedirects, getMaxRequestsQueuedPerDestination, getName, getProtocolHandlers, getProxyConfiguration, getRequestBufferSize, getRequestListeners, getResponseBufferSize, getScheduler, getSocketAddressResolver, getSslContextFactory, getTransport, getUserAgentField, isConnectBlocking, isDefaultPort, isFollowRedirects, isRemoveIdleDestinations, isSchemeSecure, isStrictEventOrdering, isTCPNoDelay, isUseInputDirectByteBuffers, isUseOutputDirectByteBuffers, newConnection, newHttpRequest, newRequest, newRequest, newRequest, newSslClientConnectionFactory, normalizeHost, normalizePort, POST, POST, removeDestination, resolveDestination, resolveDestination, send, setAddressResolutionTimeout, setAuthenticationStore, setBindAddress, setByteBufferPool, setConnectBlocking, setConnectTimeout, setCookieStore, setDefaultRequestContentType, setExecutor, setFollowRedirects, setHttpCompliance, setIdleTimeout, setMaxConnectionsPerDestination, setMaxRedirects, setMaxRequestsQueuedPerDestination, setName, setRemoveIdleDestinations, setRequestBufferSize, setResponseBufferSize, setScheduler, setSocketAddressResolver, setStrictEventOrdering, setTCPNoDelay, setUseInputDirectByteBuffers, setUseOutputDirectByteBuffers, setUserAgentField
-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
authorizeRequest
public void authorizeRequest(@Nonnull org.eclipse.jetty.client.api.Request request) throws LoginFailedExceptionDescription copied from class:AuthedHTTPClientimplement this method to add your login information to the request- Specified by:
authorizeRequestin classAuthedHTTPClient- Throws:
LoginFailedException
-
getToken
public String getToken()
- Specified by:
getTokenin classAuthedHTTPClient
-
isConnected
public boolean isConnected()
-
login
@CheckForNull public String login()
-
refreshToken
public boolean refreshToken()
get a new JWT token (try to login)- Specified by:
refreshTokenin classAuthedHTTPClient- Returns:
- true if login was successful
-
refreshTokenIfNeeded
public boolean refreshTokenIfNeeded()
-
getResponse
public org.eclipse.jetty.client.api.ContentResponse getResponse(@Nonnull String url, @Nonnull org.eclipse.jetty.http.HttpMethod method, @CheckForNull Object body, int maxRetries, @CheckForNull Integer expectedStatus) throws RequestFailedExceptionDescription copied from class:AuthedHTTPClientget the response for a given result, if 401 is returned the jwt will be renewed, and it will be tried again- Overrides:
getResponsein classAuthedHTTPClientbody- the body we want to send (can be null)maxRetries- the amount of tests to try again- Returns:
- Throws:
RequestFailedException
-
clearToken
public void clearToken()
- Specified by:
clearTokenin classAuthedHTTPClient
-
-