IdentityProviderEndpoints implements ApplicationEventPublisherAware { @RequestMapping(method = GET) public ResponseEntity<List<IdentityProvider>> retrieveIdentityProviders(@RequestParam(value = "active_only", required = false) String activeOnly, @RequestParam(required = false, defaultValue = "false") boolean rawConfig) { boolean retrieveActiveOnly = Boolean.parseBoolean(activeOnly); List<IdentityProvider> identityProviderList = identityProviderProvisioning.retrieveAll(retrieveActiveOnly, identityZoneManager.getCurrentIdentityZoneId()); for(IdentityProvider idp : identityProviderList) { idp.setSerializeConfigRaw(rawConfig); redactSensitiveData(idp); } return new ResponseEntity<>(identityProviderList, OK); } IdentityProviderEndpoints(
            final @Qualifier("identityProviderProvisioning") IdentityProviderProvisioning identityProviderProvisioning,
            final @Qualifier("externalGroupMembershipManager") ScimGroupExternalMembershipManager scimGroupExternalMembershipManager,
            final @Qualifier("scimGroupProvisioning") ScimGroupProvisioning scimGroupProvisioning,
            final @Qualifier("metaDataProviders") SamlIdentityProviderConfigurator samlConfigurator,
            final @Qualifier("identityProviderConfigValidator") IdentityProviderConfigValidator configValidator,
            final IdentityZoneManager identityZoneManager); @Override void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher); @RequestMapping(method = POST) ResponseEntity<IdentityProvider> createIdentityProvider(@RequestBody IdentityProvider body, @RequestParam(required = false, defaultValue = "false") boolean rawConfig); @RequestMapping(value = "{id}", method = DELETE) @Transactional ResponseEntity<IdentityProvider> deleteIdentityProvider(@PathVariable String id, @RequestParam(required = false, defaultValue = "false") boolean rawConfig); @RequestMapping(value = "{id}", method = PUT) ResponseEntity<IdentityProvider> updateIdentityProvider(@PathVariable String id, @RequestBody IdentityProvider body, @RequestParam(required = false, defaultValue = "false") boolean rawConfig); @RequestMapping (value = "{id}/status", method = PATCH) ResponseEntity<IdentityProviderStatus> updateIdentityProviderStatus(@PathVariable String id, @RequestBody IdentityProviderStatus body); @RequestMapping(method = GET) ResponseEntity<List<IdentityProvider>> retrieveIdentityProviders(@RequestParam(value = "active_only", required = false) String activeOnly, @RequestParam(required = false, defaultValue = "false") boolean rawConfig); @RequestMapping(value = "{id}", method = GET) ResponseEntity<IdentityProvider> retrieveIdentityProvider(@PathVariable String id, @RequestParam(required = false, defaultValue = "false") boolean rawConfig); @RequestMapping(value = "test", method = POST) ResponseEntity<String> testIdentityProvider(@RequestBody IdentityProviderValidationRequest body); @ExceptionHandler(MetadataProviderException.class) ResponseEntity<String> handleMetadataProviderException(MetadataProviderException e); @ExceptionHandler(JsonUtils.JsonUtilException.class) ResponseEntity<String> handleMetadataProviderException(); @ExceptionHandler(EmptyResultDataAccessException.class) ResponseEntity<String> handleProviderNotFoundException();  }
@Test void retrieve_all_providers_redacts_data() { when(mockIdentityProviderProvisioning.retrieveAll(anyBoolean(), anyString())) .thenReturn(Arrays.asList(getLdapDefinition(), getExternalOAuthProvider())); ResponseEntity<List<IdentityProvider>> ldapList = identityProviderEndpoints.retrieveIdentityProviders("false", true); assertNotNull(ldapList); assertNotNull(ldapList.getBody()); assertEquals(2, ldapList.getBody().size()); IdentityProvider<LdapIdentityProviderDefinition> ldap = ldapList.getBody().get(0); assertNotNull(ldap); assertNotNull(ldap.getConfig()); assertTrue(ldap.getConfig() instanceof LdapIdentityProviderDefinition); assertNull(ldap.getConfig().getBindPassword()); IdentityProvider<AbstractExternalOAuthIdentityProviderDefinition> oauth = ldapList.getBody().get(1); assertNotNull(oauth); assertNotNull(oauth.getConfig()); assertTrue(oauth.getConfig() instanceof AbstractExternalOAuthIdentityProviderDefinition); assertNull(oauth.getConfig().getRelyingPartySecret()); }