public static List<Tuple2<String, String>> validateSamePassword(Map<String, String> formValues, String fieldPassword, String fieldPasswordConf) { List<Tuple2<String, String>> errors = new ArrayList<>(); String password = formValues.get(fieldPassword); String passwordConf = formValues.get(fieldPasswordConf); if (!StringTools.safeEquals(password, passwordConf)) { errors.add(new Tuple2<>(fieldPasswordConf, "error.notSamePassword")); } return errors; }
.sorted((a, b) -> StringTools.safeComparisonNullFirst(a.getB().getResourceName(), b.getB().getResourceName())) // .forEach(link -> { switch (link.getA()) {
.sorted((a, b) -> StringTools.safeComparisonNullFirst(a.getB().getResourceName(), b.getB().getResourceName())) // .forEach(link -> { switch (link.getA()) {
@Override public void formatForm(CommonServicesContext servicesCtx, Map<String, String> rawFormValues) { CommonFormatting.trimSpacesAround(rawFormValues, UnixUser.PROPERTY_NAME); CommonFormatting.toLowerCase(rawFormValues, UnixUser.PROPERTY_NAME); // Keep clear password if (!StringTools.safeEquals(rawFormValues.get(UnixUser.PROPERTY_KEEP_CLEAR_PASSWORD), "true")) { rawFormValues.put(UnixUser.PROPERTY_KEEP_CLEAR_PASSWORD, "false"); } }
@Override public void formatForm(CommonServicesContext servicesCtx, Map<String, String> rawFormValues) { CommonFormatting.trimSpacesAround(rawFormValues, UnixUser.PROPERTY_NAME); CommonFormatting.toLowerCase(rawFormValues, UnixUser.PROPERTY_NAME); // Keep clear password if (!StringTools.safeEquals(rawFormValues.get(UnixUser.PROPERTY_KEEP_CLEAR_PASSWORD), "true")) { rawFormValues.put(UnixUser.PROPERTY_KEEP_CLEAR_PASSWORD, "false"); } }
public HaProxyConfigPortHttps addPortHttps(int port, String certificatesDirectory) { HaProxyConfigPort configPort = ports.get(port); if (configPort != null) { if (configPort instanceof HaProxyConfigPortHttps) { HaProxyConfigPortHttps configPortHttps = (HaProxyConfigPortHttps) configPort; if (!StringTools.safeEquals(configPortHttps.getCertificatesDirectory(), certificatesDirectory)) { throw new ModelsException("Port " + port + " is already used for HTTPS, but with anothercertificate folder"); } return configPortHttps; } else { throw new ModelsException("Port " + port + " is already used for another type of port"); } } HaProxyConfigPortHttps configPortHttps = new HaProxyConfigPortHttps(certificatesDirectory); ports.put(port, configPortHttps); return configPortHttps; }
if (StringTools.safeEquals(jamesEmailServer.getMeta().get("certThumbprint-" + certType), cert.getThumbprint())) {
@Override public void updateHandler(CommonServicesContext services, ChangesContext changes, UnixUser previousResource, UnixUser newResource) { // Unique user name if (!StringTools.safeEquals(previousResource.getName(), newResource.getName())) { checkUniqueName(services, newResource.getName()); } common(services, changes, newResource); }
@Override public void updateHandler(CommonServicesContext services, ChangesContext changes, UnixUser previousResource, UnixUser newResource) { // Unique user name if (!StringTools.safeEquals(previousResource.getName(), newResource.getName())) { checkUniqueName(services, newResource.getName()); } common(services, changes, newResource); }
@Override public void updateHandler(CommonServicesContext services, ChangesContext changes, Machine previousResource, Machine newResource) { if (!StringTools.safeEquals(previousResource.getName(), newResource.getName())) { removeApplicationFor(services, changes, previousResource.getName()); } commonHandlerExecute(services, changes, newResource); }
@Override protected void commonHandlerExecute(CommonServicesContext services, ChangesContext changes, CommonMethodUpdateEventHandlerContext<Machine> context) { Machine resource = context.getResource(); if (context.getOldResource() != null && !StringTools.safeEquals(context.getOldResource().getName(), resource.getName())) { throw new IllegalUpdateException("You cannot change a Machine's name"); } context.getManagedResourceTypes().add(DnsEntry.class); if (resource.getPublicIp() != null) { // Use a DnsEntry context.getManagedResources().add(new DnsEntry(resource.getName(), DnsEntryType.A, resource.getPublicIp())); } }
@Override protected void commonHandlerExecute(CommonServicesContext services, ChangesContext changes, CommonMethodUpdateEventHandlerContext<Machine> context) { Machine resource = context.getResource(); if (context.getOldResource() != null && !StringTools.safeEquals(context.getOldResource().getName(), resource.getName())) { throw new IllegalUpdateException("You cannot change a Machine's name"); } context.getManagedResourceTypes().add(DnsEntry.class); if (resource.getPublicIp() != null) { // Use a DnsEntry context.getManagedResources().add(new DnsEntry(resource.getName(), DnsEntryType.A, resource.getPublicIp())); } }
if (!StringTools.safeEquals(expectedHash, resource.getHashedPassword())) { updateHash = true;
if (!StringTools.safeEquals(expectedHash, resource.getHashedPassword())) { updateHash = true;
fieldConfig.setConvertFromString(text -> StringTools.safeEquals("TRUE", text)); fieldConfig.setConvertToString(value -> ((boolean) value) ? "TRUE" : "FALSE"); });