private Mono < String > getTokenFromUri ( String uri ) { URL url = null ; try { url = new URL ( uri ) ; } catch ( MalformedURLException e ) { return Mono . error ( e ) ; } String host = String . format ( "%s://%s%s/" , url . getProtocol ( ) , url . getHost ( ) , url . getPort ( ) > 0 ? ":" + url . getPort ( ) : "" ) ; String resource = environment ( ) . managementEndpoint ( ) ; for ( Map . Entry < String , String > endpoint : environment ( ) . endpoints ( ) . entrySet ( ) ) { if ( host . contains ( endpoint . getValue ( ) ) ) { if ( endpoint . getKey ( ) . equals ( Endpoint . KEYVAULT . identifier ( ) ) ) { resource = String . format ( "https://%s/" , endpoint . getValue ( ) . replaceAll ( "^\\.*" , "" ) ) ; break ; } else if ( endpoint . getKey ( ) . equals ( Endpoint . GRAPH . identifier ( ) ) ) { resource = environment ( ) . graphEndpoint ( ) ; break ; } else if ( endpoint . getKey ( ) . equals ( Endpoint . LOG_ANALYTICS . identifier ( ) ) ) { resource = environment ( ) . logAnalyticsEndpoint ( ) ; break ; } else if ( endpoint . getKey ( ) . equals ( Endpoint . APPLICATION_INSIGHTS . identifier ( ) ) ) { resource = environment ( ) . applicationInsightsEndpoint ( ) ; break ; } else if ( endpoint . getKey ( ) . equals ( Endpoint . DATA_LAKE_STORE . identifier ( ) ) || endpoint . getKey ( ) . equals ( Endpoint . DATA_LAKE_ANALYTICS . identifier ( ) ) ) { resource = environment ( ) . dataLakeEndpointResourceId ( ) ; break ; } } } return getToken ( resource ) ; }
Gets the token from the given endpoint .