@Override protected String getName(final AnyTO anyTO) { return UserTO.class.cast(anyTO).getUsername(); }
public StatusBean(final AnyTO any, final String resource) { this.key = any.getKey(); this.name = any instanceof UserTO ? ((UserTO) any).getUsername() : any instanceof GroupTO ? ((GroupTO) any).getName() : ((AnyObjectTO) any).getName(); this.resource = resource; }
public static String defaultConsoleLayoutInfoIfEmpty(final String content, final List<String> anyTypes) { String result; if (StringUtils.isBlank(content)) { try { ObjectNode tree = MAPPER.createObjectNode(); tree.set(AnyTypeKind.USER.name(), MAPPER.valueToTree(new UserFormLayoutInfo())); tree.set(AnyTypeKind.GROUP.name(), MAPPER.valueToTree(new GroupFormLayoutInfo())); for (String anyType : anyTypes) { if (!anyType.equals(AnyTypeKind.USER.name()) && !anyType.equals(AnyTypeKind.GROUP.name())) { tree.set(anyType, MAPPER.valueToTree(new AnyObjectFormLayoutInfo())); } } result = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(tree); } catch (IOException e) { throw new IllegalArgumentException("While generating default console layout info for " + SyncopeConsoleSession.get().getSelfTO().getUsername(), e); } } else { try { result = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(MAPPER.readTree(content)); } catch (IOException e) { result = content; } } return result; }
@Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { UserTO clone = SerializationUtils.clone(model.getObject()); clone.setKey(null); clone.setUsername(model.getObject().getUsername() + "_clone"); send(UserDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new UserWrapper(clone), target)); }
@Override protected void onSubmit(final AjaxRequestTarget target) { try { restClient.changePassword(passwordField.getModelObject()); SyncopeConsoleSession.get().invalidate(); setResponsePage(getApplication().getHomePage()); } catch (Exception e) { LOG.error("While changing password for {}", SyncopeConsoleSession.get().getSelfTO().getUsername(), e); SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage()); notificationPanel.refresh(target); } }
@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).
} catch (IOException e) { throw new IllegalArgumentException("While parsing console layout info for " + SyncopeConsoleSession.get().getSelfTO().getUsername(), e);
@Override public String getObject() { if (groupWrapper.getInnerObject().getUserOwner() == null) { return StringUtils.EMPTY; } else { UserTO userTO = userRestClient.read(groupWrapper.getInnerObject().getUserOwner()); if (userTO == null) { return StringUtils.EMPTY; } else { return String.format("[%s] %s", userTO.getKey(), userTO.getUsername()); } } }
if (StringUtils.isNotBlank(template.getUsername()) && !JexlUtils.isExpressionValid(template.getUsername())) { sce.getElements().add("Invalid JEXL: " + template.getUsername());
@Transactional(propagation = Propagation.REQUIRES_NEW) public String create(final SAML2IdPEntity idp, final SAML2LoginResponseTO responseTO, final String nameID) { UserTO userTO = new UserTO(); if (idp.getUserTemplate() != null) { templateUtils.apply(userTO, idp.getUserTemplate()); } List<SAML2IdPActions> actions = getActions(idp); for (SAML2IdPActions action : actions) { userTO = action.beforeCreate(userTO, responseTO); } fill(idp.getKey(), responseTO, userTO); if (userTO.getRealm() == null) { userTO.setRealm(SyncopeConstants.ROOT_REALM); } if (userTO.getUsername() == null) { userTO.setUsername(nameID); } Pair<String, List<PropagationStatus>> created = provisioningManager.create(userTO, false, false); userTO = binder.getUserTO(created.getKey()); for (SAML2IdPActions action : actions) { userTO = action.afterCreate(userTO, responseTO); } return userTO.getUsername(); }
@PreAuthorize("isAuthenticated() " + "and not(hasRole('" + StandardEntitlement.ANONYMOUS + "')) " + "and not(hasRole('" + StandardEntitlement.MUST_CHANGE_PASSWORD + "'))") public ProvisioningResult<UserTO> selfUpdate(final UserPatch userPatch, final boolean nullPriorityAsync) { UserTO userTO = binder.getAuthenticatedUserTO(); userPatch.setKey(userTO.getKey()); ProvisioningResult<UserTO> updated = doUpdate(userPatch, true, nullPriorityAsync); // Ensures that, if the self update above moves the user into a status from which no authentication // is possible, the existing Access Token is clean up to avoid issues with future authentications if (!confDAO.getValuesAsStrings("authentication.statuses").contains(updated.getEntity().getStatus())) { String accessToken = accessTokenDAO.findByOwner(updated.getEntity().getUsername()).getKey(); if (accessToken != null) { accessTokenDAO.delete(accessToken); } } return updated; }
@Transactional(propagation = Propagation.REQUIRES_NEW) public String update(final String username, final OIDCProvider op, final OIDCLoginResponseTO responseTO) { UserTO userTO = binder.getUserTO(userDAO.findKey(username)); UserTO original = SerializationUtils.clone(userTO); fill(op, responseTO, userTO); UserPatch userPatch = AnyOperations.diff(userTO, original, true); List<OIDCProviderActions> actions = getActions(op); for (OIDCProviderActions action : actions) { userPatch = action.beforeUpdate(userPatch, responseTO); } Pair<UserPatch, List<PropagationStatus>> updated = provisioningManager.update(userPatch, false); userTO = binder.getUserTO(updated.getLeft().getKey()); for (OIDCProviderActions action : actions) { userTO = action.afterUpdate(userTO, responseTO); } return userTO.getUsername(); } }
@Transactional(propagation = Propagation.REQUIRES_NEW) public String update(final String username, final SAML2IdPEntity idp, final SAML2LoginResponseTO responseTO) { UserTO userTO = binder.getUserTO(userDAO.findKey(username)); UserTO original = SerializationUtils.clone(userTO); fill(idp.getKey(), responseTO, userTO); UserPatch userPatch = AnyOperations.diff(userTO, original, true); List<SAML2IdPActions> actions = getActions(idp); for (SAML2IdPActions action : actions) { userPatch = action.beforeUpdate(userPatch, responseTO); } Pair<UserPatch, List<PropagationStatus>> updated = provisioningManager.update(userPatch, false); userTO = binder.getUserTO(updated.getLeft().getKey()); for (SAML2IdPActions action : actions) { userTO = action.afterUpdate(userTO, responseTO); } return userTO.getUsername(); } }
@Transactional(propagation = Propagation.REQUIRES_NEW) public String create(final OIDCProvider op, final OIDCLoginResponseTO responseTO, final String email) { UserTO userTO = new UserTO(); if (op.getUserTemplate() != null && op.getUserTemplate().get() != null) { templateUtils.apply(userTO, op.getUserTemplate().get()); } List<OIDCProviderActions> actions = getActions(op); for (OIDCProviderActions action : actions) { userTO = action.beforeCreate(userTO, responseTO); } fill(op, responseTO, userTO); if (userTO.getRealm() == null) { userTO.setRealm(SyncopeConstants.ROOT_REALM); } if (userTO.getUsername() == null) { userTO.setUsername(email); } Pair<String, List<PropagationStatus>> created = provisioningManager.create(userTO, false, false); userTO = binder.getUserTO(created.getKey()); for (OIDCProviderActions action : actions) { userTO = action.afterCreate(userTO, responseTO); } return userTO.getUsername(); }
userTO.getKey(), StringUtils.substringBefore(location, "/Groups") + "/Users/" + userTO.getKey(), userTO.getUsername())); });
fillMemberships((GroupableRelatableTO) anyTO, ((GroupableRelatableTO) template)); } else if (template instanceof UserTO) { if (StringUtils.isNotBlank(((UserTO) template).getUsername())) { String evaluated = JexlUtils.evaluate(((UserTO) template).getUsername(), jexlContext); if (StringUtils.isNotBlank(evaluated)) { ((UserTO) anyTO).setUsername(evaluated);
fileKey = UserTO.class.cast(modelObject.getInnerObject()).getUsername(); } else if (modelObject.getInnerObject() instanceof GroupTO) { fileKey = GroupTO.class.cast(modelObject.getInnerObject()).getName();
UserTO userTO = (UserTO) anyTO; userCR.setUsername(userTO.getUsername()); userCR.setPassword(userTO.getPassword()); userCR.setSecurityQuestion(userTO.getSecurityQuestion());
form.setOutputMarkupId(true); usernameField = new TextField<>("username", new Model<>(SyncopeConsoleSession.get().getSelfTO().getUsername())); usernameField.setMarkupId("username"); usernameField.setEnabled(false);
header = new ResourceModel("actions", StringUtils.EMPTY).getObject(); } else if (modelObject instanceof UserTO) { header = ((UserTO) modelObject).getUsername(); } else if (modelObject instanceof UserWrapper) { header = ((UserWrapper) modelObject).getInnerObject().getUsername(); } else if (modelObject instanceof GroupTO) { header = ((GroupTO) modelObject).getName();