| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| * |
| * This copyright notice shows up in the generated Java code |
| * |
| */ |
| package org.eclipse.osbp.xtext.authorizationdsl.validation |
| |
| import com.google.inject.Inject |
| import org.eclipse.osbp.xtext.authorizationdsl.AuthorizationDSLPackage |
| import org.eclipse.osbp.xtext.authorizationdsl.Role |
| import org.eclipse.osbp.xtext.authorizationdsl.RoleBlipProcess |
| import org.eclipse.osbp.xtext.basic.validation.IBasicValidatorDelegate |
| import org.eclipse.xtext.validation.Check |
| import org.eclipse.osbp.ui.api.useraccess.IUserAccessService |
| |
| /** |
| * This class contains custom validation rules. |
| * |
| * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation |
| */ |
| class AuthorizationDSLValidator extends AbstractAuthorizationDSLValidator { |
| @Inject(optional=true) IBasicValidatorDelegate delegate |
| |
| @Check |
| def checkSecurityLicensed(Role role) { |
| if (IUserAccessService.ADMINISTRATOR.equals(role.name)) { |
| error('''The role '«IUserAccessService.ADMINISTRATOR»' is the already existing default role and its explicit definition is not allowed!''', role, null) |
| } else if(delegate !== null && !delegate.validateCommercial("authorization", "net.osbee.organization.permissions")) { |
| info('''Authorization is needed and not yet licensed. License Authorization at www.osbee.net''', role, null) |
| } |
| |
| } |
| |
| @Check |
| def checkBPMLicensed(RoleBlipProcess process) { |
| if(delegate !== null && !delegate.validateCommercial("authorization", "net.osbee.bpm")) { |
| info('''BPM is needed and not yet licensed. License BPM at www.osbee.net''', process, AuthorizationDSLPackage.Literals.ROLE_BLIP_PROCESS__PROCESS) |
| } |
| } |
| } |