class PrincipalAuthority implements Authority, AuthorityKeyStore {

    boolean remoteIpCheck(String remoteAddr, boolean writeOp, PrincipalToken serviceToken,
            String authorizedServiceName) {
        
        boolean checkResult = true;
        switch (ipCheckMode) {
            case OPS_ALL:
                if (!remoteAddr.equals(serviceToken.getIP())) {
                    checkResult = false;
                }
                break;
            case OPS_WRITE:
                /* if we have a user token for a write operation and we have an IP address
                 * mismatch then we'll allow this authenticate request to proceed only if it's
                 * been configured with authorized user only. */
                
                if (writeOp && !remoteAddr.equals(serviceToken.getIP())) {
                    
                    if (authorizedServiceName == null) {
                        checkResult = false;
                    }
                }
                break;
            default:
                break;
        }
        
        return checkResult;
    }

    public  PrincipalAuthority();

}