IdentityProviderEndpoints implements ApplicationEventPublisherAware { protected void redactSensitiveData(IdentityProvider provider) { if (provider.getConfig() == null) { return; } switch (provider.getType()) { case LDAP: { if (provider.getConfig() instanceof LdapIdentityProviderDefinition) { logger.debug("Removing bind password from LDAP provider id:"+provider.getId()); LdapIdentityProviderDefinition definition = (LdapIdentityProviderDefinition) provider.getConfig(); definition.setBindPassword(null); } break; } case OAUTH20 : case OIDC10 : { if (provider.getConfig() instanceof AbstractExternalOAuthIdentityProviderDefinition) { logger.debug("Removing relying secret from OAuth/OIDC provider id:"+provider.getId()); AbstractExternalOAuthIdentityProviderDefinition definition = (AbstractExternalOAuthIdentityProviderDefinition) provider.getConfig(); definition.setRelyingPartySecret(null); } break; } default: break; } } 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 remove_client_secret_wrong_origin() { IdentityProvider provider = getExternalOAuthProvider(); AbstractExternalOAuthIdentityProviderDefinition spy = Mockito.spy((AbstractExternalOAuthIdentityProviderDefinition) provider.getConfig()); provider.setConfig(spy); provider.setType(UNKNOWN); identityProviderEndpoints.redactSensitiveData(provider); verify(spy, never()).setRelyingPartySecret(isNull()); }
@Test void remove_bind_password_non_ldap() { IdentityProvider provider = getLdapDefinition(); LdapIdentityProviderDefinition spy = Mockito.spy((LdapIdentityProviderDefinition) provider.getConfig()); provider.setConfig(spy); provider.setType(OriginKeys.UNKNOWN); identityProviderEndpoints.redactSensitiveData(provider); verify(spy, never()).setBindPassword(isNull()); }
@Test void patch_bind_password_non_ldap() { IdentityProvider provider = getLdapDefinition(); LdapIdentityProviderDefinition spy = Mockito.spy((LdapIdentityProviderDefinition) provider.getConfig()); provider.setConfig(spy); provider.setType(OriginKeys.UNKNOWN); identityProviderEndpoints.redactSensitiveData(provider); verify(spy, never()).setBindPassword(any()); }