use of org.apache.openmeetings.core.util.StrongPasswordValidator in project openmeetings by apache.
the class ChangePasswordDialog method onInitialize.
@Override
protected void onInitialize() {
getTitle().setObject(getString("327"));
update = new DialogButton("update", Model.of(getString("327"))) {
private static final long serialVersionUID = 1L;
@Override
public boolean isIndicating() {
return true;
}
};
cancel = new DialogButton("cancel", Model.of(getString("lbl.cancel")));
passValidator = new StrongPasswordValidator(getMinPasswdLength(cfgDao), userDao.get(getUserId()));
add(form.add(current.setLabel(Model.of(getString("current.password"))).setRequired(true), pass.setLabel(Model.of(getString("328"))).add(passValidator), pass2.setLabel(Model.of(getString("116"))), feedback.setOutputMarkupId(true)));
super.onInitialize();
}
use of org.apache.openmeetings.core.util.StrongPasswordValidator in project openmeetings by apache.
the class UserForm method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
add(password.setResetPassword(false).setLabel(Model.of(getString("110"))).setRequired(false).add(passValidator = new StrongPasswordValidator(getMinPasswdLength(cfgDao), getModelObject())));
login.setLabel(Model.of(getString("108")));
add(login.add(minimumLength(getMinLoginLength(cfgDao))));
add(new DropDownChoice<>("type", Arrays.asList(Type.values())).add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateDomain(target);
}
}));
update(null);
add(domain.add(domainId).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
add(new Label("ownerId"));
add(new DateLabel("inserted"));
add(new DateLabel("updated"));
add(new CheckBox("forceTimeZoneCheck"));
add(new Select2MultiChoice<>("rights", null, new RestrictiveChoiceProvider<Right>() {
private static final long serialVersionUID = 1L;
@Override
public String getDisplayValue(Right choice) {
return choice.name();
}
@Override
public String toId(Right choice) {
return choice.name();
}
@Override
public void query(String term, int page, Response<Right> response) {
boolean isGroupAdmin = hasGroupAdminLevel(getRights());
for (Right r : Right.values()) {
if (Right.GroupAdmin == r) {
continue;
}
if (isGroupAdmin && (Right.Admin == r || Right.Soap == r)) {
continue;
}
if (Strings.isEmpty(term) || r.name().contains(term)) {
response.add(r);
}
}
}
@Override
public Right fromId(String id) {
return Right.valueOf(id);
}
}));
add(new ComunityUserForm("comunity", getModel()));
// attach an ajax validation behavior to all form component's keydown
// event and throttle it down to once per second
add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND));
add(adminPass);
}
use of org.apache.openmeetings.core.util.StrongPasswordValidator in project openmeetings by apache.
the class Admin method checkAdminDetails.
private void checkAdminDetails() throws Exception {
cfg.setUsername(cmdl.getOptionValue("user"));
cfg.setEmail(cmdl.getOptionValue("email"));
cfg.setGroup(cmdl.getOptionValue("group"));
if (cfg.getUsername() == null || cfg.getUsername().length() < USER_LOGIN_MINIMUM_LENGTH) {
log("User login was not provided, or too short, should be at least " + USER_LOGIN_MINIMUM_LENGTH + " character long.");
throw new ExitException();
}
if (!MailUtil.isValid(cfg.getEmail())) {
log(String.format("Please provide non-empty valid email: '%s' is not valid.", cfg.getEmail()));
throw new ExitException();
}
if (Strings.isEmpty(cfg.getGroup())) {
log(String.format("User group was not provided, or too short, should be at least 1 character long: %s", cfg.getGroup()));
throw new ExitException();
}
if (cmdl.hasOption("password")) {
cfg.setPassword(cmdl.getOptionValue("password"));
}
ConfigurationDao cfgDao = getApplicationContext().getBean(ConfigurationDao.class);
IValidator<String> passValidator = new StrongPasswordValidator(false, getMinPasswdLength(cfgDao), new User());
Validatable<String> passVal;
do {
passVal = new Validatable<>(cfg.getPassword());
passValidator.validate(passVal);
if (!passVal.isValid()) {
log(String.format("Please enter password for the user '%s':", cfg.getUsername()));
cfg.setPassword(new BufferedReader(new InputStreamReader(System.in, UTF_8)).readLine());
}
} while (!passVal.isValid());
Map<String, String> tzMap = ImportHelper.getAllTimeZones(TimeZone.getAvailableIDs());
cfg.setTimeZone(null);
if (cmdl.hasOption("tz")) {
String tz = cmdl.getOptionValue("tz");
cfg.setTimeZone(tzMap.containsKey(tz) ? tz : null);
}
if (cfg.getTimeZone() == null) {
log("Please enter timezone, Possible timezones are:");
for (Map.Entry<String, String> me : tzMap.entrySet()) {
log(String.format("%1$-25s%2$s", "\"" + me.getKey() + "\"", me.getValue()));
}
throw new ExitException();
}
}
use of org.apache.openmeetings.core.util.StrongPasswordValidator in project openmeetings by apache.
the class UserWebService method add.
/**
* Adds a new User like through the Frontend, but also does activates the
* Account To do SSO see the methods to create a hash and use those ones!
*
* @param sid
* The SID from getSession
* @param user
* user object
* @param confirm
* whatever or not to send email, leave empty for auto-send
*
* @return - id of the user added or error code
*/
@WebMethod
@POST
@Path("/")
public UserDTO add(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "user") @FormParam("user") UserDTO user, @WebParam(name = "confirm") @FormParam("confirm") Boolean confirm) {
return performCall(sid, User.Right.Soap, sd -> {
User testUser = userDao.getExternalUser(user.getExternalId(), user.getExternalType());
if (testUser != null) {
throw new ServiceException("User does already exist!");
}
String tz = user.getTimeZoneId();
if (Strings.isEmpty(tz)) {
tz = getDefaultTimezone();
}
if (user.getAddress() == null) {
user.setAddress(new Address());
user.getAddress().setCountry(Locale.getDefault().getCountry());
}
if (user.getLanguageId() == null) {
user.setLanguageId(1L);
}
IValidator<String> passValidator = new StrongPasswordValidator(true, getMinPasswdLength(cfgDao), user.get(userDao));
Validatable<String> passVal = new Validatable<>(user.getPassword());
passValidator.validate(passVal);
if (!passVal.isValid()) {
StringBuilder sb = new StringBuilder();
for (IValidationError err : passVal.getErrors()) {
sb.append(((ValidationError) err).getMessage()).append(System.lineSeparator());
}
log.debug("addNewUser::weak password '{}', msg: {}", user.getPassword(), sb);
throw new ServiceException(sb.toString());
}
Object _user = userManager.registerUser(user.getLogin(), user.getPassword(), user.getLastname(), user.getFirstname(), user.getAddress().getEmail(), new Date(), user.getAddress().getStreet(), user.getAddress().getAdditionalname(), user.getAddress().getFax(), user.getAddress().getZip(), user.getAddress().getCountry(), user.getAddress().getTown(), user.getLanguageId(), // generate SIP Data if the config is enabled
"", // generate SIP Data if the config is enabled
false, // generate SIP Data if the config is enabled
true, tz, confirm);
if (_user == null) {
throw new ServiceException(UNKNOWN.getMessage());
} else if (_user instanceof String) {
throw new ServiceException((String) _user);
}
User u = (User) _user;
u.getRights().add(Right.Room);
if (Strings.isEmpty(user.getExternalId()) && Strings.isEmpty(user.getExternalType())) {
// activate the User
u.getRights().add(Right.Login);
u.getRights().add(Right.Dashboard);
} else {
u.setType(User.Type.external);
u.setExternalId(user.getExternalId());
u.setExternalType(user.getExternalType());
}
u = userDao.update(u, sd.getUserId());
return new UserDTO(u);
});
}
Aggregations