クラス ExpressionBasedMessageSecurityMetadataSourceFactory

java.lang.ObjectSE
org.springframework.security.messaging.access.expression.ExpressionBasedMessageSecurityMetadataSourceFactory

@DeprecatedSE public final class ExpressionBasedMessageSecurityMetadataSourceFactory extends ObjectSE
使用すべきではありません。
代わりに MessageMatcherDelegatingAuthorizationManager を使用してください
Spring 式にマップされた MessageMatcher を使用する MessageSecurityMetadataSource を作成するために使用されるクラス。
導入:
4.0
  • メソッドの詳細

    • createExpressionMessageMetadataSource

      public static MessageSecurityMetadataSource createExpressionMessageMetadataSource(LinkedHashMapSE<MessageMatcher<?>,StringSE> matcherToExpression)
      使用すべきではありません。
      Spring 式にマップされた MessageMatcher を使用する MessageSecurityMetadataSource を作成します。各エントリは順番に考慮され、最初に一致したものだけが使用されます。例:
           LinkedHashMap<MessageMatcher<?>,String> matcherToExpression = new LinkedHashMap<MessageMatcher<Object>,String>();
           matcherToExpression.put(new SimDestinationMessageMatcher("/public/**"), "permitAll");
           matcherToExpression.put(new SimDestinationMessageMatcher("/admin/**"), "hasRole('ROLE_ADMIN')");
           matcherToExpression.put(new SimDestinationMessageMatcher("/topics/{name}/**"), "@someBean.customLogic(authentication, #name)");
           matcherToExpression.put(new SimDestinationMessageMatcher("/**"), "authenticated");
      
           MessageSecurityMetadataSource metadataSource = createExpressionMessageMetadataSource(matcherToExpression);
       

      宛先が "/public/hello" の場合、"/public/**" と "/**" で一致します。ただし、"/public/**" は最初のエントリであるため、使用されるのは "/public/**" のみです。これは、"/public/hello" の宛先が "permitAll" にマップされることを意味します。

      式の完全なリストについては、MessageSecurityExpressionRoot を参照してください

      パラメーター:
      matcherToExpression - AbstractSecurityExpressionHandler.getExpressionParser() を使用して式に変換される文字列への MessageMatcher の順序付けられたマッピング
      戻り値:
      使用する MessageSecurityMetadataSource。null にはできません。
    • createExpressionMessageMetadataSource

      public static MessageSecurityMetadataSource createExpressionMessageMetadataSource(LinkedHashMapSE<MessageMatcher<?>,StringSE> matcherToExpression, SecurityExpressionHandler<org.springframework.messaging.Message<ObjectSE>> handler)
      使用すべきではありません。
      Spring 式にマップされた MessageMatcher を使用する MessageSecurityMetadataSource を作成します。各エントリは順番に考慮され、最初に一致したものだけが使用されます。例:
           LinkedHashMap<MessageMatcher<?>,String> matcherToExpression = new LinkedHashMap<MessageMatcher<Object>,String>();
           matcherToExpression.put(new SimDestinationMessageMatcher("/public/**"), "permitAll");
           matcherToExpression.put(new SimDestinationMessageMatcher("/admin/**"), "hasRole('ROLE_ADMIN')");
           matcherToExpression.put(new SimDestinationMessageMatcher("/topics/{name}/**"), "@someBean.customLogic(authentication, #name)");
           matcherToExpression.put(new SimDestinationMessageMatcher("/**"), "authenticated");
      
           MessageSecurityMetadataSource metadataSource = createExpressionMessageMetadataSource(matcherToExpression);
       

      宛先が "/public/hello" の場合、"/public/**" と "/**" で一致します。ただし、"/public/**" は最初のエントリであるため、使用されるのは "/public/**" のみです。これは、"/public/hello" の宛先が "permitAll" にマップされることを意味します。

      式の完全なリストについては、MessageSecurityExpressionRoot を参照してください

      パラメーター:
      matcherToExpression - AbstractSecurityExpressionHandler.getExpressionParser() を使用して式に変換される文字列への MessageMatcher の順序付けられたマッピング
      handler - 使用する SecurityExpressionHandler
      戻り値:
      使用する MessageSecurityMetadataSource。null にはできません。