Example usage for org.apache.wicket.authorization Action toString

List of usage examples for org.apache.wicket.authorization Action toString

Introduction

In this page you can find the example usage for org.apache.wicket.authorization Action toString.

Prototype

@Override
public final String toString() 

Source Link

Usage

From source file:org.openengsb.ui.common.DomainAuthorizationStrategy.java

License:Apache License

@Override
public boolean isActionAuthorized(Component arg0, Action arg1) {
    List<SecurityAttributeEntry> attributeList = Lists.newArrayList();
    if (hasSecurityAnnotation(arg0.getClass())) {
        attributeList.addAll(getSecurityAttributes(arg0.getClass()));
    }/* w w  w.jav a 2 s . c om*/

    LOGGER.info(ArrayUtils.toString(attributeProviders.getClass().getInterfaces()));

    for (SecurityAttributeProvider p : attributeProviders) {
        Collection<SecurityAttributeEntry> runtimeAttributes = p.getAttribute(arg0);
        if (runtimeAttributes != null) {
            attributeList.addAll(runtimeAttributes);
        }
    }

    if (attributeList.isEmpty()) {
        return true;
    }

    String user = getAuthenticatedUser();
    if (user == null) {
        return false;
    }
    UIAction secureAction = new UIAction(attributeList, arg1.getName(),
            ImmutableMap.of("component", (Object) arg0));

    Access checkAccess = authorizer.checkAccess(user, secureAction);
    if (checkAccess != Access.GRANTED) {
        LOGGER.warn("User {} was denied action {} on component {}",
                new Object[] { user, arg1.toString(), arg0.getClass().getName() });
    }
    return checkAccess == Access.GRANTED;
}