protected void processMetadataInitialization ( HttpServletRequest request ) throws ServletException { // In case the hosted IdP metadata weren't initialized, let's do it now if ( manager . getHostedIdpName ( ) == null ) { synchronized ( IdpMetadataManager . class ) { if ( manager . getHostedIdpName ( ) == null ) { try { log . info ( "No default metadata configured, generating with default values, please pre-configure metadata for production use" ) ; // Defaults String alias = generator . getEntityAlias ( ) ; String baseURL = getDefaultBaseURL ( request ) ; // Use default baseURL if not set if ( generator . getEntityBaseURL ( ) == null ) { log . warn ( "Generated default entity base URL {} based on values in the first server request. Please set property entityBaseURL on MetadataGenerator bean to fixate the value." , baseURL ) ; generator . setEntityBaseURL ( baseURL ) ; } else { baseURL = generator . getEntityBaseURL ( ) ; } // Use default entityID if not set if ( generator . getEntityId ( ) == null ) { generator . setEntityId ( getDefaultEntityID ( baseURL , alias ) ) ; } // Ensure supported nameID formats in uaa are listed in the metadata Collection < String > supportedNameID = Arrays . asList ( NameIDType . EMAIL , NameIDType . PERSISTENT , NameIDType . UNSPECIFIED ) ; generator . setNameID ( supportedNameID ) ; EntityDescriptor descriptor = generator . generateMetadata ( ) ; ExtendedMetadata extendedMetadata = generator . generateExtendedMetadata ( ) ; log . info ( "Created default metadata for system with entityID: " + descriptor . getEntityID ( ) ) ; MetadataMemoryProvider memoryProvider = new MetadataMemoryProvider ( descriptor ) ; memoryProvider . initialize ( ) ; MetadataProvider metadataProvider = new ExtendedMetadataDelegate ( memoryProvider , extendedMetadata ) ; manager . addMetadataProvider ( metadataProvider ) ; manager . setHostedIdpName ( descriptor . getEntityID ( ) ) ; manager . refreshMetadata ( ) ; } catch ( MetadataProviderException e ) { log . error ( "Error generating system metadata" , e ) ; throw new ServletException ( "Error generating system metadata" , e ) ; } } } } }
Verifies whether generation is needed and if so the metadata document is created and stored in metadata manager .