/** * 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)); }
/** * 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)); }
/** * Builds client instance with no authentication, for user self-registration and password reset. * * @return client instance with no authentication */ public SyncopeClient create() { return create(new NoAuthenticationHandler()); }
/** * Builds client instance with no authentication, for user self-registration and password reset. * * @return client instance with no authentication */ public SyncopeClient create() { return create(new NoAuthenticationHandler()); }
/** * Builds client instance which will be passing the provided value in the * {@link javax.ws.rs.core.HttpHeaders#AUTHORIZATION} * request header. * * @param jwt value received after login, in the {@link RESTHeaders#TOKEN} response header * @return client instance which will be passing the provided value in the * {@link javax.ws.rs.core.HttpHeaders#AUTHORIZATION} * request header */ public SyncopeClient create(final String jwt) { return create(new JWTAuthenticationHandler(jwt)); }
/** * Builds client instance which will be passing the provided value in the * {@link javax.ws.rs.core.HttpHeaders#AUTHORIZATION} * request header. * * @param jwt value received after login, in the {@link RESTHeaders#TOKEN} response header * @return client instance which will be passing the provided value in the * {@link javax.ws.rs.core.HttpHeaders#AUTHORIZATION} * request header */ public SyncopeClient create(final String jwt) { return create(new JWTAuthenticationHandler(jwt)); }
@Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache, no-store"); response.setHeader("Pragma", "no-cache"); response.setStatus(HttpServletResponse.SC_SEE_OTHER); SyncopeClientFactoryBean clientFactory = (SyncopeClientFactoryBean) request.getServletContext(). getAttribute(Constants.SYNCOPE_CLIENT_FACTORY); String accessToken = (String) request.getSession().getAttribute(Constants.OIDCCLIENTJWT); if (StringUtils.isBlank(accessToken)) { throw new IllegalArgumentException("No access token found "); } SyncopeClient client = clientFactory.create(accessToken); OIDCLogoutRequestTO requestTO = client.getService(OIDCClientService.class). createLogoutRequest(request.getSession().getAttribute(OIDCConstants.OP).toString()); String postLogoutRedirectURI = StringUtils.substringBefore(request.getRequestURL().toString(), "/beforelogout") + "/logout"; UriBuilder ub = UriBuilder.fromUri(requestTO.getEndSessionEndpoint()); ub.queryParam(OIDCConstants.POST_LOGOUT_REDIRECT_URI, postLogoutRedirectURI); response.setHeader(HttpHeaders.LOCATION, ub.build().toASCIIString()); } }
@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 List<String> getDomains() { synchronized (LOG) { if (domains == null) { domains = newClientFactory().create( new AnonymousAuthenticationHandler(anonymousUser, anonymousKey)). getService(DomainService.class).list().stream().map(EntityTO::getKey). collect(Collectors.toList()); domains.add(0, SyncopeConstants.MASTER_DOMAIN); domains = ListUtils.unmodifiableList(domains); } } return domains; }
@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))); }
@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))); }
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; }
public boolean authenticate(final String jwt) { boolean authenticated = false; try { client = SyncopeEnduserApplication.get().getClientFactory(). setDomain(SyncopeEnduserApplication.get().getDomain()).create(jwt); afterAuthentication(null); authenticated = true; } catch (Exception e) { LOG.error("Authentication failed", e); } return authenticated; }
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; }
public boolean authenticate(final String jwt) { boolean authenticated = false; try { client = SyncopeWebApplication.get().getClientFactory(). setDomain(SyncopeWebApplication.get().getDomain()).create(jwt); afterAuthentication(null); authenticated = true; } catch (Exception e) { LOG.error("Authentication failed", e); } return authenticated; }
public boolean authenticate(final String username, final String password) { boolean authenticated = false; try { client = SyncopeEnduserApplication.get().getClientFactory(). setDomain(SyncopeEnduserApplication.get().getDomain()). create(username, password); afterAuthentication(username); authenticated = true; } catch (Exception e) { LOG.error("Authentication failed", e); } return authenticated; }
public boolean authenticate(final String username, final String password) { boolean authenticated = false; try { client = SyncopeWebApplication.get().getClientFactory(). setDomain(SyncopeWebApplication.get().getDomain()). create(username, password); afterAuthentication(username); authenticated = true; } catch (Exception e) { LOG.error("Authentication failed", e); } return authenticated; }
public SyncopeEnduserSession(final Request request) { super(request); // define cookie utility to manage application cookies cookieUtils = new CookieUtils(); anonymousClient = SyncopeEnduserApplication.get().getClientFactory(). create(new AnonymousAuthenticationHandler( SyncopeEnduserApplication.get().getAnonymousUser(), SyncopeEnduserApplication.get().getAnonymousKey())); platformInfo = anonymousClient.getService(SyncopeService.class).platform(); datePlainSchemas = anonymousClient.getService(SchemaService.class). search(new SchemaQuery.Builder().type(SchemaType.PLAIN).build()); datePlainSchemas.removeAll(datePlainSchemas.stream(). filter(object -> object.getType() != AttrSchemaType.Date).collect(Collectors.toSet())); }
public SyncopeEnduserSession(final Request request) { super(request); // define cookie utility to manage application cookies cookieUtils = new CookieUtils(); anonymousClient = SyncopeWebApplication.get().getClientFactory(). create(new AnonymousAuthenticationHandler( SyncopeWebApplication.get().getAnonymousUser(), SyncopeWebApplication.get().getAnonymousKey())); platformInfo = anonymousClient.getService(SyncopeService.class).platform(); datePlainSchemas = anonymousClient.getService(SchemaService.class). search(new SchemaQuery.Builder().type(SchemaType.PLAIN).build()); datePlainSchemas.removeAll(datePlainSchemas.stream(). filter(object -> object.getType() != AttrSchemaType.Date).collect(Collectors.toSet())); }
public SyncopeConsoleSession(final Request request) { super(request); clientFactory = SyncopeWebApplication.get().newClientFactory(); anonymousClient = clientFactory. create(new AnonymousAuthenticationHandler( SyncopeWebApplication.get().getAnonymousUser(), SyncopeWebApplication.get().getAnonymousKey())); platformInfo = anonymousClient.getService(SyncopeService.class).platform(); systemInfo = anonymousClient.getService(SyncopeService.class).system(); executor = new ThreadPoolTaskExecutor(); executor.setWaitForTasksToCompleteOnShutdown(false); executor.setCorePoolSize(SyncopeWebApplication.get().getCorePoolSize()); executor.setMaxPoolSize(SyncopeWebApplication.get().getMaxPoolSize()); executor.setQueueCapacity(SyncopeWebApplication.get().getQueueCapacity()); executor.initialize(); }