1 19 20 package com.sslexplorer.input.validators; 21 22 import java.util.Properties ; 23 24 import com.sslexplorer.boot.CodedException; 25 import com.sslexplorer.boot.PropertyDefinition; 26 import com.sslexplorer.boot.PropertyValidator; 27 import com.sslexplorer.core.CoreException; 28 29 31 public class LDAPSyntaxValidator implements PropertyValidator { 32 private static final String COMMON_NAME = "cn="; 33 private static final String ORGANISATIONAL_UNIT = "ou="; 34 35 public void validate(PropertyDefinition definition, String value, Properties properties) throws CodedException { 36 if (!startsWith(value, COMMON_NAME) && !startsWith(value, ORGANISATIONAL_UNIT)) { 37 throw new CoreException(ErrorConstants.ERR_STRING_NON_DN, ErrorConstants.CATEGORY_NAME, ErrorConstants.BUNDLE_NAME, null, value); 38 } 39 } 40 41 private static boolean startsWith(String toCheck, String required) { 42 return toCheck.toLowerCase().startsWith(required); 43 } 44 } | Popular Tags |