use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class RegistrationController method displayFinalStep.
/**
* OO-92
*
* displays the final step of the registration process. (step5)<br />
* see also _content/finish.html
*
* @param user
* The newly created User from which to display information
*/
private void displayFinalStep(Identity persitedIdentity) {
// set wizard step to 5
wizInfoController.setCurStep(5);
// hide the text we don't need anymore
myContent.contextPut("pwdhelp", "");
myContent.contextPut("loginhelp", "");
myContent.contextPut("text", "");
// show last screen
VelocityContainer finishVC = createVelocityContainer("finish");
List<UserPropertyHandler> userPropertyHandlers = UserManager.getInstance().getUserPropertyHandlersFor(RegistrationForm2.USERPROPERTIES_FORM_IDENTIFIER, false);
finishVC.contextPut("userPropertyHandlers", userPropertyHandlers);
finishVC.contextPut("user", persitedIdentity.getUser());
finishVC.contextPut("locale", getLocale());
finishVC.contextPut("username", registrationForm.getLogin());
finishVC.contextPut("text", getTranslator().translate("step5.reg.text", new String[] { registrationForm.getLogin() }));
loginButton = LinkFactory.createButton("form.login", finishVC, this);
loginButton.setCustomEnabledLinkCSS("btn btn-primary");
loginButton.setUserObject(persitedIdentity);
finishVC.put("loginhref", loginButton);
regarea.setContent(finishVC);
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class RegistrationAdminController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// settings
FormLayoutContainer settingsContainer = FormLayoutContainer.createDefaultFormLayout("settings", getTranslator());
settingsContainer.setRootForm(mainForm);
settingsContainer.setFormTitle(translate("admin.registration.title"));
formLayout.add(settingsContainer);
registrationElement = uifactory.addCheckboxesHorizontal("enable.self.registration", "admin.enableRegistration", settingsContainer, enableRegistrationKeys, enableRegistrationValues);
registrationElement.addActionListener(FormEvent.ONCHANGE);
registrationElement.select("on", registrationModule.isSelfRegistrationEnabled());
registrationLoginElement = uifactory.addCheckboxesHorizontal("enable.registration.login", "admin.enableRegistrationLogin", settingsContainer, enableRegistrationKeys, enableRegistrationValues);
registrationLoginElement.addActionListener(FormEvent.ONCHANGE);
registrationLoginElement.select("on", registrationModule.isSelfRegistrationLoginEnabled());
registrationLinkElement = uifactory.addCheckboxesHorizontal("enable.registration.link", "admin.enableRegistrationLink", settingsContainer, enableRegistrationKeys, enableRegistrationValues);
registrationLinkElement.addActionListener(FormEvent.ONCHANGE);
registrationLinkElement.select("on", registrationModule.isSelfRegistrationLinkEnabled());
String example = generateExampleCode();
exampleElement = uifactory.addTextAreaElement("registration.link.example", "admin.registrationLinkExample", 64000, 4, 65, true, example, settingsContainer);
// domain configuration
domainsContainer = FormLayoutContainer.createDefaultFormLayout("domains", getTranslator());
domainsContainer.setRootForm(mainForm);
domainsContainer.setFormTitle(translate("admin.registration.domains.title"));
formLayout.add(domainsContainer);
uifactory.addStaticTextElement("admin.registration.domains.error", null, translate("admin.registration.domains.desc"), domainsContainer);
String domainsList = registrationModule.getDomainListRaw();
domainListElement = uifactory.addTextAreaElement("registration.domain.list", "admin.registration.domains", 64000, 10, 65, true, domainsList, domainsContainer);
// static property
staticPropContainer = FormLayoutContainer.createDefaultFormLayout("propertiesmapping", getTranslator());
staticPropContainer.setRootForm(mainForm);
staticPropContainer.setFormTitle(translate("admin.registration.staticprop.title"));
formLayout.add(staticPropContainer);
uifactory.addStaticTextElement("admin.registration.staticprop.error", null, translate("admin.registration.staticprop.desc"), staticPropContainer);
staticPropElement = uifactory.addCheckboxesHorizontal("enable.staticprop", "admin.enableStaticProp", staticPropContainer, enableRegistrationKeys, enableRegistrationValues);
staticPropElement.addActionListener(FormEvent.ONCHANGE);
staticPropElement.select("on", registrationModule.isStaticPropertyMappingEnabled());
propertyElement = uifactory.addDropdownSingleselect("property", "admin.registration.property", staticPropContainer, propertyKeys, propertyValues, null);
String propertyName = registrationModule.getStaticPropertyMappingName();
UserPropertyHandler handler = userPropertiesConfig.getPropertyHandler(propertyName);
if (handler != null) {
propertyElement.select(handler.getName(), true);
}
propertyElement.addActionListener(FormEvent.ONCHANGE);
String propertyValue = registrationModule.getStaticPropertyMappingValue();
propertyValueElement = uifactory.addTextElement("admin.registration.prop.value", "admin.registration.propertyValue", 255, propertyValue, staticPropContainer);
// static property
FormLayoutContainer remoteLoginContainerContainer = FormLayoutContainer.createDefaultFormLayout("remotelogin", getTranslator());
remoteLoginContainerContainer.setRootForm(mainForm);
remoteLoginContainerContainer.setFormTitle(translate("remote.login.title"));
formLayout.add(remoteLoginContainerContainer);
String remoteExample = generateRemoteLoginExampleCode();
uifactory.addTextAreaElement("remotelogin.example", "admin.registrationLinkExample", 64000, 4, 65, true, remoteExample, remoteLoginContainerContainer);
FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonGroupLayout.setRootForm(mainForm);
uifactory.addFormSubmitButton("save", buttonGroupLayout);
formLayout.add(buttonGroupLayout);
updateUI();
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class UserWebService method getUserListQuery.
/**
* Search users and return them in a simple form (without user properties). User properties
* can be added two the query parameters. If the authUsername and the authProvider are set,
* the search is made only with these two parameters because they are sufficient to return
* a single user.<br>
* The search with login and user properties are made default with wild cards. If an exact
* match is needed, the parameter msut be quoted:<br>
* users?login="username"<br>
* Don't forget the right escaping in the URL!<br>
* You can make a search with the user properties like this:<br>
* users?telMobile=39847592&login=test
* <br >/ The lookup is possible for authors, usermanagers and system administrators. Normal
* users are not allowed to use the lookup service.
*
* @response.representation.200.qname {http://www.example.com}userVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The list of all users in the OLAT system
* @response.representation.200.example {@link org.olat.user.restapi.Examples#SAMPLE_USERVOes}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param login The login (search with like)
* @param authProvider An authentication provider (optional)
* @param authUsername An specific username from the authentication provider
* @param uriInfo The URI infos
* @param httpRequest The HTTP request
* @return An array of users
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getUserListQuery(@QueryParam("login") String login, @QueryParam("authProvider") String authProvider, @QueryParam("authUsername") String authUsername, @QueryParam("statusVisibleLimit") String statusVisibleLimit, @Context UriInfo uriInfo, @Context HttpServletRequest httpRequest) {
// User lookup allowed for authors, usermanagers and admins. For
// usernamanger and up are considered "administrative" when it comes to
// lookup of the user properties
boolean isAdministrativeUser = isUserManager(httpRequest);
if (!isAdministrativeUser && !isAuthor(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
List<Identity> identities;
// make only a search by authUsername
if (StringHelper.containsNonWhitespace(authProvider) && StringHelper.containsNonWhitespace(authUsername)) {
Authentication auth = BaseSecurityManager.getInstance().findAuthenticationByAuthusername(authUsername, authProvider);
if (auth == null) {
identities = Collections.emptyList();
} else {
identities = Collections.singletonList(auth.getIdentity());
}
} else {
String[] authProviders = null;
if (StringHelper.containsNonWhitespace(authProvider)) {
authProviders = new String[] { authProvider };
}
// retrieve and convert the parameters value
Map<String, String> userProps = new HashMap<String, String>();
if (!params.isEmpty()) {
UserManager um = UserManager.getInstance();
Locale locale = getLocale(httpRequest);
List<UserPropertyHandler> propertyHandlers = um.getUserPropertyHandlersFor(PROPERTY_HANDLER_IDENTIFIER, isAdministrativeUser);
for (UserPropertyHandler handler : propertyHandlers) {
if (!params.containsKey(handler.getName()))
continue;
List<String> values = params.get(handler.getName());
if (values.isEmpty())
continue;
String value = formatDbUserProperty(values.get(0), handler, locale);
userProps.put(handler.getName(), value);
}
}
Integer status = Identity.STATUS_VISIBLE_LIMIT;
if (isAdministrativeUser && "all".equalsIgnoreCase(statusVisibleLimit)) {
status = null;
}
identities = BaseSecurityManager.getInstance().getIdentitiesByPowerSearch(login, userProps, true, null, null, authProviders, null, null, null, null, status);
}
int count = 0;
UserVO[] userVOs = new UserVO[identities.size()];
for (Identity identity : identities) {
userVOs[count++] = get(identity);
}
return Response.ok(userVOs).build();
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class UserWebService method validateUser.
private List<ErrorVO> validateUser(User user, UserVO userVo, HttpServletRequest request) {
UserManager um = UserManager.getInstance();
Locale locale = getLocale(request);
List<ErrorVO> errors = new ArrayList<>();
List<UserPropertyHandler> propertyHandlers = um.getUserPropertyHandlersFor(PROPERTY_HANDLER_IDENTIFIER, false);
validateProperty(user, UserConstants.FIRSTNAME, userVo.getFirstName(), propertyHandlers, errors, um, locale);
validateProperty(user, UserConstants.LASTNAME, userVo.getLastName(), propertyHandlers, errors, um, locale);
validateProperty(user, UserConstants.EMAIL, userVo.getEmail(), propertyHandlers, errors, um, locale);
for (UserPropertyHandler propertyHandler : propertyHandlers) {
if (!UserConstants.FIRSTNAME.equals(propertyHandler.getName()) && !UserConstants.LASTNAME.equals(propertyHandler.getName()) && !UserConstants.EMAIL.equals(propertyHandler.getName())) {
validateProperty(user, userVo, propertyHandler, errors, um, locale);
}
}
return errors;
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class UsrPropCfgManager method savePersistedProperties.
/**
* saves our config to persistedProperties
*/
private void savePersistedProperties() {
StringBuilder sbActiveHandlers = new StringBuilder();
StringBuilder sbDeactiveHandlers = new StringBuilder();
// the propertyhandlers
for (UserPropertyHandler handler : cfgObject.getPropertyHandlers()) {
// save the group of each handler
setStringProperty(handler.getName() + CONF_KEY_PROPGROUP, handler.getGroup(), false);
if (cfgObject.isActiveHandler(handler)) {
sbActiveHandlers.append(handler.getName() + PROP_DELIMITER);
} else {
sbDeactiveHandlers.append(handler.getName() + PROP_DELIMITER);
}
}
setStringProperty(CONF_KEY_ACTUPROP, sbActiveHandlers.toString(), false);
setStringProperty(CONF_KEY_DACTUPROP, sbDeactiveHandlers.toString(), false);
// the contexts
for (Entry<String, UserPropertyUsageContext> ctxEntry : cfgObject.getUsageContexts().entrySet()) {
StringBuilder sbHandlers = new StringBuilder();
StringBuilder sbMandatoryHandlers = new StringBuilder();
StringBuilder sbAdminonlyHandlers = new StringBuilder();
StringBuilder sbUsrreadonlyHandlers = new StringBuilder();
// now loop over the handlers in the current context
UserPropertyUsageContext ctx = ctxEntry.getValue();
for (UserPropertyHandler handler : ctx.getPropertyHandlers()) {
if (cfgObject.isActiveHandler(handler)) {
sbHandlers.append(handler.getName() + PROP_DELIMITER);
log.debug(ctxEntry.getKey() + " has active handler :" + handler.getName());
}
if (ctx.isMandatoryUserProperty(handler)) {
sbMandatoryHandlers.append(handler.getName() + PROP_DELIMITER);
}
if (ctx.isForAdministrativeUserOnly(handler)) {
sbAdminonlyHandlers.append(handler.getName() + PROP_DELIMITER);
}
if (ctx.isUserViewReadOnly(handler)) {
sbUsrreadonlyHandlers.append(handler.getName() + PROP_DELIMITER);
}
}
setStringProperty(ctxEntry.getKey(), "1", false);
setStringProperty(ctxEntry.getKey() + CONF_KEY_CONTPREFIX, sbHandlers.toString(), false);
setStringProperty(ctxEntry.getKey() + CONF_KEY_CONTPREFIX + CONF_KEY_CONT_MANDATORY_PREFIX, sbMandatoryHandlers.toString(), false);
setStringProperty(ctxEntry.getKey() + CONF_KEY_CONTPREFIX + CONF_KEY_CONT_ADMINONLY_PREFIX, sbAdminonlyHandlers.toString(), false);
setStringProperty(ctxEntry.getKey() + CONF_KEY_CONTPREFIX + CONF_KEY_CONT_USERREADONLY_PREFIX, sbUsrreadonlyHandlers.toString(), false);
}
// now persist
savePropertiesAndFireChangedEvent();
}
Aggregations