@Override public boolean process(TProtocol in, TProtocol out) throws TException { ThriftUtil.setIpAddress(in); ThriftUtil.setImpersonator(in); return super.process(in, out); } }
public static void setIpAddress(final TProtocol in) { try { TTransport transport = in.getTransport(); TSocket tSocket = getUnderlyingSocketFromTransport(transport); if (tSocket != null) { setIpAddress(tSocket.getSocket().getInetAddress().toString()); } else { LOGGER.warn("Unknown Transport, cannot determine ipAddress"); } } catch (Exception e) { // If there has exception when get impersonator info, log the error information. LOGGER.warn("There is an error when get the client's ip address:" + e.getMessage()); } }
public static void setImpersonator(final TProtocol in) { try { TTransport transport = in.getTransport(); if (transport instanceof TSaslServerTransport) { String impersonator = ((TSaslServerTransport) transport).getSaslServer() .getAuthorizationID(); setImpersonator(impersonator); } } catch (Exception e) { // If there has exception when get impersonator info, log the error information. LOGGER.warn("There is an error when get the impersonator:" + e.getMessage()); } }
private void setCommAttrForAMLE(AuditMetadataLogEntity amle, Configuration conf, TSentryResponseStatus responseStatus, String userName, String requestClassName) { amle.setUserName(userName); amle.setServiceName(conf.get(ServerConfig.SENTRY_SERVICE_NAME, ServerConfig.SENTRY_SERVICE_NAME_DEFAULT).trim()); amle.setImpersonator(ThriftUtil.getImpersonator()); amle.setIpAddress(ThriftUtil.getIpAddress()); amle.setOperation(Constants.requestTypeToOperationMap.get(requestClassName)); amle.setEventTime(Long.toString(System.currentTimeMillis())); amle.setAllowed(isAllowed(responseStatus)); amle.setObjectType(Constants.requestTypeToObjectTypeMap .get(requestClassName)); } }
@Override public boolean process(TProtocol in, TProtocol out) throws TException { // set the ip and impersonator for audit log ThriftUtil.setIpAddress(in); ThriftUtil.setImpersonator(in); return super.process(in, out); } }
@Override public boolean process(TProtocol in, TProtocol out) throws TException { ThriftUtil.setIpAddress(in); ThriftUtil.setImpersonator(in); return super.process(in, out); } }
@BeforeClass public static void init() { conf = new Configuration(); conf.set(ServerConfig.SENTRY_SERVICE_NAME, ServerConfig.SENTRY_SERVICE_NAME_DEFAULT); ThriftUtil.setIpAddress(TEST_IP); ThriftUtil.setImpersonator(TEST_IMPERSONATOR); }
@BeforeClass public static void init() { conf = new Configuration(); conf.set(ServerConfig.SENTRY_SERVICE_NAME, ServerConfig.SENTRY_SERVICE_NAME_DEFAULT); ThriftUtil.setIpAddress(TEST_IP); ThriftUtil.setImpersonator(TEST_IMPERSONATOR); TEST_PRIVILEGES_MAP.put("resourceType1", "resourceName1"); TEST_PRIVILEGES_MAP.put("resourceType2", "resourceName2"); TEST_PRIVILEGES_MAP.put("resourceType3", "resourceName3"); }