...
- Um UI-Komponente verrechten zu können, müssen als Vorraussetzung Datenquellen für Authentifizierung und Autorisierung in Ihrem Projekt vorhanden sein.
- Eine UI-Komponente kann auch mit mehreren Rechten verknüpft werden.
...
AuthorizationResources - Im Projekt Management > Business Objects wird diese Klasse angelegt, um die Rechte global zu verwalten.
Code Block language java theme Confluence package com.company.example.business; import com.xdev.security.authorization.Resource; import com.xdev.security.authorization.ResourceEnum; import com.xdev.security.authorization.ui.Authorization; /** * Central collection of all authorization resources used in the project. */ public enum AuthorizationResources implements ResourceEnum<AuthorizationResources> { CUSTOMERSAVE("CustomerSave") ; /** * Helper method to export all resource names. * <p> * Right click and select 'Run As' - 'Java Application' * </p> */ public static void main(String[] args) { for (AuthorizationResources value : AuthorizationResources.values()) { System.out.println(value.name); } } ///////////////////////////// // implementation details // /////////////////////////// private final String name; private Resource resource; private AuthorizationResources(final String name) { this.name = name; } @Override public String resourceName() { return this.name; } @Override public Resource resource() { if (this.resource == null) { this.resource = Authorization.resource(this.name); } return this.resource; } }
UI-Komponente - Die UI-Komponente wird mit dem Recht verknüpft.
Code Block language java theme Confluence /* * WARNING: Do NOT edit!<br>The content of this method is always regenerated * by the UI designer. */ // <generated-code name="initUI"> private void initUI() { this.button = new XdevButton(); this.button.setCaption("Save"); Authorization.setSubjectEvaluatingComponentExtension(this.button, SubjectEvaluatingComponentExtension.Builder .New().add(AuthorizationResources.CUSTOMERSAVE.resource(), SubjectEvaluationStrategy.ENABLED).build()); Authorization.evaluateComponents(this);
Benutzerrechte global verwalten