public void changePassword(final String password) { getService(UserSelfService.class).mustChangePassword(password); }
public Pair<Map<String, Set<String>>, UserTO> self() { // Explicitly disable header value split because it interferes with JSON deserialization below UserSelfService service = getService(UserSelfService.class); WebClient.getConfig(WebClient.client(service)).getRequestContext().put(HEADER_SPLIT_PROPERTY, false); Response response = service.read(); if (response.getStatusInfo().getStatusCode() != Response.Status.OK.getStatusCode()) { Exception ex = exceptionMapper.fromResponse(response); if (ex != null) { throw (RuntimeException) ex; } } try { return Pair.of( OBJECT_MAPPER.readValue( response.getHeaderString(RESTHeaders.OWNED_ENTITLEMENTS), new TypeReference<Map<String, Set<String>>>() { }), response.readEntity(UserTO.class)); } catch (IOException e) { throw new IllegalStateException(e); } }
confirmPasswordReset(token, parameters.get("newPassword")[0]);
requestPasswordReset(usernameParam[0], securityAnswerParam[0]); } else { SyncopeEnduserSession.get().getService(UserSelfService.class). requestPasswordReset(usernameParam[0], null);
getService(userTO.getETagValue(), UserSelfService.class).update(userUR);
final Response res = SyncopeEnduserSession.get().getService(UserSelfService.class).create(userTO, true);
requestPasswordReset(usernameParam[0], securityAnswerParam[0]); } else { SyncopeEnduserSession.get().getService(UserSelfService.class). requestPasswordReset(usernameParam[0], null);
getService(userTO.getETagValue(), UserSelfService.class).update(userPatch);
resources(userTO.getResources()). build(); Response res = SyncopeEnduserSession.get().getService(UserSelfService.class).create(req);
@Override protected ResourceResponse newResourceResponse(final IResource.Attributes attributes) { ResourceResponse response = new AbstractResource.ResourceResponse(); response.setContentType(MediaType.APPLICATION_JSON); try { HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest(); if (!xsrfCheck(request)) { LOG.error("XSRF TOKEN does not match"); response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match"); return response; } Map<String, String[]> parameters = request.getParameterMap(); if (parameters.get("newPassword") == null || parameters.get("newPassword").length == 0) { throw new Exception("A new correct password should be provided"); } SyncopeEnduserSession.get().getService(UserSelfService.class). mustChangePassword(parameters.get("newPassword")[0]); response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setStatusCode(Response.Status.NO_CONTENT.getStatusCode()); } catch (final Exception e) { LOG.error("Error while updating user", e); response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder() .append("ErrorMessage{{ ") .append(e.getMessage()) .append(" }}") .toString()); } return response; }
@Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { try { SyncopeConsoleSession.get().getAnonymousClient().getService(UserSelfService.class). requestPasswordReset(model.getObject().getUsername(), null); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (Exception e) { LOG.error("While actioning object {}", model.getObject().getKey(), e); SyncopeConsoleSession.get().error( StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage()); } ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target); } }, ActionType.REQUEST_PASSWORD_RESET, StandardEntitlement.USER_UPDATE).
public Pair<Map<String, Set<String>>, UserTO> self() { // Explicitly disable header value split because it interferes with JSON deserialization below UserSelfService service = getService(UserSelfService.class); WebClient.getConfig(WebClient.client(service)).getRequestContext().put(HEADER_SPLIT_PROPERTY, false); Response response = service.read(); if (response.getStatusInfo().getStatusCode() != Response.Status.OK.getStatusCode()) { Exception ex = exceptionMapper.fromResponse(response); if (ex != null) { throw (RuntimeException) ex; } } try { return Pair.of( OBJECT_MAPPER.readValue( response.getHeaderString(RESTHeaders.OWNED_ENTITLEMENTS), new TypeReference<Map<String, Set<String>>>() { }), response.readEntity(UserTO.class)); } catch (IOException e) { throw new IllegalStateException(e); } }
confirmPasswordReset(token, parameters.get("newPassword")[0]);
@Override protected ResourceResponse newResourceResponse(final IResource.Attributes attributes) { ResourceResponse response = new AbstractResource.ResourceResponse(); response.setContentType(MediaType.APPLICATION_JSON); try { HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest(); if (!xsrfCheck(request)) { LOG.error("XSRF TOKEN does not match"); response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match"); return response; } Map<String, String[]> parameters = request.getParameterMap(); if (parameters.get("newPassword") == null || parameters.get("newPassword").length == 0) { throw new Exception("A new correct password should be provided"); } SyncopeEnduserSession.get().getService(UserSelfService.class). mustChangePassword(parameters.get("newPassword")[0]); response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setStatusCode(Response.Status.NO_CONTENT.getStatusCode()); } catch (final Exception e) { LOG.error("Error while updating user", e); response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder() .append("ErrorMessage{{ ") .append(e.getMessage()) .append(" }}") .toString()); } return response; }