クラス AuthenticationPrincipalArgumentResolver

java.lang.ObjectSE
org.springframework.security.web.bind.support.AuthenticationPrincipalArgumentResolver
実装済みのインターフェース一覧:
org.springframework.web.method.support.HandlerMethodArgumentResolver

@DeprecatedSE public final class AuthenticationPrincipalArgumentResolver extends ObjectSE implements org.springframework.web.method.support.HandlerMethodArgumentResolver
使用すべきではありません。
代わりに AuthenticationPrincipalArgumentResolver を使用してください。
AuthenticationPrincipal アノテーションを使用して Authentication.getPrincipal() を解決できます。例: 次の Controller:
@Controller
public class MyController {
    @RequestMapping("/user/current/show")
    public String show(@AuthenticationPrincipal CustomUser customUser) {
        // do something with CustomUser
        return "view";
    }
}

SecurityContextHolder から Authentication.getPrincipal() を使用して CustomUser 引数を解決します。Authentication または Authentication.getPrincipal() が null の場合、null が返されます。型が一致しない場合、AuthenticationPrincipal.errorOnInvalidType() が true でない限り null が返されます。true の場合は ClassCastExceptionSE がスローされます。

または、ユーザーは以下に示すようにカスタムメタアノテーションを作成できます。

@Target({ ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
@AuthenticationPrincipal
public @interface CurrentUser {
}

代わりにカスタムアノテーションを使用できます。例:

@Controller
public class MyController {
    @RequestMapping("/user/current/show")
    public String show(@CurrentUser CustomUser customUser) {
        // do something with CustomUser
        return "view";
    }
}
導入:
3.2
  • コンストラクター概要

    コンストラクター
    コンストラクター
    説明
    使用すべきではありません。
  • 方法の概要

    修飾子と型
    メソッド
    説明
    @Nullable ObjectSE
    resolveArgument(org.springframework.core.MethodParameter parameter, @Nullable org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest, @Nullable org.springframework.web.bind.support.WebDataBinderFactory binderFactory)
    使用すべきではありません。
    boolean
    supportsParameter(org.springframework.core.MethodParameter parameter)
    使用すべきではありません。

    クラス ObjectSE から継承されたメソッド

    clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSE
  • コンストラクターの詳細

    • AuthenticationPrincipalArgumentResolver

      public AuthenticationPrincipalArgumentResolver()
      使用すべきではありません。
  • 方法の詳細

    • supportsParameter

      public boolean supportsParameter(org.springframework.core.MethodParameter parameter)
      使用すべきではありません。
      次で指定:
      インターフェース org.springframework.web.method.support.HandlerMethodArgumentResolver 内の supportsParameter 
    • resolveArgument

      public @Nullable ObjectSE resolveArgument(org.springframework.core.MethodParameter parameter, @Nullable org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest, @Nullable org.springframework.web.bind.support.WebDataBinderFactory binderFactory)
      使用すべきではありません。
      次で指定:
      インターフェース org.springframework.web.method.support.HandlerMethodArgumentResolver 内の resolveArgument