else if (_security.isSystemAuthKey() || ! _isAuthenticationRequired)
serverSignature = _security.signSystem(uid, nonce);
else {
log.info("Authentication failed because no resin-system-auth-key");
throw new NotAuthorizedException(L.l("'{0}' has invalid credentials",
uid));
}
if (! serverSignature.equals(signature)) {
throw new NotAuthorizedException(L.l("'{0}' has invalid credentials",
uid));
}
}
else if (auth == null && ! _isAuthenticationRequired) {
}
else if (auth == null) {
log.finer("Authentication failed because no authenticator configured");
throw new NotAuthorizedException(L.l("'{0}' has missing authenticator",
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));
}
}
/*
else if (server.getAdminCookie() == null && credentials == null) {
if (! "127.0.0.1".equals(ipAddress)) {
throw new NotAuthorizedException(L.l("'{0}' is an invalid local address for '{1}', because no password credentials are available",
ipAddress, uid));
}
}
*/
else {
throw new NotAuthorizedException(L.l("'{0}' is an unknown credential",
credentials));
}
}