package Ġno . vy . traffic info . baseline . mic ronaut . system Ċ Ċ import Ġio . mic ronaut . context . annotation . Requires Ċ import Ġio . mic ronaut . context . env . Environment Ċ import Ġio . mic ronaut . http . HttpRequest Ċ import Ġio . mic ronaut . security . authentication . Authentication Provider Ċ import Ġio . mic ronaut . security . authentication . Authentication Request Ċ import Ġio . mic ronaut . security . authentication . Authentication Response Ċ import Ġorg . reactiv est ream s . Publisher Ċ import Ġorg . slf 4 j . Logger Ċ import Ġorg . slf 4 j . LoggerFactory Ċ import Ġreactor . core . publisher . Flux Ċ import Ġjak arta . inject . Singleton Ċ Ċ /** Ċ Ġ* ĠThis Ġis Ġa ĠMock ĠAuthentication ĠProvider Ġonly Ġused Ġduring Ġtests Ġand Ġas Ġan Ġexample Ġclass . Ċ Ġ* ĠIt Ġcontains Ġa Ġhard Ġcoded Ġtest Ġuser Ġwhich Ġyou Ġcan Ġadd Ġroles Ġto Ġwhen Ġdoing Ġlocal Ġdevelopment Ċ Ġ* Ġso Ġthat Ġyou Ġdont Ġneed Ġto Ġretrieve Ġtokens Ġto Ġaccess Ġyour Ġservice Ġon Ġlocalhost . Ċ Ġ* Ċ Ġ* ĠIn Ġthe Ġcloud Ġenv , Ġthis Ġclass Ġshould Ġnot Ġbe Ġused Ġat Ġall Ġbecause Ġinstead ĠOAuth Ġtokens Ċ Ġ* Ġfrom Ġthe ĠC ognito Ġservice Ġare Ġused Ġfor Ġuser Ġauthentication . Ċ Ġ*/ Ċ @ Singleton Ċ @ Requires ( env Ġ= Ġ[ Environment . TEST ]) Ċ class ĠUser Authentication Service Ġ: ĠAuthentication Provider Ġ{ ĊĠĠĠ Ġprivate Ġval Ġlog : ĠLogger Ġ= ĠLoggerFactory . getLogger ( User Authentication Service :: class . java ) ĊĠĠĠ Ġoverride Ġfun Ġauthenticate ( httpRequest : ĠHttpRequest < *> ?, Ġauthentication Request : ĠAuthentication Request < *, Ġ* >? ): ĠPublisher < Authentication Response > Ġ{ ĊĠĠĠĠĠĠĠ Ġlog . info (" authentication Ġrequest Ġfrom Ġuser : Ġ${ authentication Request ?. identity }") ĊĊĠĠĠĠĠĠĠ Ġif Ġ( authentication Request ?. identity Ġ== Ġ" user " Ġ&& Ġauthentication Request . secret Ġ== Ġ" password ") Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠFlux . just ( Authentication Response . success (" user ", ĠlistOf (" https :// services . traffic info . vy dev . io / baseline - mic ronaut / read "))) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn ĠFlux . just ( Authentication Response . failure ()) ĊĠĠĠ Ġ} Ċ }