BloombergBpipePermissionCheckProvider extends AbstractPermissionCheckProvider implements PermissionCheckProvider, Lifecycle { @Override public PermissionCheckProviderResult isPermitted(PermissionCheckProviderRequest request) { ArgumentChecker.notNull(request, "request"); if (isRunning() == false) { return PermissionCheckProviderResult.ofAuthenticationError( "Bloomberg permission check found connection not running"); } String emrsId = StringUtils.trimToNull(request.getUserIdBundle().getValue(ExternalSchemes.BLOOMBERG_EMRSID)); if (emrsId == null) { return PermissionCheckProviderResult.ofAuthenticationError( "Bloomberg permission check request did not contain an EMRS user ID"); } if (request.getNetworkAddress() == null) { return PermissionCheckProviderResult.ofAuthenticationError( "Bloomberg permission check request did not contain a network address"); } Identity userIdentity; try { userIdentity = _userIdentityCache.get(IdentityCacheKey.of(request.getNetworkAddress(), emrsId)); } catch (ExecutionException | UncheckedExecutionException ex) { return processAuthenticationError(request, ex); } return checkPermissions(request, userIdentity); } BloombergBpipePermissionCheckProvider(BloombergConnector bloombergConnector);  BloombergBpipePermissionCheckProvider(BloombergConnector bloombergConnector, Duration identityExpiry); @Override PermissionCheckProviderResult isPermitted(PermissionCheckProviderRequest request); @Override synchronized void start(); @Override void stop(); @Override boolean isRunning();  }
@Test public void isPermittedEidCheck() { PermissionCheckProviderRequest request = PermissionCheckProviderRequest.createGet(ExternalSchemes.bloombergEmrsUserId(EMRS_USER_ID), IP_ADDRESS, EID_27749, EID_35009, EID_39491, EID_40066, EID_41095, EID_46707, EID_1234); PermissionCheckProviderResult resultHolder = _provider.isPermitted(request); assertNotNull(resultHolder); resultHolder.checkErrors(); assertNotNull(resultHolder.getCheckedPermissions()); Map<String, Boolean> checkPermissionResult = resultHolder.getCheckedPermissions(); assertEquals(7, checkPermissionResult.size()); assertTrue(checkPermissionResult.get(EID_27749)); assertTrue(checkPermissionResult.get(EID_35009)); assertTrue(checkPermissionResult.get(EID_39491)); assertTrue(checkPermissionResult.get(EID_40066)); assertTrue(checkPermissionResult.get(EID_41095)); assertTrue(checkPermissionResult.get(EID_46707)); assertFalse(checkPermissionResult.get(EID_1234)); }
@Test public void notPermittedEidCheckAfterEntitlementRevoked() { PermissionCheckProviderRequest request = PermissionCheckProviderRequest.createGet(ExternalSchemes.bloombergEmrsUserId(EMRS_USER_ID), IP_ADDRESS, EID_27749, EID_35009, EID_39491, EID_40066, EID_41095, EID_46707, EID_1234); PermissionCheckProviderResult resultHolder = _provider.isPermitted(request); assertNotNull(resultHolder); resultHolder.checkErrors(); assertNotNull(resultHolder.getCheckedPermissions()); Map<String, Boolean> checkPermissionResult = resultHolder.getCheckedPermissions(); assertEquals(7, checkPermissionResult.size()); assertTrue(checkPermissionResult.get(EID_27749)); assertTrue(checkPermissionResult.get(EID_35009)); assertTrue(checkPermissionResult.get(EID_39491)); assertTrue(checkPermissionResult.get(EID_40066)); assertTrue(checkPermissionResult.get(EID_41095)); assertTrue(checkPermissionResult.get(EID_46707)); assertFalse(checkPermissionResult.get(EID_1234)); try { Thread.sleep(120000); } catch (InterruptedException ex) { ex.printStackTrace(); } resultHolder = _provider.isPermitted(request); assertNotNull(resultHolder); resultHolder.checkErrors(); assertNotNull(resultHolder.getCheckedPermissions()); checkPermissionResult = resultHolder.getCheckedPermissions(); assertEquals(7, checkPermissionResult.size()); assertFalse(checkPermissionResult.get(EID_27749)); assertFalse(checkPermissionResult.get(EID_35009)); assertFalse(checkPermissionResult.get(EID_39491)); assertFalse(checkPermissionResult.get(EID_40066)); assertFalse(checkPermissionResult.get(EID_41095)); assertFalse(checkPermissionResult.get(EID_46707)); assertFalse(checkPermissionResult.get(EID_1234)); }