Java Code Examples for org.apache.sqoop.model.MPrincipal#getName()
The following examples show how to use
org.apache.sqoop.model.MPrincipal#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RangerSqoopAuthorizer.java From ranger with Apache License 2.0 | 6 votes |
public RangerSqoopAccessRequest(MPrincipal principal, MPrivilege privilege,String clientIPAddress) { super.setResource(new RangerSqoopResource(privilege.getResource())); if (MPrincipal.TYPE.USER.name().equals(principal.getType())) { super.setUser(principal.getName()); } if (MPrincipal.TYPE.GROUP.name().equals(principal.getType())) { super.setUserGroups(Sets.newHashSet(principal.getName())); } String action = privilege.getAction(); super.setAccessType(action); super.setAction(action); super.setAccessTime(new Date()); super.setClientIPAddress(clientIPAddress); }
Example 2
Source File: SentryAuthorizationValidator.java From incubator-sentry with Apache License 2.0 | 6 votes |
@Override public void checkPrivileges(MPrincipal principal, List<MPrivilege> privileges) throws SqoopException { if (privileges == null || privileges.isEmpty()) { return; } PrincipalDesc principalDesc = new PrincipalDesc(principal.getName(), principal.getType()); if (principalDesc.getType() != PrincipalType.USER) { throw new SqoopException(SecurityError.AUTH_0014,SentrySqoopError.AUTHORIZE_CHECK_NOT_SUPPORT_FOR_PRINCIPAL); } for (MPrivilege privilege : privileges) { if (LOG.isDebugEnabled()) { LOG.debug("Going to authorize check on privilege : " + privilege + " for principal: " + principal); } if (!binding.authorize(new Subject(principalDesc.getName()), privilege)) { throw new SqoopException(SecurityError.AUTH_0014, "User " + principalDesc.getName() + " does not have privileges for : " + privilege.toString()); } } }
Example 3
Source File: AuthorizationResourceRequest.java From sqoop-on-spark with Apache License 2.0 | 5 votes |
public RolesBean readRolesByPrincipal(String serverUrl, MPrincipal principal) { String response = super.get(serverUrl + RESOURCE + ROLES + "?principal_name=" + principal.getName() + "&principal_type=" + principal.getType()); JSONObject jsonObject = JSONUtils.parse(response); RolesBean bean = new RolesBean(); bean.restore(jsonObject); return bean; }
Example 4
Source File: AuthorizationResourceRequest.java From sqoop-on-spark with Apache License 2.0 | 5 votes |
public PrivilegesBean readPrivilegesByPrincipal(String serverUrl, MPrincipal principal, MResource resource) { String url = serverUrl + RESOURCE + PRIVILEGES + "?principal_name=" + principal.getName() + "&principal_type=" + principal.getType(); if (resource != null) { url += "&resource_name=" + resource.getName(); url += "&resource_type=" + resource.getType(); } String response = super.get(url); JSONObject jsonObject = JSONUtils.parse(response); PrivilegesBean bean = new PrivilegesBean(); bean.restore(jsonObject); return bean; }