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

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

Introduction

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

Prototype

ObjectIdentityRetrievalStrategyImpl

Source Link

Usage

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

private static void initializeIfRequired() {
    if (_applicationContext != null) {
        return;/*from w w  w.  j  a va 2  s.  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!");
    }
}