X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=security%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fusermgt%2FRegexpNameValidator.java;h=8a774eb7b5e9c60e2cb13284ee050cd20b321c4d;hb=17775e14ecfb286e59f67117e5cee7e21e95ab1f;hp=9d1421b46951adcce86899ffa51993c55020c044;hpb=0d8d8f24656e585ee75558cfd6a4c661f8f14985;p=utils diff --git a/security/src/main/java/org/wamblee/usermgt/RegexpNameValidator.java b/security/src/main/java/org/wamblee/usermgt/RegexpNameValidator.java index 9d1421b4..8a774eb7 100644 --- a/security/src/main/java/org/wamblee/usermgt/RegexpNameValidator.java +++ b/security/src/main/java/org/wamblee/usermgt/RegexpNameValidator.java @@ -1,5 +1,5 @@ /* - * Copyright 2005 the original author or authors. + * Copyright 2005-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,73 +13,80 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.wamblee.usermgt; import org.wamblee.usermgt.UserMgtException.Reason; /** - * Validation of names based on a regular expression. - * + * Validation of names based on a regular expression. + * * @author Erik Brakkee */ public class RegexpNameValidator implements NameValidator { - /** - * Convenience pattern for an id. + * Convenience pattern for an id. */ public static final String ID_PATTERN = "[a-zA-Z]+[a-zA-Z0-9]*"; - + /** - * Convenience pattern for a password consisting of at least 6 characters. + * Convenience pattern for a password consisting of at least 6 characters. */ public static final String PASSWORD_PATTERN = ".{6}.*"; - + /** - * Pattern to use. + * Pattern to use. */ private String pattern; - + /** - * Reason to use when validation fails. + * Reason to use when validation fails. */ - private Reason reason; - + private Reason reason; + /** - * Message to report. + * Message to report. */ - private String message; - + private String message; + /** - * Validates a regular expression. - * @param aPattern Pattern that names must comply to. - * @param aReason Reason to report when validation fails. - * @param aMessage Message to report. + * Validates a regular expression. + * + * @param aPattern + * Pattern that names must comply to. + * @param aReason + * Reason to report when validation fails. + * @param aMessage + * Message to report. */ - public RegexpNameValidator(String aPattern, Reason aReason, String aMessage) { - pattern = aPattern; + public RegexpNameValidator(String aPattern, Reason aReason, String aMessage) { + pattern = aPattern; reason = aReason; - message = aMessage; + message = aMessage; } - + /** - * Convenience constructor with all string parameters. Useful for configuration - * in Spring. - * @param aPattern Pattern to use. - * @param aReason Reason. - * @param aMessage Message. + * Convenience constructor with all string parameters. Useful for + * configuration in Spring. + * + * @param aPattern + * Pattern to use. + * @param aReason + * Reason. + * @param aMessage + * Message. */ - public RegexpNameValidator(String aPattern, String aReason, String aMessage) { + public RegexpNameValidator(String aPattern, String aReason, String aMessage) { this(aPattern, Reason.valueOf(aReason), aMessage); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wamblee.usermgt.NameValidator#validate(java.lang.String) */ public void validate(String aName) throws UserMgtException { - if ( !aName.matches(pattern)) { - throw new UserMgtException(reason, message); + if (!aName.matches(pattern)) { + throw new UserMgtException(reason, message); } } - }