public <T> T getService(final Class<T> serviceClass) { return (client == null || !isAuthenticated()) ? anonymousClient.getService(serviceClass) : client.getService(serviceClass); }
public boolean isAuthenticated() { return client != null && client.getJWT() != null; }
/** * Invalidates the JWT currently in use. */ public void logout() { getService(AccessTokenService.class).logout(); cleanup(); }
public Map<String, String> getFilters() { Map<String, String> filters = new HashMap<>(); for (Map.Entry<String, List<SearchClause>> entry : getFilterClauses().entrySet()) { if (!entry.getValue().isEmpty()) { AbstractFiqlSearchConditionBuilder bld; switch (entry.getKey()) { case "USER": bld = SyncopeClient.getUserSearchConditionBuilder(); break; case "GROUP": bld = SyncopeClient.getGroupSearchConditionBuilder(); break; default: bld = SyncopeClient.getAnyObjectSearchConditionBuilder(entry.getKey()); } filters.put(entry.getKey(), SearchUtils.buildFIQL(entry.getValue(), bld)); } } return filters; }
@Override public void onEvent(final IEvent<?> event) { if (event.getPayload() instanceof SearchClausePanel.SearchEvent) { final AjaxRequestTarget target = SearchClausePanel.SearchEvent.class.cast(event.getPayload()).getTarget(); if (Ownership.this.isGroupOwnership.getObject()) { final String fiql = SearchUtils.buildFIQL( groupSearchPanel.getModel().getObject(), SyncopeClient.getGroupSearchConditionBuilder()); groupDirectoryPanel.search(fiql, target); } else { final String fiql = SearchUtils.buildFIQL( userSearchPanel.getModel().getObject(), SyncopeClient.getUserSearchConditionBuilder()); userDirectoryPanel.search(fiql, target); } } else if (event.getPayload() instanceof AnySelectionDirectoryPanel.ItemSelection) { final AnyTO sel = ((AnySelectionDirectoryPanel.ItemSelection) event.getPayload()).getSelection(); if (sel == null) { wrapper.getInnerObject().setUserOwner(null); wrapper.getInnerObject().setGroupOwner(null); } else if (sel instanceof UserTO) { wrapper.getInnerObject().setUserOwner(sel.getKey()); wrapper.getInnerObject().setGroupOwner(null); } else if (sel instanceof GroupTO) { wrapper.getInnerObject().setGroupOwner(sel.getKey()); wrapper.getInnerObject().setUserOwner(null); } ((AnySelectionDirectoryPanel.ItemSelection) event.getPayload()).getTarget().add(ownerContainer); } else { super.onEvent(event); } }
/** * Asks for asynchronous propagation towards external resources with null priority. * * @param <T> any service class * @param service service class instance * @param nullPriorityAsync whether asynchronous propagation towards external resources with null priority is * requested * @return service instance of the given reference class, with related header set */ public <T> T nullPriorityAsync(final T service, final boolean nullPriorityAsync) { return header(service, RESTHeaders.NULL_PRIORITY_ASYNC, nullPriorityAsync); }
public String getUDynMembershipCond() { if (CollectionUtils.isEmpty(this.uDynClauses)) { return null; } else { return SearchUtils.buildFIQL(this.uDynClauses, SyncopeClient.getUserSearchConditionBuilder()); } }
/** * (Re)initializes the current instance with the authentication capabilities of the provided {@code handler}. * * @param handler authentication handler */ public void login(final AuthenticationHandler handler) { init(handler); }
/** * Retrieve dyn group memberships. */ private void reloadDynMemberships() { GroupFiqlSearchConditionBuilder searchConditionBuilder = SyncopeClient.getGroupSearchConditionBuilder(); List<CompleteCondition> conditions = GroupableRelatableTO.class.cast(anyTO).getDynMemberships(). stream().map(membership -> searchConditionBuilder.is("key").equalTo(membership.getGroupKey()).wrap()). collect(Collectors.toList()); dynMemberships = new ArrayList<>(); if (SyncopeConsoleSession.get().owns(StandardEntitlement.GROUP_SEARCH) && !conditions.isEmpty()) { dynMemberships.addAll(groupRestClient.search( SyncopeConstants.ROOT_REALM, searchConditionBuilder.or(conditions).query(), -1, -1, new SortParam<>("name", true), null).stream().map(GroupTO::getName).collect(Collectors.toList())); } }
public Map<String, String> getADynMembershipConds() { final Map<String, String> res = new HashMap<>(); if (this.aDynClauses != null && !this.aDynClauses.isEmpty()) { for (Map.Entry<String, List<SearchClause>> entry : this.aDynClauses.entrySet()) { if (CollectionUtils.isNotEmpty(entry.getValue())) { final String fiql = SearchUtils.buildFIQL(entry.getValue(), SyncopeClient.getAnyObjectSearchConditionBuilder(entry.getKey())); if (fiql != null) { res.put(entry.getKey(), fiql); } } } } return res; }
/** * 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 Map<String, String> getAboutFIQLs() { if (CollectionUtils.isEmpty(this.aboutClauses)) { return this.notificationTO.getAbouts(); } else { Map<String, String> res = new HashMap<>(); for (Pair<String, List<SearchClause>> pair : this.aboutClauses) { AbstractFiqlSearchConditionBuilder builder; switch (pair.getLeft()) { case "USER": builder = SyncopeClient.getUserSearchConditionBuilder(); break; case "GROUP": builder = SyncopeClient.getGroupSearchConditionBuilder(); break; default: builder = SyncopeClient.getAnyObjectSearchConditionBuilder(pair.getLeft()); } res.put(pair.getLeft(), SearchUtils.buildFIQL(pair.getRight(), builder)); } return res; } }
/** * Asks for asynchronous propagation towards external resources with null priority. * * @param <T> any service class * @param service service class instance * @param nullPriorityAsync whether asynchronous propagation towards external resources with null priority is * requested * @return service instance of the given reference class, with related header set */ public <T> T nullPriorityAsync(final T service, final boolean nullPriorityAsync) { return header(service, RESTHeaders.NULL_PRIORITY_ASYNC, nullPriorityAsync); }
public String getDynMembershipCond() { if (CollectionUtils.isEmpty(this.dynClauses)) { return null; } else { return SearchUtils.buildFIQL(this.dynClauses, SyncopeClient.getUserSearchConditionBuilder()); } }
/** * (Re)initializes the current instance with the authentication capabilities of the provided {@code handler}. * * @param handler authentication handler */ public void login(final AuthenticationHandler handler) { init(handler); }
GroupFiqlSearchConditionBuilder searchConditionBuilder = SyncopeClient.getGroupSearchConditionBuilder();
@Override public void onEvent(final IEvent<?> event) { if (event.getPayload() instanceof SearchClausePanel.SearchEvent) { final AjaxRequestTarget target = SearchClausePanel.SearchEvent.class.cast(event.getPayload()). getTarget(); final String fiql = SearchUtils.buildFIQL(anyObjectSearchPanel.getModel().getObject(), SyncopeClient.getAnyObjectSearchConditionBuilder(anyObjectSearchPanel.getBackObjectType())); AnyDirectoryPanel.class.cast(Specification.this.anyObjectDirectoryPanel).search(fiql, target); } else if (event.getPayload() instanceof AnySelectionDirectoryPanel.ItemSelection) { final AjaxRequestTarget target = AnySelectionDirectoryPanel.ItemSelection.class.cast(event. getPayload()).getTarget(); AnyTO right = AnySelectionDirectoryPanel.ItemSelection.class.cast(event.getPayload()).getSelection(); rel.setOtherEndKey(right.getKey()); Relationships.this.addNewRelationships(rel); Relationships.this.addOrReplace(getViewFragment().setRenderBodyOnly(true)); target.add(Relationships.this); } else { super.onEvent(event); } } }
/** * 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 <T> T getService(final Class<T> serviceClass) { return (client == null || !isAuthenticated()) ? anonymousClient.getService(serviceClass) : client.getService(serviceClass); }
/** * Invalidates the JWT currently in use. */ public void logout() { getService(AccessTokenService.class).logout(); cleanup(); }