@Override public List<SecurityCapability> getSecurityCapabilities() throws IOException { try { return executeCallable(new MasterCallable<List<SecurityCapability>>(getConnection()) { @Override public List<SecurityCapability> call(int callTimeout) throws ServiceException { PayloadCarryingRpcController controller = rpcControllerFactory.newController(); controller.setCallTimeout(callTimeout); SecurityCapabilitiesRequest req = SecurityCapabilitiesRequest.newBuilder().build(); return ProtobufUtil.toSecurityCapabilityList( master.getSecurityCapabilities(controller, req).getCapabilitiesList()); } }); } catch (IOException e) { if (e instanceof RemoteException) { e = ((RemoteException)e).unwrapRemoteException(); } throw e; } }
@Override public List<SecurityCapability> getSecurityCapabilities() throws IOException { try { return executeCallable(new MasterCallable<List<SecurityCapability>>(getConnection(), getRpcControllerFactory()) { @Override protected List<SecurityCapability> rpcCall() throws Exception { SecurityCapabilitiesRequest req = SecurityCapabilitiesRequest.newBuilder().build(); return ProtobufUtil.toSecurityCapabilityList( master.getSecurityCapabilities(getRpcController(), req).getCapabilitiesList()); } }); } catch (IOException e) { if (e instanceof RemoteException) { e = ((RemoteException)e).unwrapRemoteException(); } throw e; } }
@Test public void testSecurityCapabilities() throws Exception { List<SecurityCapability> capabilities = TEST_UTIL.getConnection().getAdmin() .getSecurityCapabilities(); assertTrue("CELL_VISIBILITY capability is missing", capabilities.contains(SecurityCapability.CELL_VISIBILITY)); }
@Test (timeout=180000) public void testSecurityCapabilities() throws Exception { List<SecurityCapability> capabilities = TEST_UTIL.getConnection().getAdmin() .getSecurityCapabilities(); assertTrue("AUTHORIZATION capability is missing", capabilities.contains(SecurityCapability.AUTHORIZATION)); assertTrue("CELL_AUTHORIZATION capability is missing", capabilities.contains(SecurityCapability.CELL_AUTHORIZATION)); }
/** * Convert SecurityCapabilitiesResponse.Capability to SecurityCapability * @param capabilities capabilities returned in the SecurityCapabilitiesResponse message * @return the converted list of SecurityCapability elements */ public static List<SecurityCapability> toSecurityCapabilityList( List<MasterProtos.SecurityCapabilitiesResponse.Capability> capabilities) { List<SecurityCapability> scList = new ArrayList<>(capabilities.size()); for (MasterProtos.SecurityCapabilitiesResponse.Capability c: capabilities) { try { scList.add(SecurityCapability.valueOf(c.getNumber())); } catch (IllegalArgumentException e) { // Unknown capability, just ignore it. We don't understand the new capability // but don't care since by definition we cannot take advantage of it. } } return scList; }
@Override public CompletableFuture<List<SecurityCapability>> getSecurityCapabilities() { return this .<List<SecurityCapability>> newMasterCaller() .action( (controller, stub) -> this .<SecurityCapabilitiesRequest, SecurityCapabilitiesResponse, List<SecurityCapability>> call( controller, stub, SecurityCapabilitiesRequest.newBuilder().build(), (s, c, req, done) -> s.getSecurityCapabilities(c, req, done), (resp) -> ProtobufUtil .toSecurityCapabilityList(resp.getCapabilitiesList()))).call(); }
@Override public List<SecurityCapability> getSecurityCapabilities() throws IOException { throw new UnsupportedOperationException("getSecurityCapabilities"); }
@Override public List<SecurityCapability> getSecurityCapabilities() throws IOException { return wrappedHbaseAdmin.getSecurityCapabilities(); }
@Override public CompletableFuture<List<SecurityCapability>> getSecurityCapabilities() { return wrap(rawAdmin.getSecurityCapabilities()); }
/** * Return true if cell visibility features are supported and enabled * @param connection The connection to use * @return true if cell visibility features are supported and enabled, false otherwise * @throws IOException */ public static boolean isCellVisibilityEnabled(Connection connection) throws IOException { return connection.getAdmin().getSecurityCapabilities() .contains(SecurityCapability.CELL_VISIBILITY); }
/** * Return true if authorization is supported and enabled * @param connection The connection to use * @return true if authorization is supported and enabled, false otherwise * @throws IOException */ public static boolean isAuthorizationEnabled(Connection connection) throws IOException { return connection.getAdmin().getSecurityCapabilities() .contains(SecurityCapability.AUTHORIZATION); }
/** * Return true if cell authorization is supported and enabled * @param connection The connection to use * @return true if cell authorization is supported and enabled, false otherwise * @throws IOException */ public static boolean isCellAuthorizationEnabled(Connection connection) throws IOException { return connection.getAdmin().getSecurityCapabilities() .contains(SecurityCapability.CELL_AUTHORIZATION); }
/** * Return the set of supported security capabilities. * @throws IOException * @throws UnsupportedOperationException */ List<SecurityCapability> getSecurityCapabilities() throws IOException;
/** * @return the list of supported security capabilities. The return value will be wrapped by a * {@link CompletableFuture}. */ CompletableFuture<List<SecurityCapability>> getSecurityCapabilities();