Example usage for org.springframework.security.access SecurityConfig createListFromCommaDelimitedString

List of usage examples for org.springframework.security.access SecurityConfig createListFromCommaDelimitedString

Introduction

In this page you can find the example usage for org.springframework.security.access SecurityConfig createListFromCommaDelimitedString.

Prototype

public static List<ConfigAttribute> createListFromCommaDelimitedString(String access) 

Source Link

Usage

From source file:com.xyz.system.service.impl.DefinitionSourceFactoryBean.java

/**
 * resourceDetailService??LinkedHashMap<String, String>?URL??
 * DefaultFilterInvocationDefinitionSource?LinkedHashMap<RequestKey, ConfigAttributeDefinition>?.
 *//*w w w. j a  v a  2 s  .  c o  m*/
protected LinkedHashMap<RequestKey, Collection<ConfigAttribute>> buildRequestMap() throws Exception {
    LinkedHashMap<String, String> srcMap = securityManager.getRequestMap();
    LinkedHashMap<RequestKey, Collection<ConfigAttribute>> distMap = new LinkedHashMap<RequestKey, Collection<ConfigAttribute>>();

    for (Map.Entry<String, String> entry : srcMap.entrySet()) {
        RequestKey key = new RequestKey(entry.getKey(), null);
        if (StringUtils.isNotBlank(entry.getValue())) {
            distMap.put(key, SecurityConfig.createListFromCommaDelimitedString(entry.getValue()));
        }
    }

    return distMap;
}

From source file:com.beto.test.securityinterceptor.security.CustomFilterInvocationSecurityMetadataSource.java

@Override
public Collection<ConfigAttribute> getAttributes(Object object) {
    LOOGER.debug("CustomFilterInvocationSecurityMetadataSource.getAttributes() method called...");
    FilterInvocation fi = (FilterInvocation) object;

    String url = fi.getRequestUrl();

    String urlPropsValue = null;//from   ww w. j  ava2  s . c  o m

    if (url.contains(".jsf")) {
        int lastSlashIndex = url.lastIndexOf(".jsf");
        url = url.substring(0, lastSlashIndex);
    }

    if (!StringUtils.isEmpty(url) && (url.startsWith("/css/") || url.startsWith("/img/")
            || url.startsWith("/assets/") || url.startsWith("/js/") || url.startsWith("/resources/"))) {
        return null;
    }

    urlPropsValue = getRole(url);

    String attr = "";
    if (urlPropsValue != null) {
        attr = addAttr(urlPropsValue, attr);
    }

    if (!url.endsWith("/")) {
        int lastSlashIndex = url.lastIndexOf("/");
        url = url.substring(0, lastSlashIndex + 1);
    }

    /**
     * Dorudan url'e atanm bir role tanm yoksa dizin role
     * atamalar var m diye kontrol et
     */
    if (attr == null || attr.equals("")) {
        attr = getUrlHigherDirectoryRoles(url, attr, urlPropsValue);
    }

    LOOGER.debug("getAttributes [Tespit Edilen Roller : " + attr + "]");

    if (attr.length() == 0) {
        // throw new
        // org.springframework.security.access.AccessDeniedException("Eriim Hatas");
        return null;
    }
    return SecurityConfig.createListFromCommaDelimitedString(attr);
}

From source file:com.rockagen.gnext.service.spring.security.extension.JdbcFilterInvocationSecurityMetadataSourceFactoryBean.java

/**
 * Builds the request map./* w  w  w  .  j  ava2 s.c om*/
 * <p>return LinkedHashMap&lt; {@link RequestMatcher}, Collection&lt; {@link ConfigAttribute}&gt;&gt </p>
 * 
 * @return requestMap order-preserving map of request definitions to attribute lists
 */
protected LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> buildRequestMap() {
    LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = new LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>>();

    Map<String, String> resourceMap = findResources();

    for (Map.Entry<String, String> entry : resourceMap.entrySet()) {
        RequestMatcher key = new AntPathRequestMatcher(entry.getKey());
        requestMap.put(key, SecurityConfig.createListFromCommaDelimitedString(entry.getValue()));
    }

    return requestMap;
}