release version 1.10.0

This commit is contained in:
2024-12-14 04:07:49 +03:00
parent a5088587f7
commit c6b3d793c4
1916 changed files with 254306 additions and 0 deletions

View File

@ -0,0 +1,166 @@
/*-
* ~~~~~~licensing~~~~~~
* jaas-runtime
* ==========
* 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.platform.runtime.modules.unifrom_service.service;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map.Entry;
import org.apache.felix.utils.properties.Properties;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.component.annotations.ReferencePolicyOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.runtime.core.initializer.api.AbstractStandaloneInitializer;
import ru.entaxy.esb.platform.runtime.core.initializer.api.Initialized;
import ru.entaxy.esb.platform.runtime.core.initializer.api.StandaloneInitializer;
import ru.entaxy.platform.core.artifact.Artifact;
import ru.entaxy.platform.core.artifact.ArtifactCoordinates;
import ru.entaxy.platform.core.artifact.Artifacts;
import ru.entaxy.platform.core.artifact.DeployedArtifact;
import ru.entaxy.platform.core.artifact.installer.builder.InstallationResult;
import ru.entaxy.platform.core.artifact.installer.builder.Installer;
import ru.entaxy.platform.core.artifact.installer.builder.typed.CommonBundleInstaller;
import ru.entaxy.platform.core.artifact.repository.impl.DeployedArtifactImpl;
import ru.entaxy.platform.core.artifact.service.ArtifactService;
@Deprecated(since = "1.10", forRemoval = true)
@StandaloneInitializer(id = "uniform-service")
// @Component(service = UniformServiceInitializer.class, immediate = true)
public class UniformServiceInitializer extends AbstractStandaloneInitializer {
private static final Logger log = LoggerFactory.getLogger(UniformServiceInitializer.class);
private final static int REPEAT_COUNT = 5;
private final static int INTERVAL = 15000;
public static final String PATH_SUFFIX = "init/install/uniform-service.properties";
@Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY, target = "(id=artifacts)")
volatile Initialized artifactsInitializerReady;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
ArtifactService artifactService;
@Activate
public void activate(ComponentContext componentContext) {
setBundleContext(componentContext.getBundleContext());
Path configPath = Paths.get(System.getProperty("karaf.etc"), PATH_SUFFIX);
File configFile = configPath.toFile();
if (!configFile.exists())
return;
try {
Properties properties = new Properties(configFile);
for (Entry<String, String> entry : properties.entrySet()) {
String url = entry.getKey();
String paramsData = entry.getValue();
InstallationParams params = InstallationParams.parse(paramsData);
Artifact artifact = Artifacts.create(params.artifactCategory);
artifact.getCoordinates().set(ArtifactCoordinates.fromUrl(url));
DeployedArtifact depoyedArtifact = new DeployedArtifactImpl(artifact, "mvn:" + url);
Installer<?> installer = params.installShared ? artifactService.installers().cluster()
: artifactService.installers().local();
installer.artifact(depoyedArtifact);
CommonBundleInstaller bundleInstaller = installer.typed(CommonBundleInstaller.class);
InstallationResult result = null;
for (int i = 0; i < REPEAT_COUNT; i++) {
result = bundleInstaller.installOnlyIfMissing().start().startLevel(params.startLevel).install();
if (result != null && result.isSuccessful())
break;
try {
Thread.sleep(INTERVAL);
} catch (InterruptedException e) {
log.trace(e.getMessage());
}
}
if (result != null && result.isSuccessful())
log.info("Installed successfully: [{}]", url);
else {
log.error("Installation failed: [{}] :: {}", url,
result == null ? "Result is null" : result.getMessage());
if (result != null && result.getError() != null) {
log.error("DETAILS:", result.getError());
}
}
}
} catch (IOException e) {
log.error("Error processing properties", e);
}
}
protected static class InstallationParams {
protected static final String SHARED_TARGET = "shared";
public static InstallationParams parse(String data) {
InstallationParams result = new InstallationParams();
String[] values = data.split(";");
result.installShared = values[0].equals(SHARED_TARGET);
if (values.length > 1)
result.artifactCategory = values[1].trim();
if (values.length > 2)
try {
result.startLevel = Integer.parseInt(values[2].trim());
} catch (Exception ignore) {
}
return result;
}
boolean installShared = true;
String artifactCategory = "jar";
int startLevel = 100;
}
}

View File

@ -0,0 +1,154 @@
{
"factory": {
"id": "uniform-based-soap-service-protected",
"displayName": "SOAP :: UNIFORM :: PROTECTED",
"type": "entaxy.runtime.service",
"description": "Uniform SOAP service",
"isAbstract": false,
"isInternal": true,
"parent": "wsdl-based-soap-service-protected",
"label": "service,soap,uniform",
"category": ""
},
"entaxy.runtime.service": {},
"fields": {
"operationRouter": {
"source": "schemas/uniform-service/operationRouterProtected.xml",
"defaultValue": {
"@RESOURCE": {
"location": {
"@CALCULATED": {
"lazy": false,
"expression": "schemas/uniform-service/operationRouterProtected.xml"
}
}
}
},
"@TYPEINFO": {
"location": "schemas/uniform-service/operationRouterProtected.xml"
}
},
"##headers": {
"type": "List",
"required": false,
"isHidden": true,
"defaultValue": [
{
"name": "Entaxy-Dynamic-Factory-Provider",
"type": "boolean",
"value": false
}
]
}
},
"outputs": {
"init": {
"isDefault": true,
"generator": "",
"config": {
"configurable": false
},
"fields": {
"operationRouter": {
"source": "schemas/uniform-service/operationRouterProtected.xml",
"defaultValue": {
"@RESOURCE": {
"location": {
"@CALCULATED": {
"lazy": false,
"expression": "schemas/uniform-service/operationRouterProtected.xml"
}
}
}
},
"@TYPEINFO": {
"location": "schemas/uniform-service/operationRouterProtected.xml"
},
"immutable": true
},
"connectorInFactory": {
"required": false
},
"objectId": {
"immutable": true,
"defaultValue": "uniform-passive-service",
"fixedValue": "uniform-passive-service"
},
"address": {
"immutable": true,
"defaultValue": "uniform-exchange",
"fixedValue": "uniform-exchange"
},
"serviceFullName": {
"immutable": true
},
"port": {
"immutable": true
},
"dataFormat": {
"immutable": true
},
"displayServiceSchema": {
"defaultValue": true,
"fixedValue": true,
"immutable": true
},
"mtomEnabled": {
"immutable": true,
"defaultValue": false,
"fixedValue": false
},
"schemaValidationEnabled": {
"immutable": true,
"defaultValue": false
},
"_serviceMetadata": {
"immutable": true
},
"serviceName": {
"immutable": true
},
"serviceNamespace": {
"immutable": true
},
"authorizationType": {
"defaultValue": "JAAS"
},
"schemaUrl": {
"immutable": true,
"defaultValue": "schemas:uniform-service/soap-passive.wsdl",
"fixedValue": "schemas:uniform-service/soap-passive.wsdl"
},
"connectorDispatchingBeans": {
"defaultValue": {
"factoryId": "uniform-based-soap-service-protected"
}
},
"@IMPORT": [
{
"sourceFactoryId": "service-components",
"location": "outputs.specificProtectedServiceComponents.fields",
"prefix": ""
}
],
"##headers": {
"required": false
}
}
},
"connectorDispatchingBeans": {
"scopes": [
"private"
],
"fields": {
"serviceId": {
"type": "String"
}
},
"config": {
"configurable": false,
"@SKIP_PUBLISH": {}
}
}
}
}

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<route>
<from uri="direct:uniform-passive-service-operation-router"/>
<choice>
<when>
<simple>${headers.operationName} == 'PutPackets'</simple>
<log loggingLevel="DEBUG"
message="${headers.NTX_loggingKey} Called operation: ${headers.operationName} with message-type: ${header.message-type}"/>
<log loggingLevel="DEBUG" message="${headers.NTX_loggingKey} Sending to connector: in"/>
<log loggingLevel="TRACE" message="${headers.NTX_loggingKey} Body: ${body}"/>
<to uri="bean:uniform-passive-service-in-connector-registry?method=inConnectorFind"/>
<choice>
<when>
<simple>${headers.NTX_targetConnector} != null</simple>
<setProperty name="NTX_TMP_targetConnector">
<simple>${headers.NTX_targetConnector}</simple>
</setProperty>
<removeHeader headerName="NTX_targetConnector"/>
<toD uri="${exchangeProperty.NTX_TMP_targetConnector}"/>
</when>
<otherwise>
<log message="${headers.NTX_loggingKey} Connector not found: service=uniform-service; profile=${headers[X-SystemName]}; direction=in"
loggingLevel="ERROR"/>
<throwException
exceptionType="ru.entaxy.platform.services.runtime.exceptions.ConnectorNotFound"
message="Connector not found: service=uniform-service; profile=${headers[X-SystemName]}; direction=in"/>
</otherwise>
</choice>
</when>
<when>
<simple>${headers.operationName} == 'ConfirmGettingPackets'</simple>
<log loggingLevel="DEBUG"
message="${headers.NTX_loggingKey} Called operation: ${headers.operationName}"/>
<log loggingLevel="DEBUG" message="${headers.NTX_loggingKey} Sending to connector: out"/>
<to uri="bean:uniform-passive-service-out-connector-registry?method=outConnectorFind"/>
<choice>
<when>
<simple>${headers.NTX_targetConnector} != null</simple>
<setProperty name="NTX_TMP_targetConnector">
<simple>${headers.NTX_targetConnector}</simple>
</setProperty>
<removeHeader headerName="NTX_targetConnector"/>
<toD uri="${exchangeProperty.NTX_TMP_targetConnector}"/>
</when>
<otherwise>
<log message="${headers.NTX_loggingKey} Connector not found: service=uniform-service; profile=${headers[X-SystemName]}; direction=out"
loggingLevel="ERROR"/>
<throwException
exceptionType="ru.entaxy.platform.services.runtime.exceptions.ConnectorNotFound"
message="Connector not found: service=uniform-service; profile=${headers[X-SystemName]}; direction=out"/>
</otherwise>
</choice>
</when>
<when>
<simple>${headers.operationName} == 'GetPackets'</simple>
<log loggingLevel="DEBUG"
message="${headers.NTX_loggingKey} Called operation: ${headers.operationName}"/>
<log loggingLevel="DEBUG" message="${headers.NTX_loggingKey} Sending to connector: out"/>
<to uri="bean:uniform-passive-service-out-connector-registry?method=outConnectorFind"/>
<choice>
<when>
<simple>${headers.NTX_targetConnector} != null</simple>
<setProperty name="NTX_TMP_targetConnector">
<simple>${headers.NTX_targetConnector}</simple>
</setProperty>
<removeHeader headerName="NTX_targetConnector"/>
<toD uri="${exchangeProperty.NTX_TMP_targetConnector}"/>
</when>
<otherwise>
<log message="${headers.NTX_loggingKey} Connector not found: service=uniform-service; profile=${headers[X-SystemName]}; direction=out"
loggingLevel="ERROR"/>
<throwException
exceptionType="ru.entaxy.platform.services.runtime.exceptions.ConnectorNotFound"
message="Connector not found: service=uniform-service; profile=${headers[X-SystemName]}; direction=out"/>
</otherwise>
</choice>
</when>
<otherwise>
<log message="${headers.NTX_loggingKey} Uniform service operation ${header.operationName} isn't support"
loggingLevel="ERROR"/>
<throwException exceptionType="java.lang.IllegalArgumentException"
message="Uniform service operation ${header.operationName} isn't support"/>
</otherwise>
</choice>
</route>

View File

@ -0,0 +1,30 @@
[#ftl attributes={"generated.type":"blueprint.fragment"}]
<bean id="[=serviceId]-in-connector-registry"
class="ru.entaxy.platform.services.runtime.impl.EntaxyServiceConnectorRegistry" activation="eager">
<property name="profileNameHeaders">
<list value-type="java.lang.String">
<value>X-SystemName</value>
</list>
</property>
</bean>
<reference-list interface="ru.entaxy.platform.services.runtime.EntaxyServiceConnectorInfo"
filter="(service=uniform-service-in)" availability="optional">
<reference-listener ref="[=serviceId]-in-connector-registry"
bind-method="register" unbind-method="unregister"/>
</reference-list>
<bean id="[=serviceId]-out-connector-registry"
class="ru.entaxy.platform.services.runtime.impl.EntaxyServiceConnectorRegistry" activation="eager">
<property name="profileNameHeaders">
<list value-type="java.lang.String">
<value>X-SystemName</value>
</list>
</property>
</bean>
<reference-list id="connectorOutList"
interface="ru.entaxy.platform.services.runtime.EntaxyServiceConnectorInfo"
filter="(service=uniform-service-out)" availability="optional">
<reference-listener ref="[=serviceId]-out-connector-registry"
bind-method="register" unbind-method="unregister"/>
</reference-list>

View File

@ -0,0 +1,108 @@
[#ftl attributes={"generated.type":"blueprint"}]
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:cxf="http://cxf.apache.org/blueprint/core"
xmlns:[=objectId]="[=properties.serviceNamespace]"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!-- xmlns:soap-type="http://www.entaxy.ru/ExchangeTypes/1.0" -->
<!--
factoryId: wsdl-based-soap-service-public
factoryType: entaxy.runtime.service
outputType: init
properties:
[#list properties?keys as key]
[=key]
[/#list]
-->
<camelcxf:cxfEndpoint id="[=objectId]-cxf-endpoint"
address="/[=properties.address]"
endpointName="[=objectId]:[=properties.port]"
serviceName="[=objectId]:[=properties.serviceName]"
wsdlURL="entaxy-resource://[=properties.schemaUrl?replace(":", "/")]">
<camelcxf:properties>
<entry key="dataFormat" value="[=properties.dataFormat]"/>
<entry key="mtom-enabled" value="[=properties.mtomEnabled?c]"/>
<entry key="schema-validation-enabled" value="[=properties.schemaValidationEnabled?c]"/>
</camelcxf:properties>
<camelcxf:inInterceptors>
[#if properties.authorizationType == "JAAS"]
<ref component-id="jaasLoginInterceptor" />
[#if properties.restrictByRoles]
<ref component-id="simpleAuthorizingInterceptor" />
[/#if]
<ref component-id="resolveProfileNameInterceptor" />
<ref component-id="resolveLoginInterceptor"/>
[#if properties.displayServiceSchema]
<!-- ref component-id="isSchemaDisplayInterceptor" / -->
[#else]
<ref component-id="disableWSDLGetInterceptor" />
<ref component-id="postAuthWsdlGetInterceptor" />
[/#if]
[/#if]
<ref component-id="validator"/>
</camelcxf:inInterceptors>
</camelcxf:cxfEndpoint>
<bean id="validator" class="ru.entaxy.platform.services.runtime.interceptor.SOAPValidateInterceptor">
<property name="schemaValidationEnabled" value="[=properties.schemaValidationEnabled?c]"/>
</bean>
[#if properties.authorizationType == "JAAS"]
<bean id="jaasLoginInterceptor" class="org.apache.cxf.interceptor.security.JAASLoginInterceptor">
<property name="contextName" value="[=properties.authorizationRealm]" />
<property name="roleClassifier" value="RolePrincipal"/>
<property name="roleClassifierType" value="classname"/>
<property name="allowAnonymous" value="false"/>
<property name="allowNamedPrincipals" value="true"/>
</bean>
<bean id="resolveProfileNameInterceptor" class="ru.entaxy.platform.services.runtime.interceptor.ResolveProfileNameInterceptor">
</bean>
<bean id="resolveLoginInterceptor" class="ru.entaxy.platform.services.runtime.interceptor.ResolveLoginInterceptor" />
[#if properties.restrictByRoles]
<bean id="simpleAuthorizingInterceptor" class="org.apache.cxf.interceptor.security.SimpleAuthorizingInterceptor">
<property name="methodRolesMap">
<map>
<!-- NOT IMPLEMENTED YET -->
<!-- no wildcard support, names need to match exactly -->
<!-- entry key="addNumbers" value="ROLE_USER ROLE_ADMIN"/>
<entry key="divideNumbers" value="ROLE_ADMIN"/ -->
</map>
</property>
<!-- its possible to define global roles that apply to all WSDL operations not listed above -->
<property name="globalRoles" value="[=properties.globalRoles]"/>
</bean>
[/#if]
[#if properties.displayServiceSchema]
<!-- bean id="isSchemaDisplayInterceptor" class="ru.entaxy.platform.services.runtime.interceptor.IsSchemaDisplayInterceptor">
<property name="isDisplayServiceSchema" value="[=displayServiceSchema?c]"/>
</bean -->
[#else]
<bean id="postAuthWsdlGetInterceptor" class="ru.entaxy.platform.services.runtime.interceptor.PostAuthWSDLGetInterceptor">
</bean>
<bean id="disableWSDLGetInterceptor" class="ru.entaxy.platform.services.runtime.interceptor.DisableWSDLGetInterceptor">
</bean>
[/#if]
[/#if]
[#import "templates:object-commons/common-utils.ftl" as utils]
<camelContext id="[=objectId]" xmlns="http://camel.apache.org/schema/blueprint">
<route id="[=objectId]-cxf-endpoint" streamCache="true">
<from uri="cxf:bean:[=objectId]-cxf-endpoint"/>
<setHeader name="ENTAXY_EndpointName">
<simple>[=objectId]</simple>
</setHeader>
[#include "templates:service-components/generateLoggingKey.ftl"]
<to uri="direct:[=objectId]-operation-router" />
<removeProperties pattern="NTX.+|ENTAXY.+"/>
<removeHeaders pattern="NTX.+|ENTAXY.+"/>
</route>
</camelContext>
</blueprint>