package leigh.chain.pki;

public class NameUtils {
    /**
     * Returns <code>true</code> if the provided string is a legal identity name. To be valid
     * an identity name may only contain letters, numbers, and the <code>'-'</code> symbol.
     * <p>
     * BUGS: This method currently does not successfully validate foreign unicode characters,
     * but should.
     */
    public static boolean isValid(String s) {
        if (s == null) return false;
        int len = s.length();
        for (int i = 0; i < len; i++) {
            char c = s.charAt(i);
            if (c != '-' && !Character.isLetterOrDigit(s.charAt(i))) {
                return false;
            }
        }
        return true;
    }
}
