Java Code Examples for org.springframework.security.access.SecurityMetadataSource

The following examples show how to use org.springframework.security.access.SecurityMetadataSource. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public SecurityMetadataSource obtainSecurityMetadataSource()
{
    SecurityMetadataSource definitionSource = definitionSourceTag.get();

    if ( definitionSource != null )
    {
        return definitionSource;
    }

    // ---------------------------------------------------------------------
    // ObjectDefinitionSource required, but we are not inside an
    // invocation. Returning an empty dummy.
    // ---------------------------------------------------------------------

    return new SingleSecurityMetadataSource( new ActionConfig.Builder( "", "", "" ).build() );
}
 
Example 2
Source Project: bdf3   Source File: SecurityDecisionManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Collection<ConfigAttribute> findConfigAttributes(Resource resource) {
	Collection<ConfigAttribute> attributes = resource.getAttributes();
	if (CollectionUtils.isEmpty(attributes)) {
		for (SecurityMetadataSource securityMetadataSource : securityMetadataSources) {
			if (securityMetadataSource.supports(resource.getClass())) {
				attributes = securityMetadataSource.getAttributes(resource);
			}
		}
	} 
	return attributes;
}
 
Example 3
@Override
public SecurityMetadataSource createSecurityMetadataSource( ActionConfig actionConfig, Object object )
{
    Collection<ConfigAttribute> attributes = new ArrayList<>();
    attributes.addAll( StrutsAuthorityUtils.getConfigAttributes( getRequiredAuthorities( actionConfig ) ) );
    attributes.addAll( StrutsAuthorityUtils.getConfigAttributes( globalAttributes ) );

    return new SingleSecurityMetadataSource( object, attributes );
}
 
Example 4
@Override
@SuppressWarnings("unchecked")
public Collection<ConfigAttribute> getAttributes(final Object object) throws IllegalArgumentException {
    Callback<SecurityMetadataSource> callback = () -> {
        HierarchicalConfiguration siteConfig = ConfigUtils.getCurrentConfig();
        if (siteConfig != null) {
            List<HierarchicalConfiguration> restrictionsConfig = siteConfig.configurationsAt(URL_RESTRICTION_KEY);
            if (CollectionUtils.isNotEmpty(restrictionsConfig)) {
                LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> map = new LinkedHashMap<>();
                for (HierarchicalConfiguration restrictionConfig : restrictionsConfig) {
                    String url = restrictionConfig.getString(URL_RESTRICTION_URL_KEY);
                    String expression = restrictionConfig.getString(URL_RESTRICTION_EXPRESSION_KEY);
                    if (StringUtils.isNotEmpty(url) && StringUtils.isNotEmpty(expression)) {
                        AntPathRequestMatcher matcher = new AntPathRequestMatcher(url);
                        map.put(matcher, singleton(new SecurityConfig(expression)));
                    }
                }
                return new ExpressionBasedFilterInvocationSecurityMetadataSource(map,
                    new DefaultWebSecurityExpressionHandler());
            }
        }
        return new DefaultFilterInvocationSecurityMetadataSource(new LinkedHashMap<>());
    };

    SiteContext siteContext = SiteContext.getCurrent();
    if (siteContext != null) {
        SecurityMetadataSource metadataSource =
            cacheTemplate.getObject(siteContext.getContext(), callback, URL_RESTRICTIONS_CACHE_KEY);

        return metadataSource.getAttributes(object);
    }
    return null;
}
 
Example 5
Source Project: spring-boot-demo   Source File: MyFilterSecurityInterceptor.java    License: MIT License 4 votes vote down vote up
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {

    return this.securityMetadataSource;
}
 
Example 6
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return this.securityMetadataSource;
}
 
Example 7
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return this.securityMetadataSource;
}
 
Example 8
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return this.securityMetadataSource;
}
 
Example 9
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return this.securityMetadataSource;
}
 
Example 10
Source Project: mall-swarm   Source File: DynamicSecurityFilter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return dynamicSecurityMetadataSource;
}
 
Example 11
Source Project: base-admin   Source File: DynamicallyUrlInterceptor.java    License: MIT License 4 votes vote down vote up
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return this.securityMetadataSource;
}
 
Example 12
@Override
public SecurityMetadataSource obtainSecurityMetadataSource(){
	return this.securityMetadataSource;
}
 
Example 13
Source Project: mall   Source File: DynamicSecurityFilter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return dynamicSecurityMetadataSource;
}
 
Example 14
Source Project: demo-project   Source File: MyFilterSecurityInterceptor.java    License: MIT License 4 votes vote down vote up
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return this.mySecurityMetadataSource;
}
 
Example 15
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return this.securityMetadataSource;
}
 
Example 16
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return this.securityMetadataSource;
}
 
Example 17
Source Project: Auth-service   Source File: CustomSecurityFilter.java    License: MIT License 4 votes vote down vote up
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return invocationSource;
}
 
Example 18
Source Project: itweet-boot   Source File: MyFilterSecurityInterceptor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return this.securityMetadataSource;
}
 
Example 19
Source Project: microservice-integration   Source File: CustomSecurityFilter.java    License: MIT License 4 votes vote down vote up
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return invocationSource;
}
 
Example 20
Source Project: bdf3   Source File: FilterSecurityInterceptor.java    License: Apache License 2.0 4 votes vote down vote up
public SecurityMetadataSource obtainSecurityMetadataSource() {
	return this.securityMetadataSource;
}
 
Example 21
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
    return this.securityMetadataSource;
}
 
Example 22
@Override
public SecurityMetadataSource createSecurityMetadataSource( ActionConfig actionConfig )
{
    return createSecurityMetadataSource( actionConfig, actionConfig );
}
 
Example 23
Source Project: maintain   Source File: MyFilterSecurityInterceptor.java    License: MIT License 4 votes vote down vote up
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
	return this.securityMetadataSource;
}
 
Example 24
Source Project: zxl   Source File: ResourceSecurityFilter.java    License: Apache License 2.0 4 votes vote down vote up
public SecurityMetadataSource obtainSecurityMetadataSource() {
	return this.securityMetadataSource;
}
 
Example 25
Source Project: hermes   Source File: SecurityFilter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
	return securityMetadataSource;
}
 
Example 26
/**
 * Creates an SecurityMetadataSource based on the required authorities for
 * the action config. The specified action config is set as the secure
 * object. The SecurityMetadataSource may include additional attributes if
 * needed.
 *
 * @param actionConfig the secure actionConfig to get required authorities
 *                     from.
 */
public SecurityMetadataSource createSecurityMetadataSource( ActionConfig actionConfig );
 
Example 27
/**
 * Creates an SecurityMetadataSource for a specified secure object based on
 * the required authorities for the action config. The
 * SecurityMetadataSource may include additional attributes if needed.
 *
 * @param actionConfig the actionConfig to get required authorities from.
 * @param object       the secure object.
 */
public SecurityMetadataSource createSecurityMetadataSource( ActionConfig actionConfig, Object object );
 
Example 28
Source Project: hermes   Source File: SecurityFilter.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 设置安全元数据
 * 
 * @param securityMetadataSource
 */
public void setSecurityMetadataSource(SecurityMetadataSource securityMetadataSource) {
	this.securityMetadataSource = securityMetadataSource;
}