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);
}
}
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]));
}
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;
}
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);
}
}
}
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);
}
Aggregations