package Ġcom . example . real world . service . implementation Ċ Ċ import Ġcom . example . real world . service . SecurityContext Service Ċ import Ġorg . springframework . security . core . Authentication Ċ import Ġorg . springframework . security . core . context . SecurityContext Ċ import Ġorg . springframework . security . core . context . SecurityContext Holder Ċ import Ġorg . springframework . security . core . user details . UserDetails Ċ import Ġorg . springframework . stereotype . Component Ċ Ċ @ Component Ċ class ĠSecurity Context ServiceImpl Ġ: ĠSecurity Context Service Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġset Authentication ( authentication : ĠAuthentication ) Ġ{ ĊĠĠĠĠĠĠĠ ĠgetContext (). authentication Ġ= Ġauthentication ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Principal (): ĠUser Details Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠgetContext (). authentication . principal Ġas ĠUser Details ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠgetContext (): ĠSecurity Context Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠSecurity Context Holder . getContext () ĊĠĠĠ Ġ} Ċ } Ċ