/** * Returns the domain configured for this instance, or {@link SyncopeConstants#MASTER_DOMAIN} if not set. * * @return the domain configured for this instance */ public String getDomain() { List<String> headerValues = restClientFactory.getHeaders().get(RESTHeaders.DOMAIN); return headerValues == null || headerValues.isEmpty() ? SyncopeConstants.MASTER_DOMAIN : headerValues.get(0); }
/** * Returns the domain configured for this instance, or {@link SyncopeConstants#MASTER_DOMAIN} if not set. * * @return the domain configured for this instance */ public String getDomain() { List<String> headerValues = restClientFactory.getHeaders().get(RESTHeaders.DOMAIN); return headerValues == null || headerValues.isEmpty() ? SyncopeConstants.MASTER_DOMAIN : headerValues.get(0); }
/** * Returns the JWT in used by this instance, passed with the {@link HttpHeaders#AUTHORIZATION} header * in all requests. It can be null (in case {@link NoAuthenticationHandler} or * {@link AnonymousAuthenticationHandler} were used). * * @return the JWT in used by this instance */ public String getJWT() { List<String> headerValues = restClientFactory.getHeaders().get(HttpHeaders.AUTHORIZATION); String header = headerValues == null || headerValues.isEmpty() ? null : headerValues.get(0); if (header != null && header.startsWith("Bearer ")) { return header.substring("Bearer ".length()); } return null; }
/** * Returns the JWT in used by this instance, passed with the {@link HttpHeaders#AUTHORIZATION} header * in all requests. It can be null (in case {@link NoAuthenticationHandler} or * {@link AnonymousAuthenticationHandler} were used). * * @return the JWT in used by this instance */ public String getJWT() { List<String> headerValues = restClientFactory.getHeaders().get(HttpHeaders.AUTHORIZATION); String header = headerValues == null || headerValues.isEmpty() ? null : headerValues.get(0); if (header != null && header.startsWith("Bearer ")) { return header.substring("Bearer ".length()); } return null; }
protected void cleanup() { restClientFactory.getHeaders().remove(HttpHeaders.AUTHORIZATION); restClientFactory.setUsername(null); restClientFactory.setPassword(null); }
protected void cleanup() { restClientFactory.getHeaders().remove(HttpHeaders.AUTHORIZATION); restClientFactory.setUsername(null); restClientFactory.setPassword(null); }
public SyncopeClient( final MediaType mediaType, final JAXRSClientFactoryBean restClientFactory, final RestClientExceptionMapper exceptionMapper, final AuthenticationHandler handler, final boolean useCompression, final TLSClientParameters tlsClientParameters) { this.mediaType = mediaType; this.restClientFactory = restClientFactory; if (this.restClientFactory.getHeaders() == null) { this.restClientFactory.setHeaders(new HashMap<>()); } this.exceptionMapper = exceptionMapper; this.tlsClientParameters = tlsClientParameters; init(handler); this.useCompression = useCompression; }
/** * Attempts to extend the lifespan of the JWT currently in use. */ public void refresh() { String jwt = getService(AccessTokenService.class).refresh().getHeaderString(RESTHeaders.TOKEN); restClientFactory.getHeaders().put(HttpHeaders.AUTHORIZATION, Collections.singletonList("Bearer " + jwt)); }
public SyncopeClient( final MediaType mediaType, final JAXRSClientFactoryBean restClientFactory, final RestClientExceptionMapper exceptionMapper, final AuthenticationHandler handler, final boolean useCompression, final TLSClientParameters tlsClientParameters) { this.mediaType = mediaType; this.restClientFactory = restClientFactory; if (this.restClientFactory.getHeaders() == null) { this.restClientFactory.setHeaders(new HashMap<>()); } this.exceptionMapper = exceptionMapper; this.tlsClientParameters = tlsClientParameters; init(handler); this.useCompression = useCompression; }
/** * Attempts to extend the lifespan of the JWT currently in use. */ public void refresh() { String jwt = getService(AccessTokenService.class).refresh().getHeaderString(RESTHeaders.TOKEN); restClientFactory.getHeaders().put(HttpHeaders.AUTHORIZATION, Collections.singletonList("Bearer " + jwt)); }
protected JAXRSClientFactoryBean defaultRestClientFactoryBean() { JAXRSClientFactoryBean defaultRestClientFactoryBean = new JAXRSClientFactoryBean(); defaultRestClientFactoryBean.setHeaders(new HashMap<>()); if (StringUtils.isBlank(address)) { throw new IllegalArgumentException("Property 'address' is missing"); } defaultRestClientFactoryBean.setAddress(address); if (StringUtils.isNotBlank(domain)) { defaultRestClientFactoryBean.getHeaders().put(RESTHeaders.DOMAIN, Collections.singletonList(domain)); } defaultRestClientFactoryBean.setThreadSafe(true); defaultRestClientFactoryBean.setInheritHeaders(true); List<Feature> features = new ArrayList<>(); features.add(new LoggingFeature()); defaultRestClientFactoryBean.setFeatures(features); List<Object> providers = new ArrayList<>(4); providers.add(new DateParamConverterProvider()); providers.add(getJaxbProvider()); providers.add(getJsonProvider()); providers.add(getExceptionMapper()); defaultRestClientFactoryBean.setProviders(providers); return defaultRestClientFactoryBean; }
protected JAXRSClientFactoryBean defaultRestClientFactoryBean() { JAXRSClientFactoryBean defaultRestClientFactoryBean = new JAXRSClientFactoryBean(); defaultRestClientFactoryBean.setHeaders(new HashMap<>()); if (StringUtils.isBlank(address)) { throw new IllegalArgumentException("Property 'address' is missing"); } defaultRestClientFactoryBean.setAddress(address); if (StringUtils.isNotBlank(domain)) { defaultRestClientFactoryBean.getHeaders().put(RESTHeaders.DOMAIN, Collections.singletonList(domain)); } defaultRestClientFactoryBean.setThreadSafe(true); defaultRestClientFactoryBean.setInheritHeaders(true); List<Feature> features = new ArrayList<>(); features.add(new LoggingFeature()); defaultRestClientFactoryBean.setFeatures(features); List<Object> providers = new ArrayList<>(4); providers.add(new DateParamConverterProvider()); providers.add(getJaxbProvider()); providers.add(getJsonProvider()); providers.add(getExceptionMapper()); defaultRestClientFactoryBean.setProviders(providers); return defaultRestClientFactoryBean; }
restClientFactory.getHeaders().put(HttpHeaders.AUTHORIZATION, Collections.singletonList("Bearer " + jwt)); restClientFactory.getHeaders().put( HttpHeaders.AUTHORIZATION, Collections.singletonList("Bearer " + ((JWTAuthenticationHandler) handler).getJwt()));
restClientFactory.getHeaders().put(HttpHeaders.AUTHORIZATION, Collections.singletonList("Bearer " + jwt)); restClientFactory.getHeaders().put( HttpHeaders.AUTHORIZATION, Collections.singletonList("Bearer " + ((JWTAuthenticationHandler) handler).getJwt()));