Example usage for org.springframework.security.acls.domain DefaultPermissionFactory DefaultPermissionFactory

List of usage examples for org.springframework.security.acls.domain DefaultPermissionFactory DefaultPermissionFactory

Introduction

In this page you can find the example usage for org.springframework.security.acls.domain DefaultPermissionFactory DefaultPermissionFactory.

Prototype

public DefaultPermissionFactory() 

Source Link

Document

Registers the Permission fields from the BasePermission class.

Usage

From source file:org.bremersee.common.spring.autoconfigure.AclCommonAutoConfiguration.java

@Bean
@ConditionalOnMissingBean({ PermissionFactory.class })
public PermissionFactory permissionFactory() {
    DefaultPermissionFactory impl = new DefaultPermissionFactory();
    LOG.info("Creating new 'PermissionFactory' ...");
    return impl;/*from   w  w w. jav  a 2 s .  c  o m*/
}

From source file:org.zkoss.spring.security.SecurityUtil.java

private static void initializeIfRequired() {
    if (_applicationContext != null) {
        return;/*from   ww  w . j  av a 2s  .  c o m*/
    }

    _applicationContext = SpringUtil.getApplicationContext();

    Map map = new HashMap();
    ApplicationContext context = _applicationContext;

    while (context != null) {
        map.putAll(context.getBeansOfType(AclService.class));
        context = context.getParent();
    }

    if (map.size() != 1) {
        throw new UiException(
                "Found incorrect number of AclService instances in application context - you must have only have one!");
    }

    _aclService = (AclService) map.values().iterator().next();

    map = _applicationContext.getBeansOfType(SidRetrievalStrategy.class);

    if (map.size() == 0) {
        _sidRetrievalStrategy = new SidRetrievalStrategyImpl();
    } else if (map.size() == 1) {
        _sidRetrievalStrategy = (SidRetrievalStrategy) map.values().iterator().next();
    } else {
        throw new UiException("Found incorrect number of SidRetrievalStrategy instances in application "
                + "context - you must have only have one!");
    }

    map = _applicationContext.getBeansOfType(ObjectIdentityRetrievalStrategy.class);

    if (map.size() == 0) {
        _objectIdentityRetrievalStrategy = new ObjectIdentityRetrievalStrategyImpl();
    } else if (map.size() == 1) {
        _objectIdentityRetrievalStrategy = (ObjectIdentityRetrievalStrategy) map.values().iterator().next();
    } else {
        throw new UiException("Found incorrect number of ObjectIdentityRetrievalStrategy instances in "
                + "application context - you must have only have one!");
    }

    map = _applicationContext.getBeansOfType(PermissionFactory.class);

    if (map.size() == 0) {
        permissionFactory = new DefaultPermissionFactory();
    } else if (map.size() == 1) {
        permissionFactory = (PermissionFactory) map.values().iterator().next();
    } else {
        throw new UiException("Found incorrect number of PermissionFactory instances in "
                + "application context - you must have only have one!");
    }
}