public synchronized void validateSamlIdentityProviderDefinition ( SamlIdentityProviderDefinition providerDefinition ) throws MetadataProviderException { ExtendedMetadataDelegate added , deleted = null ; if ( providerDefinition == null ) { throw new NullPointerException ( ) ; } if ( ! hasText ( providerDefinition . getIdpEntityAlias ( ) ) ) { throw new NullPointerException ( "SAML IDP Alias must be set" ) ; } if ( ! hasText ( providerDefinition . getZoneId ( ) ) ) { throw new NullPointerException ( "IDP Zone Id must be set" ) ; } SamlIdentityProviderDefinition clone = providerDefinition . clone ( ) ; added = getExtendedMetadataDelegate ( clone ) ; String entityIDToBeAdded = ( ( ConfigMetadataProvider ) added . getDelegate ( ) ) . getEntityID ( ) ; if ( ! StringUtils . hasText ( entityIDToBeAdded ) ) { throw new MetadataProviderException ( "Emtpy entityID for SAML provider with zoneId:" + providerDefinition . getZoneId ( ) + " and origin:" + providerDefinition . getIdpEntityAlias ( ) ) ; } boolean entityIDexists = false ; for ( SamlIdentityProviderDefinition existing : getIdentityProviderDefinitions ( ) ) { ConfigMetadataProvider existingProvider = ( ConfigMetadataProvider ) getExtendedMetadataDelegate ( existing ) . getDelegate ( ) ; if ( entityIDToBeAdded . equals ( existingProvider . getEntityID ( ) ) && ! ( existing . getUniqueAlias ( ) . equals ( clone . getUniqueAlias ( ) ) ) ) { entityIDexists = true ; break ; } } if ( entityIDexists ) { throw new MetadataProviderException ( "Duplicate entity ID:" + entityIDToBeAdded ) ; } }
adds or replaces a SAML identity proviider