credentials));
}
else if (credentials instanceof DigestCredentials) {
DigestCredentials digestCred = (DigestCredentials) credentials;
Principal user = new BasicPrincipal(digestCred.getUserName());
user = auth.authenticate(user, digestCred, null);
if (user == null) {
throw new NotAuthorizedException(L.l("'{0}' has invalid digest credentials",
digestCred.getUserName()));
}
}
else if (credentials instanceof String) {
String password = (String) credentials;
Principal user = new BasicPrincipal(to);
PasswordCredentials pwdCred = new PasswordCredentials(password);
if (auth.authenticate(user, pwdCred, null) == null) {
throw new NotAuthorizedException(L.l("'{0}' has invalid password credentials",
to));