initial public commit

This commit is contained in:
2021-09-06 17:46:59 +03:00
commit b744b08829
824 changed files with 91593 additions and 0 deletions

View File

@ -0,0 +1,39 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component;
import org.apache.camel.Endpoint;
import org.apache.camel.support.DefaultComponent;
import java.util.Map;
public class PermissionComponent extends DefaultComponent {
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
PermissionEndpoint endpoint = new PermissionEndpoint(uri, this);
endpoint.setOperation(remaining);
setProperties(endpoint, parameters);
return endpoint;
}
}

View File

@ -0,0 +1,132 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component;
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriPath;
import org.apache.camel.support.DefaultEndpoint;
@UriEndpoint(
scheme = "permission",
title = "Permission",
syntax = "permission:operation",
label = "custom",
producerOnly = true)
public class PermissionEndpoint extends DefaultEndpoint {
@UriPath
@Metadata(required = true)
private String operation;
@UriParam
private long permissionId;
@UriParam
private long objectId;
@UriParam
private String objectType;
@UriParam
private String subjectId;
@UriParam
private String subjectType;
@UriParam
private String action;
public PermissionEndpoint() {
}
public PermissionEndpoint(String uri, PermissionComponent component) {
super(uri, component);
}
public Producer createProducer() throws Exception {
return new PermissionProducer(this);
}
public Consumer createConsumer(Processor processor) throws Exception {
return null;
}
public boolean isSingleton() {
return true;
}
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation;
}
public long getPermissionId() {
return permissionId;
}
public void setPermissionId(long permissionId) {
this.permissionId = permissionId;
}
public long getObjectId() {
return objectId;
}
public void setObjectId(long objectId) {
this.objectId = objectId;
}
public String getObjectType() {
return objectType;
}
public void setObjectType(String objectType) {
this.objectType = objectType;
}
public String getSubjectId() {
return subjectId;
}
public void setSubjectId(String subjectId) {
this.subjectId = subjectId;
}
public String getSubjectType() {
return subjectType;
}
public void setSubjectType(String subjectType) {
this.subjectType = subjectType;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
}

View File

@ -0,0 +1,47 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component;
import org.apache.camel.Exchange;
import org.apache.camel.support.DefaultProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.system.core.permission.component.operation.OperationFactory;
public class PermissionProducer extends DefaultProducer {
private static final Logger LOG = LoggerFactory.getLogger(PermissionProducer.class);
private final PermissionEndpoint endpoint;
public PermissionProducer(PermissionEndpoint endpoint) {
super(endpoint);
this.endpoint = endpoint;
}
public void process(Exchange exchange) throws Exception {
String operation = endpoint.getOperation();
LOG.debug("In PermissionProducer " + endpoint.getPermissionId() + " " + endpoint.getObjectId() + " " + endpoint.getObjectType() + " "
+ endpoint.getSubjectId() + " " + endpoint.getSubjectType() + " " + endpoint.getAction());
OperationFactory.getOperation(operation).process(exchange, endpoint);
}
}

View File

