release version 1.10.0
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* permission-handler
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.core.permission.handler;
|
||||
|
||||
public interface PermissionChecker {
|
||||
|
||||
public boolean check(int objectId, String objectType, String subjectId, String subjectType, String action);
|
||||
|
||||
public boolean check(int objectId, String objectType, String subjectId, String subjectType);
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* permission-handler
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.core.permission.handler;
|
||||
|
||||
import ru.entaxy.esb.system.core.permission.jpa.PermissionService;
|
||||
|
||||
public class PermissionCheckerImpl implements PermissionChecker {
|
||||
|
||||
private PermissionService permissionService;
|
||||
|
||||
public PermissionService getPermissionService() {
|
||||
return permissionService;
|
||||
}
|
||||
|
||||
public void setPermissionService(PermissionService permissionService) {
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
public boolean check(int objectId, String objectType, String subjectId, String subjectType, String action) {
|
||||
return permissionService.existByAllParameters(objectId, objectType, subjectId, subjectType, action);
|
||||
}
|
||||
|
||||
public boolean check(int objectId, String objectType, String subjectId, String subjectType) {
|
||||
return check(objectId, objectType, subjectId, subjectType, null);
|
||||
}
|
||||
}
|
@@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
permission-handler
|
||||
==========
|
||||
Copyright (C) 2020 - 2024 EmDev LLC
|
||||
==========
|
||||
You may not use this file except in accordance with the License Terms of the Copyright
|
||||
Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
Software for commercial purposes to provide services to third parties.
|
||||
|
||||
The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
Software provided by him will be suitable or not suitable for the specific purposes
|
||||
of the User, that the Software will meet all commercial and personal subjective
|
||||
expectations of the User, that the Software will work properly, without technical
|
||||
errors, quickly and uninterruptedly.
|
||||
|
||||
Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
or damage to data, property, etc.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
|
||||
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
|
||||
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
|
||||
|
||||
<cm:property-placeholder
|
||||
persistent-id="ru.entaxy.esb.system.permission.handler" update-strategy="reload">
|
||||
<cm:default-properties>
|
||||
<cm:property name="mode.dev" value="false"/>
|
||||
</cm:default-properties>
|
||||
</cm:property-placeholder>
|
||||
|
||||
<reference id="permissionService"
|
||||
interface="ru.entaxy.esb.system.core.permission.jpa.PermissionService"
|
||||
timeout="30000"
|
||||
availability="mandatory"/>
|
||||
|
||||
<service ref="permissionChecker"
|
||||
interface="ru.entaxy.esb.system.core.permission.handler.PermissionChecker"/>
|
||||
|
||||
<bean id="permissionChecker"
|
||||
class="ru.entaxy.esb.system.core.permission.handler.PermissionCheckerImpl">
|
||||
<property name="permissionService" ref="permissionService"/>
|
||||
</bean>
|
||||
|
||||
<camelContext id="permission-handler-context" xmlns="http://camel.apache.org/schema/blueprint">
|
||||
|
||||
<route id="test-permission" autoStartup="{{mode.dev}}">
|
||||
<from uri="timer:test-permission?period=60&repeatCount=1"/>
|
||||
|
||||
<to uri="bean:permissionService?method=add(1, 'system', '2', 'system', 'send')"/>
|
||||
<log message="CREATE PERMISSION RECORD ${body}"/>
|
||||
|
||||
<to uri="bean:permissionService?method=getByAllParameters(1, 'system', '2', 'system', 'send')"/>
|
||||
<log message="${body}"/>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${body} != null</simple>
|
||||
<log message="GET EXISTING RECORD: TEST PASSED"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<log message="GET EXISTING RECORD: TEST FAILED"/>
|
||||
</otherwise>
|
||||
</choice>
|
||||
|
||||
<doTry>
|
||||
<to uri="bean:permissionService?method=getByAllParameters(1, '4321', '4321', '4321', '4321')"/>
|
||||
<log message="GET NOT EXISTING RECORD: TEST FAILED"/>
|
||||
<doCatch>
|
||||
<exception>java.lang.Exception</exception>
|
||||
<log message="GET NOT EXISTING RECORD: TEST PASSED"/>
|
||||
</doCatch>
|
||||
</doTry>
|
||||
|
||||
<to uri="bean:permissionService?method=remove(1, 'system', '2', 'system', 'send')"/>
|
||||
|
||||
<log message="DELETE PERMISSION RECORD ${body}"/>
|
||||
</route>
|
||||
|
||||
<route id="test-permission-component" autoStartup="{{mode.dev}}">
|
||||
<from uri="timer:test-has-permission?period=60&repeatCount=1&delay=30000"/>
|
||||
|
||||
<toD uri="permission:create?objectId=2&objectType=system&subjectId=3&subjectType=system&action=default"/>
|
||||
<log message="Create"/>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${body} != null</simple>
|
||||
<log message="CREATE ${body}: TEST PASSED"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<log message="CREATE ${body}: TEST FAILED"/>
|
||||
</otherwise>
|
||||
</choice>
|
||||
|
||||
<toD uri="permission:check?objectId=2&objectType=system&subjectId=3&subjectType=system&action=default"/>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${body}</simple>
|
||||
<log message="CHECK ${body}: TEST PASSED"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<log message="CHECK ${body}: TEST FAILED"/>
|
||||
</otherwise>
|
||||
</choice>
|
||||
|
||||
<toD uri="permission:create?objectId=2&objectType=system&subjectId=4&subjectType=system&action=send"/>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${body} != null</simple>
|
||||
<log message="CREATE ${body}: TEST PASSED"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<log message="CREATE ${body}: TEST FAILED"/>
|
||||
</otherwise>
|
||||
</choice>
|
||||
|
||||
<toD uri="permission:check?objectId=2&objectType=system&subjectId=4&subjectType=system&action=send"/>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${body}</simple>
|
||||
<log message="CHECK ${body}: TEST PASSED"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<log message="CHECK ${body}: TEST FAILED"/>
|
||||
</otherwise>
|
||||
</choice>
|
||||
|
||||
<toD uri="permission:getByAllParams?objectId=2&objectType=system&subjectId=3&subjectType=system&action=default"/>
|
||||
<log message="getByAllParams objectId=2&objectType=system&subjectId=3&subjectType=system&action=default"/>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${body} != null</simple>
|
||||
<log message="GET ${body}: TEST PASSED"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<log message="GET ${body}: TEST FAILED"/>
|
||||
</otherwise>
|
||||
</choice>
|
||||
|
||||
|
||||
<toD uri="permission:delete?objectId=2&objectType=system&subjectId=3&subjectType=system&action=default"/>
|
||||
<log message="DELETE ${body}"/>
|
||||
|
||||
<toD uri="permission:delete?objectId=2&objectType=system&subjectId=4&subjectType=system&action=send"/>
|
||||
<log message="DELETE ${body}"/>
|
||||
|
||||
<toD uri="permission:check?objectId=2&objectType=system&subjectId=3&subjectType=system&action=default"/>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${body} == false</simple>
|
||||
<log message="CHECK DELETED ${body}: TEST PASSED"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<log message="CHECK DELETED ${body}: TEST FAILED"/>
|
||||
</otherwise>
|
||||
</choice>
|
||||
|
||||
<toD uri="permission:check?objectId=2&objectType=system&subjectId=4&subjectType=system&action=send"/>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${body} == false</simple>
|
||||
<log message="CHECK DELETED ${body}: TEST PASSED"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<log message="CHECK DELETED ${body}: TEST FAILED"/>
|
||||
</otherwise>
|
||||
</choice>
|
||||
|
||||
</route>
|
||||
|
||||
</camelContext>
|
||||
|
||||
</blueprint>
|
Reference in New Issue
Block a user