Java tutorial
//package com.java2s; import java.security.cert.CertPathValidatorException; import java.util.Iterator; import java.util.Set; public class Main { protected static void checkExcludedEmail(Set excluded, String email) throws CertPathValidatorException { if (excluded.isEmpty()) { return; } String sub = email.substring(email.indexOf('@') + 1); Iterator it = excluded.iterator(); while (it.hasNext()) { String str = (String) it.next(); if (sub.endsWith(str)) { throw new CertPathValidatorException("Subject email address is from an excluded subtree"); } } } }