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