*/
public class ValidateUDDIKey {
public static void validateUDDIv3Key(String key) throws DispositionReportFaultMessage {
if (key == null)
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NullKey"));
String keyToTest = key.trim();
if (keyToTest.endsWith(KeyGenerator.PARTITION_SEPARATOR))
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));
StringTokenizer tokenizer = new StringTokenizer(key.toLowerCase(), KeyGenerator.PARTITION_SEPARATOR);
int tokensCount = tokenizer.countTokens();
if(tokensCount <= 1)
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));
for(int count = 0; tokenizer.hasMoreTokens(); count++) {
String nextToken = tokenizer.nextToken();
if (count == 0) {
if (!ValidateUDDIKey.isValidUDDIScheme(nextToken))
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));
}
else if (count == 1) {
if(!ValidateUDDIKey.isValidDomainKey(nextToken))
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));
}
else {
if (!isValidKSS(nextToken))
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));
}
}
}