Class SecureCxfClientFactoryImpl<T>

java.lang.Object
org.codice.ddf.cxf.client.impl.SecureCxfClientFactoryImpl<T>
All Implemented Interfaces:
org.codice.ddf.cxf.client.SecureCxfClientFactory<T>

public class SecureCxfClientFactoryImpl<T> extends Object implements org.codice.ddf.cxf.client.SecureCxfClientFactory<T>
This factory helps construct clients for secure restful communication. For now, the getForSubject methods should only be used to support DDFinvalid input: '<'->DDF interop, because:
  1. Most non-DDF systems do not know how to handle SAML assertions in the auth header.
  • Field Details

  • Constructor Details

    • SecureCxfClientFactoryImpl

      public SecureCxfClientFactoryImpl(String endpointUrl, Class<T> interfaceClass, List<?> providers, org.apache.cxf.interceptor.Interceptor<? extends org.apache.cxf.message.Message> interceptor, boolean disableCnCheck, boolean allowRedirects, boolean useOauth, boolean useSamlEcp, boolean useSubjectRetrievalInterceptor, org.codice.ddf.configuration.PropertyResolver propertyResolver, Integer connectionTimeout, Integer receiveTimeout, String sourceId, URI discoveryUrl, String clientId, String clientSecret, String oauthFlow, String username, String password, ClientKeyInfo keyInfo, String sslProtocol, Map<String,String> additionalOauthParameters, OAuthSecurity oauthSecurity, org.codice.ddf.security.jaxrs.SamlSecurity samlSecurity, ddf.security.audit.SecurityLogger securityLogger, ddf.security.service.SecurityManager securityManager)
      Constructs a factory that will return security-aware cxf clients. Once constructed, use the getClient* methods to retrieve a fresh client with the same configuration. Providing WebClient to interfaceClass will create a generic web client.

      This factory can and should be cached. The clients it constructs should not be.

      Parameters:
      endpointUrl - the remote url to connect to
      interfaceClass - an interface representing the resource at the remote url
      providers - optional list of providers to further configure the client
      interceptor - optional message interceptor for the client
      disableCnCheck - disable ssl check for common name / host name match
      allowRedirects - allow this client to follow redirects
      useOauth - whether to use oauth or not
  • Method Details

    • initialize

      public void initialize()
    • getClient

      public T getClient()
      Specified by:
      getClient in interface org.codice.ddf.cxf.client.SecureCxfClientFactory<T>
    • getWebClient

      public org.apache.cxf.jaxrs.client.WebClient getWebClient()
      Specified by:
      getWebClient in interface org.codice.ddf.cxf.client.SecureCxfClientFactory<T>
    • getWebSystemClient

      public org.apache.cxf.jaxrs.client.WebClient getWebSystemClient()
      Specified by:
      getWebSystemClient in interface org.codice.ddf.cxf.client.SecureCxfClientFactory<T>
    • getClientForSubject

      public final T getClientForSubject(org.apache.shiro.subject.Subject subject)
      Clients produced by this method will be secured with two-way ssl and the provided security subject.

      The returned client should NOT be reused between requests! This method should be called for each new request in order to ensure that the security token is up-to-date each time.

      Specified by:
      getClientForSubject in interface org.codice.ddf.cxf.client.SecureCxfClientFactory<T>
    • getClientForSystemSubject

      public final T getClientForSystemSubject(org.apache.shiro.subject.Subject subject)
      Clients produced by this method will be secured with two-way ssl and the provided security subject.

      The returned client should NOT be reused between requests! This method should be called for each new request in order to ensure that the security token is up-to-date each time.

      Specified by:
      getClientForSystemSubject in interface org.codice.ddf.cxf.client.SecureCxfClientFactory<T>
    • getSameUriRedirectMax

      public Integer getSameUriRedirectMax()
      Specified by:
      getSameUriRedirectMax in interface org.codice.ddf.cxf.client.SecureCxfClientFactory<T>
    • setSameUriRedirectMax

      public void setSameUriRedirectMax(Integer sameUriRedirectMax)
    • getWebClientForSubject

      public org.apache.cxf.jaxrs.client.WebClient getWebClientForSubject(org.apache.shiro.subject.Subject subject)
      Convenience method to get a WebClient instead of a ClientProxyImpl.
      Specified by:
      getWebClientForSubject in interface org.codice.ddf.cxf.client.SecureCxfClientFactory<T>
      See Also:
    • configureTimeouts

      protected void configureTimeouts(org.apache.cxf.jaxrs.client.ClientConfiguration clientConfiguration, Integer connectionTimeout, Integer receiveTimeout)
      Configures the connection and receive timeouts. If any of the parameters are null, the timeouts will be set to the system default.
      Parameters:
      clientConfiguration - Client configuration used for outgoing requests.
      connectionTimeout - Connection timeout in milliseconds.
      receiveTimeout - Receive timeout in milliseconds.
    • addOutInterceptors

      public void addOutInterceptors(org.apache.cxf.interceptor.Interceptor<? extends org.apache.cxf.message.Message> inteceptor)
      Specified by:
      addOutInterceptors in interface org.codice.ddf.cxf.client.SecureCxfClientFactory<T>