Package org.codice.ddf.cxf.client.impl
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 DDF<->DDF interop, because:
- Most non-DDF systems do not know how to handle SAML assertions in the auth header.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classX509 certificate selector for retrieving certificate for a specific alias. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSecureCxfClientFactoryImpl(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOutInterceptors(org.apache.cxf.interceptor.Interceptor<? extends org.apache.cxf.message.Message> inteceptor) protected voidconfigureTimeouts(org.apache.cxf.jaxrs.client.ClientConfiguration clientConfiguration, Integer connectionTimeout, Integer receiveTimeout) Configures the connection and receive timeouts.final TgetClientForSubject(org.apache.shiro.subject.Subject subject) Clients produced by this method will be secured with two-way ssl and the provided security subject.final TgetClientForSystemSubject(org.apache.shiro.subject.Subject subject) Clients produced by this method will be secured with two-way ssl and the provided security subject.org.apache.cxf.jaxrs.client.WebClientorg.apache.cxf.jaxrs.client.WebClientgetWebClientForSubject(org.apache.shiro.subject.Subject subject) Convenience method to get aWebClientinstead of aClientProxyImpl.org.apache.cxf.jaxrs.client.WebClientvoidvoidsetSameUriRedirectMax(Integer sameUriRedirectMax)
-
Field Details
-
HTTPS
- See Also:
-
CREDENTIAL_FLOW
- See Also:
-
PASSWORD_FLOW
- See Also:
-
-
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. ProvidingWebClientto 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 tointerfaceClass- an interface representing the resource at the remote urlproviders- optional list of providers to further configure the clientinterceptor- optional message interceptor for the clientdisableCnCheck- disable ssl check for common name / host name matchallowRedirects- allow this client to follow redirectsuseOauth- whether to use oauth or not
-
-
Method Details
-
initialize
public void initialize() -
getClient
- Specified by:
getClientin interfaceorg.codice.ddf.cxf.client.SecureCxfClientFactory<T>
-
getWebClient
public org.apache.cxf.jaxrs.client.WebClient getWebClient()- Specified by:
getWebClientin interfaceorg.codice.ddf.cxf.client.SecureCxfClientFactory<T>
-
getWebSystemClient
public org.apache.cxf.jaxrs.client.WebClient getWebSystemClient()- Specified by:
getWebSystemClientin interfaceorg.codice.ddf.cxf.client.SecureCxfClientFactory<T>
-
getClientForSubject
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:
getClientForSubjectin interfaceorg.codice.ddf.cxf.client.SecureCxfClientFactory<T>
-
getClientForSystemSubject
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:
getClientForSystemSubjectin interfaceorg.codice.ddf.cxf.client.SecureCxfClientFactory<T>
-
getSameUriRedirectMax
- Specified by:
getSameUriRedirectMaxin interfaceorg.codice.ddf.cxf.client.SecureCxfClientFactory<T>
-
setSameUriRedirectMax
-
getWebClientForSubject
public org.apache.cxf.jaxrs.client.WebClient getWebClientForSubject(org.apache.shiro.subject.Subject subject) Convenience method to get aWebClientinstead of aClientProxyImpl.- Specified by:
getWebClientForSubjectin interfaceorg.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:
addOutInterceptorsin interfaceorg.codice.ddf.cxf.client.SecureCxfClientFactory<T>
-