@Test public void simpDestMatchersAccess() { String expected = "hasRole('ROLE_ADMIN') and fullyAuthenticated"; messages.simpDestMatchers("admin/**", "location/**").access(expected) .anyMessage().denyAll(); assertThat(getAttribute()).isEqualTo(expected); }
/** * Specify that Messages are not allowed by anyone. * * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry denyAll() { return access(denyAll); }
/** * Specify that {@link Message} instances require a particular authority. * * @param authority the authority to require (i.e. ROLE_USER, ROLE_ADMIN, etc). * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry hasAuthority(String authority) { return access(MessageSecurityMetadataSourceRegistry.hasAuthority(authority)); }
/** * Specify that Messages are allowed by users who have authenticated and were not * "remembered". * * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization * @see RememberMeConfigurer */ public MessageSecurityMetadataSourceRegistry fullyAuthenticated() { return access(fullyAuthenticated); }
/** * Specify that Messages are allowed by any authenticated user. * * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry authenticated() { return access(authenticated); }
/** * Specify that Messages are allowed by users that have been remembered. * * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization * @see RememberMeConfigurer */ public MessageSecurityMetadataSourceRegistry rememberMe() { return access(rememberMe); }
/** * Specify that Messages are allowed by anyone. * * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry permitAll() { return access(permitAll); }
/** * Specify that {@link Message} instances requires any of a number authorities. * * @param authorities the requests require at least one of the authorities (i.e. * "ROLE_USER","ROLE_ADMIN" would mean either "ROLE_USER" or "ROLE_ADMIN" is * required). * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry hasAnyAuthority( String... authorities) { return access(MessageSecurityMetadataSourceRegistry .hasAnyAuthority(authorities)); }
/** * Shortcut for specifying {@link Message} instances require a particular role. If * you do not want to have "ROLE_" automatically inserted see * {@link #hasAuthority(String)}. * * @param role the role to require (i.e. USER, ADMIN, etc). Note, it should not * start with "ROLE_" as this is automatically inserted. * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry hasRole(String role) { return access(MessageSecurityMetadataSourceRegistry.hasRole(role)); }
/** * Shortcut for specifying {@link Message} instances require any of a number of * roles. If you do not want to have "ROLE_" automatically inserted see * {@link #hasAnyAuthority(String...)} * * @param roles the roles to require (i.e. USER, ADMIN, etc). Note, it should not * start with "ROLE_" as this is automatically inserted. * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry hasAnyRole(String... roles) { return access(MessageSecurityMetadataSourceRegistry.hasAnyRole(roles)); }
/** * Specify that Messages are not allowed by anyone. * * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry denyAll() { return access(denyAll); }
/** * Specify that {@link Message} instances require a particular authority. * * @param authority the authority to require (i.e. ROLE_USER, ROLE_ADMIN, etc). * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry hasAuthority(String authority) { return access(MessageSecurityMetadataSourceRegistry.hasAuthority(authority)); }
/** * Specify that Messages are allowed by anyone. * * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry permitAll() { return access(permitAll); }
/** * Specify that Messages are allowed by users who have authenticated and were not * "remembered". * * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization * @see RememberMeConfigurer */ public MessageSecurityMetadataSourceRegistry fullyAuthenticated() { return access(fullyAuthenticated); }
/** * Specify that Messages are allowed by any authenticated user. * * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry authenticated() { return access(authenticated); }
@Override protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) { messages .simpDestMatchers("/permitAll/**").permitAll() .simpDestMatchers("/customExpression/**").access("denyRob") .anyMessage().denyAll(); } // @formatter:on
@Override protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) { messages .anyMessage().access("denyRob()"); } // @formatter:on
/** * Specify that Messages are allowed by users that have been remembered. * * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization * @see RememberMeConfigurer */ public MessageSecurityMetadataSourceRegistry rememberMe() { return access(rememberMe); }
/** * Specify that Messages are allowed by anonymous users. * * @return the {@link MessageSecurityMetadataSourceRegistry} for further * customization */ public MessageSecurityMetadataSourceRegistry anonymous() { return access(anonymous); }
@Override protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) { messages .simpDestMatchers("/permitAll/**").permitAll() .simpDestMatchers("/beanResolver/**").access("@security.check()") .anyMessage().denyAll(); } // @formatter:on