@Test public void testAuthorize() { RangerBasePlugin plugin = new RangerBasePlugin("hbase", "hbase"); User user = mock(User.class); when(user.getShortName()).thenReturn("user1"); when(user.getGroupNames()).thenReturn(new String[] { "users" } ); AuthorizationSession session = new AuthorizationSession(plugin); session.access("read") .user(user) .table(":meta:") .buildRequest() .authorize(); }
AuthorizationSession authorize() { if (LOG.isDebugEnabled()) { LOG.debug("==> AuthorizationSession.authorize: " + getRequestMessage()); } if (_request == null) { String message = String.format("Invalid state transition: buildRequest() must be called before authorize(). This request would ultimately get denied.!"); throw new IllegalStateException(message); } else { if (_auditHandler != null && _superUser) { if (LOG.isDebugEnabled()) { LOG.debug("Setting super-user override on audit handler"); } _auditHandler.setSuperUserOverride(_superUser); } _result = _authorizer.isAccessAllowed(_request, _auditHandler); } if (LOG.isDebugEnabled()) { boolean allowed = isAuthorized(); String reason = getDenialReason(); LOG.debug("<== AuthorizationSession.authorize: " + getLogMessage(allowed, reason)); } return this; }
AuthorizationSession { AuthorizationSession authorize() { if (LOG.isDebugEnabled()) { LOG.debug("==> AuthorizationSession.authorize: " + getRequestMessage()); } if (_request == null) { String message = String.format("Invalid state transition: buildRequest() must be called before authorize(). This request would ultimately get denied.!"); throw new IllegalStateException(message); } else { if (_auditHandler != null && _superUser) { if (LOG.isDebugEnabled()) { LOG.debug("Setting super-user override on audit handler"); } _auditHandler.setSuperUserOverride(_superUser); } _result = _authorizer.isAccessAllowed(_request, _auditHandler); } if (LOG.isDebugEnabled()) { boolean allowed = isAuthorized(); String reason = getDenialReason(); LOG.debug("<== AuthorizationSession.authorize: " + getLogMessage(allowed, reason)); } return this; } }
AuthorizationSession { AuthorizationSession authorize() { if (LOG.isDebugEnabled()) { LOG.debug("==> AuthorizationSession.authorize: " + getRequestMessage()); } if (_request == null) { String message = String.format("Invalid state transition: buildRequest() must be called before authorize(). This request would ultimately get denied.!"); throw new IllegalStateException(message); } else { if (_auditHandler != null && _superUser) { if (LOG.isDebugEnabled()) { LOG.debug("Setting super-user override on audit handler"); } _auditHandler.setSuperUserOverride(_superUser); } _result = _authorizer.isAccessAllowed(_request, _auditHandler); } if (LOG.isDebugEnabled()) { boolean allowed = isAuthorized(); String reason = getDenialReason(); LOG.debug("<== AuthorizationSession.authorize: " + getLogMessage(allowed, reason)); } return this; } AuthorizationSession(RangerBasePlugin authorizer); }
AuthorizationSession { AuthorizationSession authorize() { if (LOG.isDebugEnabled()) { LOG.debug("==> AuthorizationSession.authorize: " + getRequestMessage()); } if (_request == null) { String message = String.format("Invalid state transition: buildRequest() must be called before authorize(). This request would ultimately get denied.!"); throw new IllegalStateException(message); } else { if (_auditHandler != null && _superUser) { if (LOG.isDebugEnabled()) { LOG.debug("Setting super-user override on audit handler"); } _auditHandler.setSuperUserOverride(_superUser); } _result = _authorizer.isAccessAllowed(_request, _auditHandler); } if (LOG.isDebugEnabled()) { boolean allowed = isAuthorized(); String reason = getDenialReason(); LOG.debug("<== AuthorizationSession.authorize: " + getLogMessage(allowed, reason)); } return this; } AuthorizationSession(RangerBasePlugin authorizer);  }
AuthorizationSession { AuthorizationSession authorize() { if (LOG.isDebugEnabled()) { LOG.debug("==> AuthorizationSession.authorize: " + getRequestMessage()); } if (_request == null) { String message = String.format("Invalid state transition: buildRequest() must be called before authorize(). This request would ultimately get denied.!"); throw new IllegalStateException(message); } else { if (_auditHandler != null && _superUser) { if (LOG.isDebugEnabled()) { LOG.debug("Setting super-user override on audit handler"); } _auditHandler.setSuperUserOverride(_superUser); } _result = _authorizer.isAccessAllowed(_request, _auditHandler); } if (LOG.isDebugEnabled()) { boolean allowed = isAuthorized(); String reason = getDenialReason(); LOG.debug("<== AuthorizationSession.authorize: " + getLogMessage(allowed, reason)); } return this; } AuthorizationSession(RangerBasePlugin authorizer);   }