forked from eclipse-tractusx/item-relationship-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eclipse-tractusx#530 from catenax-ng/TRI-1593-poli…
…cy-store-api-extension feat(irs-policy-store): [TRI-1593] Policy Store API Extension
- Loading branch information
Showing
13 changed files
with
456 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/Constraint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2021,2022,2023 | ||
* 2022: ZF Friedrichshafen AG | ||
* 2022: ISTOS GmbH | ||
* 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* 2022,2023: BOSCH AG | ||
* Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.policystore.models; | ||
|
||
import java.util.List; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* A Constraint object used as an element of collection in Permission | ||
*/ | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class Constraint { | ||
|
||
private String leftOperand; | ||
private OperatorType operator; | ||
private List<String> rightOperand; | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/Constraints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2021,2022,2023 | ||
* 2022: ZF Friedrichshafen AG | ||
* 2022: ISTOS GmbH | ||
* 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* 2022,2023: BOSCH AG | ||
* Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.policystore.models; | ||
|
||
import java.util.List; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* A Constraint containing two collections of Constraints | ||
*/ | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@SuppressWarnings("PMD.ShortVariable") | ||
public class Constraints { | ||
|
||
private List<Constraint> and; | ||
private List<Constraint> or; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/OperatorType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2021,2022,2023 | ||
* 2022: ZF Friedrichshafen AG | ||
* 2022: ISTOS GmbH | ||
* 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* 2022,2023: BOSCH AG | ||
* Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.policystore.models; | ||
|
||
import java.util.NoSuchElementException; | ||
import java.util.stream.Stream; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; | ||
import lombok.Getter; | ||
|
||
/** | ||
* List of Operator Type that can be used to build Constraints | ||
*/ | ||
@JsonSerialize(using = ToStringSerializer.class) | ||
@Getter | ||
public enum OperatorType { | ||
|
||
EQ("eq", "Equals to"), | ||
NEQ("neq", "Not equal to"), | ||
LT("lt", "Less than"), | ||
GT("gt", "Greater than"), | ||
IN("in", "In"), | ||
LTEQ("lteq", "Less than or equal to"), | ||
GTEQ("gteq", "Greater than or equal to"), | ||
ISA("isA", "Is a"), | ||
HASPART("hasPart", "Has part"), | ||
ISPARTOF("isPartOf", "Is part of"), | ||
ISONEOF("isOneOf", "Is one of"), | ||
ISALLOF("isAllOf", "Is all of"), | ||
ISNONEOF("isNoneOf", "Is none of"); | ||
|
||
private final String code; | ||
private final String label; | ||
|
||
OperatorType(final String code, final String label) { | ||
this.code = code; | ||
this.label = label; | ||
} | ||
|
||
@JsonCreator | ||
public static OperatorType fromValue(final String value) { | ||
return Stream.of(OperatorType.values()) | ||
.filter(operatorType -> operatorType.code.equals(value)) | ||
.findFirst() | ||
.orElseThrow(() -> new NoSuchElementException("Unsupported OperatorType: " + value)); | ||
} | ||
|
||
/** | ||
* @return convert OperatorType to string value | ||
*/ | ||
@Override | ||
public String toString() { | ||
return code; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/Permission.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2021,2022,2023 | ||
* 2022: ZF Friedrichshafen AG | ||
* 2022: ISTOS GmbH | ||
* 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* 2022,2023: BOSCH AG | ||
* Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.policystore.models; | ||
|
||
import java.util.List; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* A Permission object gather PolicyType with list of Constraints and its relation | ||
*/ | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class Permission { | ||
|
||
private PolicyType action; | ||
private List<Constraints> constraints; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/PolicyType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2021,2022,2023 | ||
* 2022: ZF Friedrichshafen AG | ||
* 2022: ISTOS GmbH | ||
* 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* 2022,2023: BOSCH AG | ||
* Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.policystore.models; | ||
|
||
/** | ||
* A PolicyType object use in Permission | ||
*/ | ||
public enum PolicyType { | ||
|
||
ACCESS, USE | ||
|
||
} |
Oops, something went wrong.