package Ġit . val er io va udi . v auth enticator . oauth 2 . client app Ċ Ċ import Ġit . val er io va udi . v auth enticator . extent ions .* Ċ import Ġorg . springframework . security . crypto . password . Password Encoder Ċ import Ġsoftware . amazon . aw ssdk . services . dynamodb . model . AttributeValue Ċ Ċ const Ġval Ġresource Id : ĠString Ġ= Ġ" oauth 2 - resource " Ċ Ċ object ĠD ynamo Client Application Converter Ġ{ ĊĊĠĠĠ Ġfun Ġfrom Domain To D ynamo ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclient App : ĠClient Application ĊĠĠĠ Ġ): ĠMutable Map < String , ĠAttribute Value > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġd ynamo Document Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" client _ id " Ġto Ġclient App . client AppId . content . as D ynamo Attribute (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" client _ secret " Ġto Ġclient App . secret . content . as D ynamo Attribute (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" resource _ ids " Ġto Ġresource Id . as D ynamo Attribute (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" scopes " Ġto Ġclient App . scopes . as D ynamo Attribute (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" authorized _ grant _ types " Ġto Ġclient App . authorized Grant Types . as D ynamo Attribute (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" web _ server _ redirect _ uri " Ġto Ġclient App . web Server Redirect Uri . content . as D ynamo Attribute (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" access _ token _ validity " Ġto Ġclient App . accessToken Validity . as D ynamo Attribute (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" refresh _ token _ validity " Ġto Ġclient App . refresh Token Validity . as D ynamo Attribute (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" auto _ approve " Ġto Ġclient App . auto Approve . content . as D ynamo Attribute (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" post _ logout _ redirect _ uris " Ġto Ġclient App . post Logout Redirect Uri . content . as D ynamo Attribute (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" logout _ uris " Ġto Ġclient App . logout Uri . content . as D ynamo Attribute () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġif Ġ( client App . author ities . content . isNotEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġd ynamo Document [" author ities "] Ġ= Ġclient App . author ities . as D ynamo Attribute () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġd ynamo Document ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġfrom D ynamo To Domain ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġd ynamo Payload : ĠMutable Map < String , ĠAttribute Value > ĊĠĠĠ Ġ): ĠClient Application Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠClient Application ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġclient AppId Ġ= ĠClient AppId ( d ynamo Payload . value AsString For (" client _ id ")), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsecret Ġ= ĠSecret ( d ynamo Payload . value AsString For (" client _ secret ")), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġresource Ids Ġ= ĠResource Ids ( listOf ( ResourceId ( d ynamo Payload . value AsString For (" resource _ ids ")) )), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġscopes Ġ= ĠS copes ( d ynamo Payload . values As ListOf String For (" scopes "). map Ġ{ ĠScope ( it ) Ġ}. toSet ()), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġauthorized Grant Types Ġ= ĠAuthor ized Grant Types ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġd ynamo Payload . values As ListOf String For (" authorized _ grant _ types ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġit . toUpperCase () Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠAuthor ized Grant Type . valueOf ( it ) Ġ}), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġweb Server Redirect Uri Ġ= ĠCallback Uri ( d ynamo Payload . value AsString For (" web _ server _ redirect _ uri ")), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġauthor ities Ġ= ĠAuthor ities ( d ynamo Payload . values As ListOf String For (" author ities "). map Ġ{ ĠAuthor ity ( it ) Ġ}), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠaccessToken Validity Ġ= ĠToken TimeTo Live ( d ynamo Payload . value As Int For (" access _ token _ validity ")), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrefresh Token Validity Ġ= ĠToken TimeTo Live ( d ynamo Payload . value As Int For (" refresh _ token _ validity ")), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġauto Approve Ġ= ĠAuto Approve ( d ynamo Payload . value As Bool For (" auto _ approve ")), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpost Logout Redirect Uri Ġ= ĠPost Logout Redirect Uri ( d ynamo Payload . value AsString For (" post _ logout _ redirect _ uris ")), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlogout Uri Ġ= ĠLogout Uri ( d ynamo Payload . value AsString For (" logout _ uris ")) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ Ċ }