Commit a734c5ee authored by Fotis Soldatos's avatar Fotis Soldatos
Browse files

feat(policy): add context related domain models

parent d3c89cab
Loading
Loading
Loading
Loading
+11 −17
Original line number Diff line number Diff line
@@ -18,32 +18,26 @@ package eu.teraflow.policy.context.model;

public class ConfigRule {

    private final ConfigActionEnum action;
    private final String resourceKey;
    private final String resourceValue;
    private final ConfigActionEnum configActionEnum;
    private final ConfigRuleType<?> configRuleType;

    public ConfigRule(ConfigActionEnum action, String resourceKey, String resourceValue) {
        this.action = action;
        this.resourceKey = resourceKey;
        this.resourceValue = resourceValue;
    public ConfigRule(ConfigActionEnum configActionEnum, ConfigRuleType<?> configRuleType) {
        this.configActionEnum = configActionEnum;
        this.configRuleType = configRuleType;
    }

    public ConfigActionEnum getAction() {
        return action;
    public ConfigActionEnum getConfigActionEnum() {
        return configActionEnum;
    }

    public String getResourceKey() {
        return resourceKey;
    }

    public String getResourceValue() {
        return resourceValue;
    public ConfigRuleType getConfigRuleType() {
        return configRuleType;
    }

    @Override
    public String toString() {
        return String.format(
                "%s:{action:\"%s\", resourceKey:\"%s\", resourceValue:\"%s\"}",
                getClass().getSimpleName(), action.toString(), resourceKey, resourceValue);
                "%s:{configActionEnum:\"%s\", %s}",
                getClass().getSimpleName(), configActionEnum.toString(), configRuleType);
    }
}
+43 −0
Original line number Diff line number Diff line
/*
* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
*
* 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.
*/

package eu.teraflow.policy.context.model;

import eu.teraflow.policy.acl.AclRuleSet;

public class ConfigRuleAcl {

    private final EndPointId endPointId;
    private final AclRuleSet ruleSet;

    public ConfigRuleAcl(EndPointId endPointId, AclRuleSet ruleSet) {
        this.endPointId = endPointId;
        this.ruleSet = ruleSet;
    }

    public EndPointId getEndPointId() {
        return endPointId;
    }

    public AclRuleSet getRuleSet() {
        return ruleSet;
    }

    @Override
    public String toString() {
        return String.format("%s:{%s, %s}", getClass().getSimpleName(), endPointId, ruleSet);
    }
}
+43 −0
Original line number Diff line number Diff line
/*
* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
*
* 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.
*/

package eu.teraflow.policy.context.model;

public class ConfigRuleCustom {

    private final String resourceKey;
    private final String resourceValue;

    public ConfigRuleCustom(String resourceKey, String resourceValue) {
        this.resourceKey = resourceKey;
        this.resourceValue = resourceValue;
    }

    public String getResourceKey() {
        return resourceKey;
    }

    public String getResourceValue() {
        return resourceValue;
    }

    @Override
    public String toString() {
        return String.format(
                "%s:{resourceKey:\"%s\", resourceValue:\"%s\"}",
                getClass().getSimpleName(), resourceKey, resourceValue);
    }
}
+22 −0
Original line number Diff line number Diff line
/*
* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
*
* 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.
*/

package eu.teraflow.policy.context.model;

public interface ConfigRuleType<T> {

    public T getConfigRuleType();
}
+36 −0
Original line number Diff line number Diff line
/*
* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
*
* 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.
*/

package eu.teraflow.policy.context.model;

public class ConfigRuleTypeAcl implements ConfigRuleType<ConfigRuleAcl> {

    private final ConfigRuleAcl configRuleAcl;

    public ConfigRuleTypeAcl(ConfigRuleAcl configRuleAcl) {
        this.configRuleAcl = configRuleAcl;
    }

    @Override
    public ConfigRuleAcl getConfigRuleType() {
        return this.configRuleAcl;
    }

    @Override
    public String toString() {
        return String.format("%s:{%s}", getClass().getSimpleName(), configRuleAcl);
    }
}
Loading