/** * Builds client instance with the given credentials. * Such credentials will be used only to obtain a valid JWT in the * {@link javax.ws.rs.core.HttpHeaders#AUTHORIZATION} header; * * @param username username * @param password password * @return client instance with the given credentials */ public SyncopeClient create(final String username, final String password) { return create(new BasicAuthenticationHandler(username, password)); }
public SyncopeClientFactoryBean newClientFactory() { return new SyncopeClientFactoryBean(). setAddress(scheme + "://" + host + ":" + port + StringUtils.prependIfMissing(rootPath, "/")). setUseCompression(BooleanUtils.toBoolean(useGZIPCompression)); }
public <T> T getService(final MediaType mediaType, final Class<T> serviceClass) { T service; synchronized (clientFactory) { SyncopeClientFactoryBean.ContentType preType = clientFactory.getContentType(); clientFactory.setContentType(SyncopeClientFactoryBean.ContentType.fromString(mediaType.toString())); service = clientFactory.create(getJWT()).getService(serviceClass); clientFactory.setContentType(preType); } return service; }
/** * Builds client instance with the given authentication handler. * * @param handler authentication handler * @return client instance with the given authentication handler */ public SyncopeClient create(final AuthenticationHandler handler) { return new SyncopeClient( getContentType().getMediaType(), getRestClientFactoryBean(), getExceptionMapper(), handler, useCompression, tlsClientParameters); } }
@Override public void contextInitialized(final ServletContextEvent sce) { // read saml2spagent.properties Properties props = PropertyUtils.read(getClass(), SAML2SP_AGENT_PROPERTIES, "conf.directory"); String anonymousUser = props.getProperty("anonymousUser"); assertNotNull(anonymousUser, "<anonymousUser>"); String anonymousKey = props.getProperty("anonymousKey"); assertNotNull(anonymousKey, "<anonymousKey>"); String scheme = props.getProperty("scheme"); assertNotNull(scheme, "<scheme>"); String host = props.getProperty("host"); assertNotNull(host, "<host>"); String port = props.getProperty("port"); assertNotNull(port, "<port>"); String rootPath = props.getProperty("rootPath"); assertNotNull(rootPath, "<rootPath>"); String useGZIPCompression = props.getProperty("useGZIPCompression"); assertNotNull(useGZIPCompression, "<useGZIPCompression>"); SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean(). setAddress(scheme + "://" + host + ":" + port + "/" + rootPath). setUseCompression(BooleanUtils.toBoolean(useGZIPCompression)); sce.getServletContext().setAttribute(Constants.SYNCOPE_CLIENT_FACTORY, clientFactory); sce.getServletContext().setAttribute( Constants.SYNCOPE_ANONYMOUS_CLIENT, clientFactory.create(new AnonymousAuthenticationHandler(anonymousUser, anonymousKey))); }
: Integer.valueOf(props.getProperty("maxUploadFileSizeMB")); clientFactory = new SyncopeClientFactoryBean(). setAddress(scheme + "://" + host + ":" + port + StringUtils.prependIfMissing(rootPath, "/")). setContentType(SyncopeClientFactoryBean.ContentType.JSON). setUseCompression(BooleanUtils.toBoolean(useGZIPCompression));
@Override public boolean authenticate(final String username, final String password) { boolean authenticated = false; try { client = clientFactory.setDomain(getDomain()).create(username, password); refreshAuth(username); authenticated = true; } catch (Exception e) { LOG.error("Authentication failed", e); } return authenticated; }
public MediaType getMediaType() { return clientFactory.getContentType().getMediaType(); }
public JacksonJaxbJsonProvider getJsonProvider() { return jsonProvider == null ? defaultJsonProvider() : jsonProvider; }
public JAXBElementProvider<?> getJaxbProvider() { return jaxbProvider == null ? defaultJAXBProvider() : jaxbProvider; }
public RestClientExceptionMapper getExceptionMapper() { return exceptionMapper == null ? defaultExceptionMapper() : exceptionMapper; }
public JAXRSClientFactoryBean getRestClientFactoryBean() { return restClientFactoryBean == null ? defaultRestClientFactoryBean() : restClientFactoryBean; }
@Override public void contextInitialized(final ServletContextEvent sce) { // read oidcclientagent.properties Properties props = PropertyUtils.read(getClass(), OIDCCLIENT_AGENT_PROPERTIES, "conf.directory"); String anonymousUser = props.getProperty("anonymousUser"); assertNotNull(anonymousUser, "<anonymousUser>"); String anonymousKey = props.getProperty("anonymousKey"); assertNotNull(anonymousKey, "<anonymousKey>"); String scheme = props.getProperty("scheme"); assertNotNull(scheme, "<scheme>"); String host = props.getProperty("host"); assertNotNull(host, "<host>"); String port = props.getProperty("port"); assertNotNull(port, "<port>"); String rootPath = props.getProperty("rootPath"); assertNotNull(rootPath, "<rootPath>"); String useGZIPCompression = props.getProperty("useGZIPCompression"); assertNotNull(useGZIPCompression, "<useGZIPCompression>"); SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean(). setAddress(scheme + "://" + host + ":" + port + "/" + rootPath). setUseCompression(BooleanUtils.toBoolean(useGZIPCompression)); sce.getServletContext().setAttribute(Constants.SYNCOPE_CLIENT_FACTORY, clientFactory); sce.getServletContext().setAttribute( Constants.SYNCOPE_ANONYMOUS_CLIENT, clientFactory.create(new AnonymousAuthenticationHandler(anonymousUser, anonymousKey))); }
: Integer.valueOf(props.getProperty("maxUploadFileSizeMB")); clientFactory = new SyncopeClientFactoryBean(). setAddress(scheme + "://" + host + ":" + port + StringUtils.prependIfMissing(rootPath, "/")). setContentType(SyncopeClientFactoryBean.ContentType.JSON). setUseCompression(BooleanUtils.toBoolean(useGZIPCompression));
public boolean authenticate(final String jwt) { boolean authenticated = false; try { client = clientFactory.setDomain(getDomain()).create(jwt); refreshAuth(null); authenticated = true; } catch (Exception e) { LOG.error("Authentication failed", e); } if (authenticated) { bind(); } signIn(authenticated); return authenticated; }
/** * Builds client instance with the given authentication handler. * * @param handler authentication handler * @return client instance with the given authentication handler */ public SyncopeClient create(final AuthenticationHandler handler) { return new SyncopeClient( getContentType().getMediaType(), getRestClientFactoryBean(), getExceptionMapper(), handler, useCompression, tlsClientParameters); } }
public JacksonJaxbJsonProvider getJsonProvider() { return jsonProvider == null ? defaultJsonProvider() : jsonProvider; }
public JAXBElementProvider<?> getJaxbProvider() { return jaxbProvider == null ? defaultJAXBProvider() : jaxbProvider; }
public RestClientExceptionMapper getExceptionMapper() { return exceptionMapper == null ? defaultExceptionMapper() : exceptionMapper; }
public JAXRSClientFactoryBean getRestClientFactoryBean() { return restClientFactoryBean == null ? defaultRestClientFactoryBean() : restClientFactoryBean; }