Search in sources :

Example 1 with PageDescriptor

use of com.evolveum.midpoint.authentication.api.authorization.PageDescriptor in project midpoint by Evolveum.

the class DescriptorLoaderImpl method scanPackagesForPages.

private void scanPackagesForPages() throws InstantiationException, IllegalAccessException {
    Collection<Class<?>> classes = ClassPathUtil.scanClasses(PageDescriptor.class);
    for (Class<?> clazz : classes) {
        PageDescriptor descriptor = clazz.getAnnotation(PageDescriptor.class);
        if (descriptor == null) {
            continue;
        }
        loadActions(descriptor);
    }
}
Also used : PageDescriptor(com.evolveum.midpoint.authentication.api.authorization.PageDescriptor)

Example 2 with PageDescriptor

use of com.evolveum.midpoint.authentication.api.authorization.PageDescriptor in project midpoint by Evolveum.

the class SecurityUtils method isPageAuthorized.

public static boolean isPageAuthorized(Class<?> page) {
    if (page == null) {
        return false;
    }
    PageDescriptor descriptor = page.getAnnotation(PageDescriptor.class);
    if (descriptor == null) {
        return false;
    }
    AuthorizationAction[] actions = descriptor.action();
    List<String> list = new ArrayList<>();
    for (AuthorizationAction action : actions) {
        list.add(action.actionUri());
    }
    return WebComponentUtil.isAuthorized(list.toArray(new String[0]));
}
Also used : PageDescriptor(com.evolveum.midpoint.authentication.api.authorization.PageDescriptor) AuthorizationAction(com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction)

Example 3 with PageDescriptor

use of com.evolveum.midpoint.authentication.api.authorization.PageDescriptor in project midpoint by Evolveum.

the class SecurityUtils method getPageAuthorizations.

public static List<String> getPageAuthorizations(Class<?> page) {
    List<String> list = new ArrayList<>();
    if (page == null) {
        return list;
    }
    PageDescriptor descriptor = page.getAnnotation(PageDescriptor.class);
    if (descriptor == null) {
        return list;
    }
    AuthorizationAction[] actions = descriptor.action();
    for (AuthorizationAction action : actions) {
        list.add(action.actionUri());
    }
    return list;
}
Also used : PageDescriptor(com.evolveum.midpoint.authentication.api.authorization.PageDescriptor) AuthorizationAction(com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction)

Example 4 with PageDescriptor

use of com.evolveum.midpoint.authentication.api.authorization.PageDescriptor in project midpoint by Evolveum.

the class PageMounter method scanPackagesForPages.

private void scanPackagesForPages(MidPointApplication application) throws InstantiationException, IllegalAccessException {
    for (String pac : PACKAGES_TO_SCAN) {
        LOGGER.debug("Scanning package {} for page annotations", pac);
        Set<Class<?>> classes = ClassPathUtil.listClasses(pac);
        for (Class<?> clazz : classes) {
            if (!WebPage.class.isAssignableFrom(clazz)) {
                continue;
            }
            PageDescriptor descriptor = clazz.getAnnotation(PageDescriptor.class);
            if (descriptor == null) {
                continue;
            }
            mountPage(descriptor, clazz, application);
        }
    }
}
Also used : WebPage(org.apache.wicket.markup.html.WebPage) PageDescriptor(com.evolveum.midpoint.authentication.api.authorization.PageDescriptor)

Example 5 with PageDescriptor

use of com.evolveum.midpoint.authentication.api.authorization.PageDescriptor in project midpoint by Evolveum.

the class WebComponentUtil method isAuthorized.

public static boolean isAuthorized(Class<? extends ObjectType> clazz) {
    Class<? extends PageBase> detailsPage = getObjectDetailsPage(clazz);
    if (detailsPage == null) {
        return false;
    }
    PageDescriptor descriptor = detailsPage.getAnnotation(PageDescriptor.class);
    AuthorizationAction[] actions = descriptor.action();
    List<String> actionUris = new ArrayList<>();
    for (AuthorizationAction action : actions) {
        actionUris.add(action.actionUri());
    }
    return isAuthorized(actionUris);
}
Also used : PageDescriptor(com.evolveum.midpoint.authentication.api.authorization.PageDescriptor) AuthorizationAction(com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Aggregations

PageDescriptor (com.evolveum.midpoint.authentication.api.authorization.PageDescriptor)6 AuthorizationAction (com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 WebPage (org.apache.wicket.markup.html.WebPage)1