2016-12-15 21 views
-1

スケジュールタスクで呼び出されたメソッド内に記録されているユーザー名にアクセスしたいので、問題があります。私は次のコードを持っています:スケジュールタスクでログに記録されたユーザーを取得する - Spring

public void updateCategorizedProdutcsFile() 
{ 
    Authentication authentication SecurityContextHolder.getContext().getAuthentication(); 

私はあなたに感謝します。

+1

リファレンスガイドにその上の全体[章](http://docs.spring.io/spring-security/site/docs/current/reference/html/concurrency.html)があります。 –

+0

WebアプリケーションまたはSpringベースのJavaアプリケーションがありますか? –

答えて

-1

これがうまくいきます。

public void updateCategorizedProdutcsFile() 
{ 
Authentication auth = SecurityContextHolder.getContext().getAuthentication(); 
     String name = auth.getName(); //get logged in username 
} 
+1

この場合、authはnullです。 – ATavares

関連する問題