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

feat(policy): add acl related domain models

parent 7079134f
Loading
Loading
Loading
Loading
+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.acl;

public class AclAction {

    private final AclForwardActionEnum aclForwardActionEnum;
    private final AclLogActionEnum aclLogActionEnum;

    public AclAction(AclForwardActionEnum aclForwardActionEnum, AclLogActionEnum aclLogActionEnum) {
        this.aclForwardActionEnum = aclForwardActionEnum;
        this.aclLogActionEnum = aclLogActionEnum;
    }

    public AclForwardActionEnum getAclForwardActionEnum() {
        return aclForwardActionEnum;
    }

    public AclLogActionEnum getAclLogActionEnum() {
        return aclLogActionEnum;
    }

    @Override
    public String toString() {
        return String.format(
                "%s:{aclForwardActionEnum:\"%s\", aclLogActionEnum:\"%s\"}",
                getClass().getSimpleName(), aclForwardActionEnum.toString(), aclLogActionEnum.toString());
    }
}
+55 −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.acl;

public class AclEntry {

    private final int sequenceId;
    private final String description;
    private final AclMatch match;
    private final AclAction action;

    public AclEntry(int sequenceId, String description, AclMatch match, AclAction action) {
        this.sequenceId = sequenceId;
        this.description = description;
        this.match = match;
        this.action = action;
    }

    public int getSequenceId() {
        return sequenceId;
    }

    public String getDescription() {
        return description;
    }

    public AclMatch getMatch() {
        return match;
    }

    public AclAction getAction() {
        return action;
    }

    @Override
    public String toString() {
        return String.format(
                "%s:{sequenceId:\"%d\", description:\"%s\", %s, %s}",
                getClass().getSimpleName(), sequenceId, description, match, action);
    }
}
+24 −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.acl;

public enum AclForwardActionEnum {
    UNDEFINED,
    DROP,
    ACCEPT,
    REJECT,
}
+23 −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.acl;

public enum AclLogActionEnum {
    UNDEFINED,
    NO_LOG,
    SYSLOG
}
+95 −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.acl;

public class AclMatch {

    private final int dscp;
    private final int protocol;
    private final String srcAddress;
    private final String dstAddress;
    private final int srcPort;
    private final int dstPort;
    private final int startMplsLabel;
    private final int endMplsLabel;

    public AclMatch(
            int dscp,
            int protocol,
            String srcAddress,
            String dstAddress,
            int srcPort,
            int dstPort,
            int startMplsLabel,
            int endMplsLabel) {
        this.dscp = dscp;
        this.protocol = protocol;
        this.srcAddress = srcAddress;
        this.dstAddress = dstAddress;
        this.srcPort = srcPort;
        this.dstPort = dstPort;
        this.startMplsLabel = startMplsLabel;
        this.endMplsLabel = endMplsLabel;
    }

    public int getDscp() {
        return dscp;
    }

    public int getProtocol() {
        return protocol;
    }

    public String getSrcAddress() {
        return srcAddress;
    }

    public String getDstAddress() {
        return dstAddress;
    }

    public int getSrcPort() {
        return srcPort;
    }

    public int getDstPort() {
        return dstPort;
    }

    public int getStartMplsLabel() {
        return startMplsLabel;
    }

    public int getEndMplsLabel() {
        return endMplsLabel;
    }

    @Override
    public String toString() {
        return String.format(
                "%s:{dscp:\"%d\", protocol:\"%d\", srcAddress:\"%s\", dstAddress:\"%s\", srcPort:\"%d\", dstPort:\"%d\", startMplsLabel:\"%d\", endMplsLabel:\"%d\"}",
                getClass().getSimpleName(),
                dscp,
                protocol,
                srcAddress,
                dstAddress,
                srcPort,
                dstPort,
                startMplsLabel,
                endMplsLabel);
    }
}
Loading