Skip to content

Commit

Permalink
0001691: Additional Logging for compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Apr 25, 2014
1 parent ad7524c commit 1f56484
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -29,11 +29,15 @@
import org.apache.commons.lang.StringUtils;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.service.INodeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Protect handlers by checking that the request is allowed.
*/
public class AuthenticationInterceptor implements IInterceptor {

Logger log = LoggerFactory.getLogger(getClass());

public enum AuthenticationStatus {
SYNC_DISABLED, REGISTRATION_REQUIRED, FORBIDDEN, ACCEPTED;
Expand All @@ -58,14 +62,18 @@ public boolean before(HttpServletRequest req, HttpServletResponse resp) throws I
AuthenticationStatus status = getAuthenticationStatus(nodeId, securityToken);

if (AuthenticationStatus.ACCEPTED.equals(status)) {
log.debug("Node '{}' successfully authenticated", nodeId);
return true;
} else if (AuthenticationStatus.REGISTRATION_REQUIRED.equals(status)) {
log.debug("Node '{}' failed to authenticate. It was not regsitered", nodeId);
ServletUtils.sendError(resp, WebConstants.REGISTRATION_REQUIRED);
return false;
} else if (AuthenticationStatus.SYNC_DISABLED.equals(status)) {
log.debug("Node '{}' failed to authenticate. It was not enabled", nodeId);
ServletUtils.sendError(resp, WebConstants.SYNC_DISABLED);
return false;
} else {
log.debug("Node '{}' failed to authenticate. It had the wrong password", nodeId);
ServletUtils.sendError(resp, HttpServletResponse.SC_FORBIDDEN);
return false;
}
Expand Down

0 comments on commit 1f56484

Please sign in to comment.