@ -0,0 +1,47 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.exception;
public class UnknownOperationException extends Exception {
private static final long serialVersionUID = 948229285513408917L;
public UnknownOperationException() {
super();
}
public UnknownOperationException(String message, Throwable cause, boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public UnknownOperationException(String message, Throwable cause) {
super(message, cause);
}
public UnknownOperationException(String message) {
super(message);
}
public UnknownOperationException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,74 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.system.common.osgi.OSGIUtils;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
import ru.entaxy.esb.system.core.permission.component.PermissionProducer;
import ru.entaxy.esb.system.core.permission.jpa.PermissionService;
import ru.entaxy.esb.system.jpa.SystemService;
public abstract class BaseOperation implements Operation {
private static final Logger LOG = LoggerFactory.getLogger(BaseOperation.class);
private PermissionService permissionService;
private SystemService systemService;
@Override
public void process(Exchange exchange, PermissionEndpoint endpoint) throws Exception {
doProcess(exchange, endpoint);
}
protected abstract void doProcess(Exchange exchange, PermissionEndpoint endpoint) throws Exception;
protected void validateParams(String... parameters) {
for (String parameter : parameters) {
if (parameter == null || "0".equals(parameter) || parameter.isEmpty()) {
throw new IllegalArgumentException("One or more parameters empty!");
}
}
}
protected PermissionService getPermissionService() {
if (permissionService == null) {
permissionService = (PermissionService) OSGIUtils.getServiceReference(
FrameworkUtil.getBundle(PermissionProducer.class).getBundleContext(),
PermissionService.class.getName());
}
return permissionService;
}
protected SystemService getSystemService() {
if (systemService == null) {
systemService = (SystemService) OSGIUtils.getServiceReference(
FrameworkUtil.getBundle(PermissionProducer.class).getBundleContext(),
SystemService.class.getName());
}
return systemService;
}
}

View File

@ -0,0 +1,33 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
public class BulkCreate extends BaseOperation {
@Override
protected void doProcess(Exchange exchange, PermissionEndpoint endpoint) throws Exception {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,41 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
public class Check extends BaseOperation {
@Override
protected void doProcess(Exchange exchange, PermissionEndpoint endpoint) throws Exception {
validateParams(String.valueOf(endpoint.getObjectId()), endpoint.getObjectType(),
endpoint.getSubjectId(), endpoint.getSubjectType());
exchange.getIn().setBody(check(endpoint), Boolean.class);
}
protected boolean check(PermissionEndpoint endpoint) {
return getPermissionService().existByAllParameters(endpoint.getObjectId(), endpoint.getObjectType(),
endpoint.getSubjectId(), endpoint.getSubjectType(), endpoint.getAction());
}
}

View File

@ -0,0 +1,71 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import ru.entaxy.esb.system.core.permission.common.PermissionConstants;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
import ru.entaxy.esb.system.jpa.entity.System;
import javax.persistence.NoResultException;
public class CheckSystemAccess extends BaseOperation {
@Override
protected void doProcess(Exchange exchange, PermissionEndpoint endpoint) throws Exception {
validateParams(String.valueOf(endpoint.getObjectId()), endpoint.getSubjectId());
exchange.getIn().setBody(checkSystemAccessProc(endpoint), Boolean.class);
}
protected boolean checkSystemAccessProc(PermissionEndpoint endpoint) {
System system = getSystem(endpoint.getSubjectId());
boolean result = false;
if (system != null) {
result = getPermissionService().existByAllParameters(endpoint.getObjectId(), PermissionConstants.TYPE_SYSTEM,
String.valueOf(system.getId()), PermissionConstants.TYPE_SYSTEM, endpoint.getAction());
}
return result;
}
protected System getSystem(String subject) {
try {
long systemId = Long.valueOf(subject);
return getSystemService().get(systemId);
} catch (Exception e) {
/*keep silence*/
}
System system = null;
try {
system = getSystemService().getByName(subject);
return system;
} catch (NoResultException e) {
/*keep silence*/
}
try {
system = getSystemService().getByUuid(subject);
} catch (NoResultException e) {
/*keep silence*/
}
return system;
}
}

View File

@ -0,0 +1,39 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
import ru.entaxy.esb.system.jpa.entity.System;
public class CheckSystemAccessWithException extends CheckSystemAccess {
@Override
protected void doProcess(Exchange exchange, PermissionEndpoint endpoint) throws IllegalAccessException {
validateParams(String.valueOf(endpoint.getObjectId()), endpoint.getSubjectId());
if (!checkSystemAccessProc(endpoint)) {
if (endpoint.getSubjectId().equals("error")) return;
System system = getSystem(endpoint.getSubjectId());
if (system.getId() == endpoint.getObjectId()) return;
throw new IllegalAccessException("Connection to system " + endpoint.getSubjectId() + " is not allowed");
}
}
}

View File

@ -0,0 +1,34 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
public class CheckWithException extends Check {
@Override
protected void doProcess(Exchange exchange, PermissionEndpoint endpoint) throws IllegalAccessException {
validateParams(String.valueOf(endpoint.getObjectId()), endpoint.getObjectType(),
endpoint.getSubjectId(), endpoint.getSubjectType());
if (!check(endpoint)) {
throw new IllegalAccessException();
}
}
}

View File

@ -0,0 +1,35 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
public class Create extends BaseOperation {
@Override
protected void doProcess(Exchange exchange, PermissionEndpoint endpoint) throws Exception {
validateParams(String.valueOf(endpoint.getObjectId()), endpoint.getObjectType(),
endpoint.getSubjectId(), endpoint.getSubjectType());
exchange.getIn().setBody(getPermissionService().add(endpoint.getObjectId(), endpoint.getObjectType(),
endpoint.getSubjectId(), endpoint.getSubjectType(), endpoint.getAction()));
}
}

View File

@ -0,0 +1,40 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
public class Delete extends BaseOperation {
@Override
protected void doProcess(Exchange exchange, PermissionEndpoint endpoint) throws Exception {
validateParams(String.valueOf(endpoint.getObjectId()), endpoint.getObjectType(),
endpoint.getSubjectId(), endpoint.getSubjectType());
try {
getPermissionService().remove(endpoint.getObjectId(), endpoint.getObjectType(),
endpoint.getSubjectId(), endpoint.getSubjectType(), endpoint.getAction());
exchange.getIn().setBody(true, Boolean.class);
} catch (Exception e) {
exchange.getIn().setBody(false, Boolean.class);
}
}
}

View File

@ -0,0 +1,33 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
public class Get extends BaseOperation {
@Override
protected void doProcess(Exchange exchange, PermissionEndpoint endpoint) throws Exception {
validateParams(String.valueOf(endpoint.getPermissionId()));
exchange.getIn().setBody(getPermissionService().get(endpoint.getPermissionId()));
}
}

View File

@ -0,0 +1,35 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
public class GetByAllParams extends BaseOperation {
@Override
protected void doProcess(Exchange exchange, PermissionEndpoint endpoint) throws Exception {
validateParams(String.valueOf(endpoint.getObjectId()), endpoint.getObjectType(),
endpoint.getSubjectId(), endpoint.getSubjectType());
exchange.getIn().setBody(getPermissionService().getByAllParameters(endpoint.getObjectId(), endpoint.getObjectType(),
endpoint.getSubjectId(), endpoint.getSubjectType(), endpoint.getAction()));
}
}

View File

@ -0,0 +1,29 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
public interface Operation {
void process(Exchange exchange, PermissionEndpoint endpoint) throws Exception;
}

View File

@ -0,0 +1,52 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import ru.entaxy.esb.system.core.permission.component.exception.UnknownOperationException;
import ru.entaxy.esb.system.core.permission.component.util.PermissionComponentConstants;
import java.util.HashMap;
import java.util.Map;
public class OperationFactory {
private static final Map<String, Operation> operations;
static {
operations = new HashMap<>();
operations.put(PermissionComponentConstants.OPERATION_CHECK, new Check());
operations.put(PermissionComponentConstants.OPERATION_CHECK_EXCEPTION, new CheckWithException());
operations.put(PermissionComponentConstants.OPERATION_CHECK_SYSTEM_ACCESS, new CheckSystemAccess());
operations.put(PermissionComponentConstants.OPERATION_CHECK_SYSTEM_ACCESS_EXCEPTION, new CheckSystemAccessWithException());
operations.put(PermissionComponentConstants.OPERATION_CREATE, new Create());
operations.put(PermissionComponentConstants.OPERATION_DELETE, new Delete());
operations.put(PermissionComponentConstants.OPERATION_GET, new Get());
operations.put(PermissionComponentConstants.OPERATION_GET_BY_ALL_PARAM, new GetByAllParams());
operations.put(PermissionComponentConstants.OPERATION_UPDATE, new Update());
}
public static final Operation getOperation(String name) throws UnknownOperationException {
if (operations.containsKey(name)) {
return operations.get(name);
}
throw new UnknownOperationException();
}
}

View File

@ -0,0 +1,35 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.operation;
import org.apache.camel.Exchange;
import ru.entaxy.esb.system.core.permission.component.PermissionEndpoint;
public class Update extends BaseOperation {
@Override
protected void doProcess(Exchange exchange, PermissionEndpoint endpoint) throws Exception {
validateParams(String.valueOf(endpoint.getObjectId()), endpoint.getObjectType(),
endpoint.getSubjectId(), endpoint.getSubjectType());
exchange.getIn().setBody(getPermissionService().update(endpoint.getPermissionId(), endpoint.getObjectId(), endpoint.getObjectType(),
endpoint.getSubjectId(), endpoint.getSubjectType(), endpoint.getAction()));
}
}

View File

@ -0,0 +1,36 @@
/*-
* ~~~~~~licensing~~~~~~
* permission-component
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.core.permission.component.util;
public class PermissionComponentConstants {
public static final String OPERATION_CHECK = "check";
public static final String OPERATION_CHECK_EXCEPTION = "checkException";
public static final String OPERATION_CHECK_SYSTEM_ACCESS = "checkSystemAccess";
public static final String OPERATION_CHECK_SYSTEM_ACCESS_EXCEPTION = "checkSystemAccessException";
public static final String OPERATION_GET = "get";
public static final String OPERATION_GET_BY_ALL_PARAM = "getByAllParams";
public static final String OPERATION_CREATE = "create";
public static final String OPERATION_UPDATE = "update";
public static final String OPERATION_DELETE = "delete";
private PermissionComponentConstants() {
}
}

View File

@ -0,0 +1 @@
class=ru.entaxy.esb.system.core.permission.component.PermissionComponent

View File

@ -0,0 +1,30 @@
###
# ~~~~~~licensing~~~~~~
# permission-component
# ==========
# Copyright (C) 2020 - 2021 EmDev LLC
# ==========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~~~~/licensing~~~~~~
###
appender.file.type=File
appender.file.name=file
appender.file.fileName=target/camel-test.log
appender.file.layout.type=PatternLayout
appender.file.layout.pattern=%d %-5p %c{1} - %m %n
appender.out.type=Console
appender.out.name=out
appender.out.layout.type=PatternLayout
appender.out.layout.pattern=[%30.30t] %-30.30c{1} %-5p %m%n
rootLogger.level=INFO
rootLogger.appenderRef.out.ref=out