@ValidationMethod(message="deploymentGroups cannot be null and names can only contain letters, numbers, underscores, dashes or periods") @JsonIgnore public boolean isValidDeploymentGroups() { if ( deploymentGroups == null ) { return false; } java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("^[a-zA-Z0-9_\\-.]+$"); for ( String group : deploymentGroups ) { if ( !pattern.matcher(group).matches() ) { return false; } } return true; }
@SuppressWarnings("unused") @ValidationMethod(message = "Index must be an unsigned integer.") public boolean isIndexAbsentOrUnsigned() { if (getIndex().isPresent()) { return getIndex().get() >= 0; } return true; }
@ValidationMethod(message = "Assertion Consumer Service indices must be unique.") @SuppressWarnings("unused") // used by the deserializer private boolean isAssertionConsumerServiceIndicesUnique() { Set<Integer> indices = new HashSet<>(); for (AssertionConsumerService assertionConsumerService : assertionConsumerServices) { final Optional<Integer> index = assertionConsumerService.getIndex(); if (index.isPresent() && !indices.add(index.get())) { return false; } } return true; }
@ValidationMethod(message = "Exactly one Assertion Consumer Service must be marked as default.") @SuppressWarnings("unused") // used by the deserializer private boolean isOnlyOneDefaultAssertionConsumerServiceIndex() { boolean hasDefault = false; for (AssertionConsumerService assertionConsumerService : assertionConsumerServices) { if (assertionConsumerService.getDefault()) { if (hasDefault) { return false; } hasDefault = true; } } return hasDefault; }
@ValidationMethod(message = "Certificate was not a valid x509 cert.") public boolean isX509Valid() { try { getCertificate(); } catch (CertificateException e) { return false; } return true; }
@ValidationMethod(message = ".systemTablePlacement references a keyspace not defined in 'cassandraKeyspaces'") public boolean isValidSystemTablePlacement() { String systemKeyspace = _systemTablePlacement.substring(0, _systemTablePlacement.indexOf(':')); for (CassandraConfiguration cassandraConfig : _cassandraClusters.values()) { if (cassandraConfig.getKeyspaces().containsKey(systemKeyspace)) { return true; } } return false; }
@ValidationMethod(message="Invalid authentication") public boolean isAuthenticationValid() { if (token != null && !token.isEmpty()) return true; if (username != null && !username.isEmpty() && password != null && password.isEmpty()) return true; return false; }
@ValidationMethod(message = "measurementMappings must be regular expressions") public boolean isMeasurementMappingRegularExpressions() { for (Map.Entry<String, String> entry : buildMeasurementMappings().entrySet()) { try { Pattern.compile(entry.getValue()); } catch (PatternSyntaxException e) { return false; } } return true; }
/** * Validates the _session's token to proper UUID form. * @return A boolean value. If true the _session token is correctly formed, otherwise false. */ @JsonIgnore @ValidationMethod(message="may not be correctly formatted token") public boolean isValidToken() { boolean isValid = true; try { UUID.fromString(_session); } catch (Exception e) { isValid = false; } return isValid; }
@JsonIgnore @ValidationMethod(message = ".options.readPreference must be one of \"primary\", \"primaryPreferred\", \"secondary\", \"secondaryPreferred\", or \"nearest\"") public boolean isReadPreferenceValid() { if (options.get(READ_PREFERENCE_KEY) == null) { return true; } try { ReadPreference.valueOf(options.get(READ_PREFERENCE_KEY)); } catch (IllegalArgumentException | ClassCastException e) { return false; } return true; }
@ValidationMethod public boolean isCerficateCheckingDisabled() { if (disableCertificateChecks) { System.setProperty("com.amazonaws.sdk.disableCertChecking","true"); } return true; }
@SuppressWarnings("unused") @ValidationMethod(message = "Assertion Consumer Service url must be an absolute url.") public boolean isUriValid() { return uri.isAbsolute(); }
@ValidationMethod(message = "Matching Service url must be an absolute url.") @SuppressWarnings("unused") // used by the deserializer private boolean isUriValid() { return uri.isAbsolute(); }
@JsonIgnore @ValidationMethod( message = ".refreshFrequency must be less greater than zero when credential retrieval is enabled") public boolean isRefreshFrequencySetWhenFeatureIsEnabled() { return this.retrieveCredentials ? this.refreshFrequency > 1 : true; }
@ValidationMethod(message = "cert chain file {value} does not exist") public boolean isValidCertChainFile() { return certChainFile == null || Files.exists(certChainFile); }
@ValidationMethod(message = "private key file {value} does not exist") public boolean isValidPrivateKeyFile() { return privateKeyFile == null || Files.exists(privateKeyFile); }
@JsonIgnore @ValidationMethod(message = ".minSize must be less than or equal to maxSize") public boolean isMinSizeLessThanMaxSize() { return this.minSize <= this.maxSize; }
@ValidationMethod(message = "must define keyManager when clientAuth is REQUIRE") public boolean isClientAuthConfigValid() { return clientAuth != ClientAuth.REQUIRE || keyManager != null; }
@JsonIgnore @ValidationMethod(message = ".options.writeConcern must be one of the static WriteConcerns on com.mongodb.WriteConcern by name. Case doesn't matter.") public boolean isWriteConcernValid() { return options.get(WRITE_CONCERN_KEY) == null || WriteConcern.valueOf(options.get(WRITE_CONCERN_KEY)) != null; }
@JsonIgnore @ValidationMethod(message = ".options.dbDecoderFactory must be one of \"lazy\", \"lazy-writeable\", or \"default\"") public boolean isDBDecoderFactoryValid() { return options.get(DB_DECODER_FACTORY_KEY) == null || DB_DECODER_FACTORY_VALUES.contains(options.get(DB_DECODER_FACTORY_KEY)); }
@ValidationMethod @JsonIgnore public boolean isValidConfig() { return nodeClient || !servers.isEmpty(); }
@ValidationMethod(message="foo may not be 'John'") public boolean isNotJohn() { return !("John".equals(foo)); }
@ValidationMethod(message = "both or neither AWS access parameter must be set.") public boolean isBothOrNeitherAwsAccessParameterSet() { return (StringUtils.isNotBlank(accessKeyID) && StringUtils.isNotBlank(secretAccessKey)) || (StringUtils.isBlank(accessKeyID) && StringUtils.isBlank(secretAccessKey)); }