-
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.
feat: Implementation of container policies #2
- Loading branch information
1 parent
b128e00
commit fe89ea1
Showing
21 changed files
with
840 additions
and
83 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...extra/src/main/java/com/simplito/java/privmx_endpoint_extra/policies/BasePolicyValue.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,24 @@ | ||
// | ||
// PrivMX Endpoint Java Extra. | ||
// Copyright © 2024 Simplito sp. z o.o. | ||
// | ||
// This file is part of the PrivMX Platform (https://privmx.dev). | ||
// This software is Licensed under the MIT License. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package com.simplito.java.privmx_endpoint_extra.policies; | ||
|
||
public final class BasePolicyValue extends PolicyValue { | ||
|
||
BasePolicyValue(String value) { | ||
super(value); | ||
} | ||
|
||
public static final BasePolicyValue DEFAULT = new BasePolicyValue("default"); | ||
public static final BasePolicyValue INHERIT = new BasePolicyValue("inherit"); | ||
public static final BasePolicyValue YES = new BasePolicyValue("yes"); | ||
public static final BasePolicyValue NO = new BasePolicyValue("no"); | ||
} |
29 changes: 29 additions & 0 deletions
29
...main/java/com/simplito/java/privmx_endpoint_extra/policies/ContainerPolicyChainValue.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,29 @@ | ||
// | ||
// PrivMX Endpoint Java Extra. | ||
// Copyright © 2024 Simplito sp. z o.o. | ||
// | ||
// This file is part of the PrivMX Platform (https://privmx.dev). | ||
// This software is Licensed under the MIT License. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package com.simplito.java.privmx_endpoint_extra.policies; | ||
|
||
public class ContainerPolicyChainValue extends ContainerPolicyValue { | ||
|
||
|
||
ContainerPolicyChainValue(String value) { | ||
super(value); | ||
} | ||
|
||
public ContainerPolicyChainValue OR(ContainerPolicyChainValue policy) { | ||
return new ContainerPolicyChainValue(value + "," + policy.value); | ||
} | ||
|
||
|
||
public ContainerPolicyChainValue AND(ContainerPolicyChainValue policy) { | ||
return new ContainerPolicyChainValue(value + "&" + policy.value); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
.../src/main/java/com/simplito/java/privmx_endpoint_extra/policies/ContainerPolicyValue.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,18 @@ | ||
// | ||
// PrivMX Endpoint Java Extra. | ||
// Copyright © 2024 Simplito sp. z o.o. | ||
// | ||
// This file is part of the PrivMX Platform (https://privmx.dev). | ||
// This software is Licensed under the MIT License. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package com.simplito.java.privmx_endpoint_extra.policies; | ||
|
||
public class ContainerPolicyValue extends PolicyValue { | ||
ContainerPolicyValue(String value) { | ||
super(value); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...src/main/java/com/simplito/java/privmx_endpoint_extra/policies/ContainerPolicyValues.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,23 @@ | ||
// | ||
// PrivMX Endpoint Java Extra. | ||
// Copyright © 2024 Simplito sp. z o.o. | ||
// | ||
// This file is part of the PrivMX Platform (https://privmx.dev). | ||
// This software is Licensed under the MIT License. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package com.simplito.java.privmx_endpoint_extra.policies; | ||
|
||
|
||
public class ContainerPolicyValues { | ||
public static final ContainerPolicyValue DEFAULT = new ContainerPolicyValue("default"); | ||
public static final ContainerPolicyValue INHERIT = new ContainerPolicyValue("inherit"); | ||
public static final ContainerPolicyValue NONE = new ContainerPolicyValue("none"); | ||
public static final ContainerPolicyValue ALL = new ContainerPolicyValue("all"); | ||
public static final ContainerPolicyChainValue USER = new ContainerPolicyChainValue("user"); | ||
public static final ContainerPolicyChainValue MANAGER = new ContainerPolicyChainValue("manager"); | ||
public static final ContainerPolicyChainValue OWNER = new ContainerPolicyChainValue("owner"); | ||
} |
27 changes: 27 additions & 0 deletions
27
.../src/main/java/com/simplito/java/privmx_endpoint_extra/policies/ItemPolicyChainValue.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,27 @@ | ||
// | ||
// PrivMX Endpoint Java Extra. | ||
// Copyright © 2024 Simplito sp. z o.o. | ||
// | ||
// This file is part of the PrivMX Platform (https://privmx.dev). | ||
// This software is Licensed under the MIT License. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package com.simplito.java.privmx_endpoint_extra.policies; | ||
|
||
public class ItemPolicyChainValue extends ItemPolicyValue { | ||
|
||
ItemPolicyChainValue(String value) { | ||
super(value); | ||
} | ||
|
||
public ItemPolicyChainValue OR(ItemPolicyChainValue policy) { | ||
return new ItemPolicyChainValue(value + "," + policy.value); | ||
} | ||
|
||
public ItemPolicyChainValue AND(ItemPolicyChainValue policy) { | ||
return new ItemPolicyChainValue(value + "&" + policy.value); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...extra/src/main/java/com/simplito/java/privmx_endpoint_extra/policies/ItemPolicyValue.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,18 @@ | ||
// | ||
// PrivMX Endpoint Java Extra. | ||
// Copyright © 2024 Simplito sp. z o.o. | ||
// | ||
// This file is part of the PrivMX Platform (https://privmx.dev). | ||
// This software is Licensed under the MIT License. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package com.simplito.java.privmx_endpoint_extra.policies; | ||
|
||
public class ItemPolicyValue extends PolicyValue { | ||
ItemPolicyValue(String value) { | ||
super(value); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...xtra/src/main/java/com/simplito/java/privmx_endpoint_extra/policies/ItemPolicyValues.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,22 @@ | ||
// | ||
// PrivMX Endpoint Java Extra. | ||
// Copyright © 2024 Simplito sp. z o.o. | ||
// | ||
// This file is part of the PrivMX Platform (https://privmx.dev). | ||
// This software is Licensed under the MIT License. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package com.simplito.java.privmx_endpoint_extra.policies; | ||
|
||
public class ItemPolicyValues { | ||
public static final ItemPolicyValue DEFAULT = new ItemPolicyValue("default"); | ||
public static final ItemPolicyValue NONE = new ItemPolicyValue("none"); | ||
public static final ItemPolicyValue ALL = new ItemPolicyValue("all"); | ||
public static final ItemPolicyChainValue USER = new ItemPolicyChainValue("user"); | ||
public static final ItemPolicyChainValue MANAGER = new ItemPolicyChainValue("manager"); | ||
public static final ItemPolicyChainValue OWNER = new ItemPolicyChainValue("owner"); | ||
public static final ItemPolicyChainValue ITEM_OWNER = new ItemPolicyChainValue("itemOwner"); | ||
} |
20 changes: 20 additions & 0 deletions
20
...int-extra/src/main/java/com/simplito/java/privmx_endpoint_extra/policies/PolicyValue.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,20 @@ | ||
// | ||
// PrivMX Endpoint Java Extra. | ||
// Copyright © 2024 Simplito sp. z o.o. | ||
// | ||
// This file is part of the PrivMX Platform (https://privmx.dev). | ||
// This software is Licensed under the MIT License. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package com.simplito.java.privmx_endpoint_extra.policies; | ||
|
||
public class PolicyValue { | ||
public final String value; | ||
|
||
PolicyValue(String value) { | ||
this.value = value; | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
...ava/com/simplito/java/privmx_endpoint_extra/policies/builders/ContainerPolicyBuilder.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,109 @@ | ||
// | ||
// PrivMX Endpoint Java Extra. | ||
// Copyright © 2024 Simplito sp. z o.o. | ||
// | ||
// This file is part of the PrivMX Platform (https://privmx.dev). | ||
// This software is Licensed under the MIT License. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package com.simplito.java.privmx_endpoint_extra.policies.builders; | ||
|
||
import com.simplito.java.privmx_endpoint.model.ContainerPolicy; | ||
import com.simplito.java.privmx_endpoint.model.ContainerPolicyWithoutItem; | ||
import com.simplito.java.privmx_endpoint.model.ItemPolicy; | ||
import com.simplito.java.privmx_endpoint_extra.policies.BasePolicyValue; | ||
import com.simplito.java.privmx_endpoint_extra.policies.ContainerPolicyValue; | ||
|
||
public class ContainerPolicyBuilder { | ||
|
||
private String get; | ||
private String update; | ||
private String delete; | ||
private String updatePolicy; | ||
private String updaterCanBeRemovedFromManagers; | ||
private String ownerCanBeRemovedFromManagers; | ||
private ItemPolicy item; | ||
|
||
public ContainerPolicyBuilder() { | ||
} | ||
|
||
public ContainerPolicyBuilder(ContainerPolicy containerPolicy) { | ||
this.get = containerPolicy.get; | ||
this.update = containerPolicy.update; | ||
this.delete = containerPolicy.delete; | ||
this.updatePolicy = containerPolicy.updatePolicy; | ||
this.updaterCanBeRemovedFromManagers = containerPolicy.updaterCanBeRemovedFromManagers; | ||
this.ownerCanBeRemovedFromManagers = containerPolicy.ownerCanBeRemovedFromManagers; | ||
this.item = containerPolicy.item; | ||
} | ||
|
||
public ContainerPolicyBuilder(ContainerPolicyWithoutItem containerPolicyWithoutItem) { | ||
this.get = containerPolicyWithoutItem.get; | ||
this.update = containerPolicyWithoutItem.update; | ||
this.delete = containerPolicyWithoutItem.delete; | ||
this.updatePolicy = containerPolicyWithoutItem.updatePolicy; | ||
this.updaterCanBeRemovedFromManagers = containerPolicyWithoutItem.updaterCanBeRemovedFromManagers; | ||
this.ownerCanBeRemovedFromManagers = containerPolicyWithoutItem.ownerCanBeRemovedFromManagers; | ||
} | ||
|
||
ContainerPolicyBuilder setGet(ContainerPolicyValue policyValue) { | ||
this.get = policyValue.value; | ||
return this; | ||
} | ||
|
||
ContainerPolicyBuilder setUpdate(ContainerPolicyValue policyValue) { | ||
this.update = policyValue.value; | ||
return this; | ||
} | ||
|
||
ContainerPolicyBuilder setDelete(ContainerPolicyValue policyValue) { | ||
this.delete = policyValue.value; | ||
return this; | ||
} | ||
|
||
ContainerPolicyBuilder setUpdatePolicy(ContainerPolicyValue policyValue) { | ||
this.updatePolicy = policyValue.value; | ||
return this; | ||
} | ||
|
||
ContainerPolicyBuilder setUpdaterCanBeRemovedFromManagers(BasePolicyValue policyValue) { | ||
this.updaterCanBeRemovedFromManagers = policyValue.value; | ||
return this; | ||
} | ||
|
||
ContainerPolicyBuilder setOwnerCanBeRemovedFromManagers(BasePolicyValue policyValue) { | ||
this.ownerCanBeRemovedFromManagers = policyValue.value; | ||
return this; | ||
} | ||
|
||
ContainerPolicyBuilder setItem(ItemPolicy item) { | ||
this.item = item; | ||
return this; | ||
} | ||
|
||
ContainerPolicyWithoutItem buildWithoutItem() { | ||
return new ContainerPolicyWithoutItem( | ||
get, | ||
update, | ||
delete, | ||
updatePolicy, | ||
updaterCanBeRemovedFromManagers, | ||
ownerCanBeRemovedFromManagers | ||
); | ||
} | ||
|
||
ContainerPolicy build() { | ||
return new ContainerPolicy( | ||
get, | ||
update, | ||
delete, | ||
updatePolicy, | ||
updaterCanBeRemovedFromManagers, | ||
ownerCanBeRemovedFromManagers, | ||
item | ||
); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...ain/java/com/simplito/java/privmx_endpoint_extra/policies/builders/ItemPolicyBuilder.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,70 @@ | ||
// | ||
// PrivMX Endpoint Java Extra. | ||
// Copyright © 2024 Simplito sp. z o.o. | ||
// | ||
// This file is part of the PrivMX Platform (https://privmx.dev). | ||
// This software is Licensed under the MIT License. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package com.simplito.java.privmx_endpoint_extra.policies.builders; | ||
|
||
import com.simplito.java.privmx_endpoint.model.ItemPolicy; | ||
import com.simplito.java.privmx_endpoint_extra.policies.ItemPolicyValue; | ||
|
||
public class ItemPolicyBuilder { | ||
private String get; | ||
private String listMy; | ||
private String listAll; | ||
private String create; | ||
private String update; | ||
private String delete; | ||
|
||
public ItemPolicyBuilder() { | ||
|
||
} | ||
|
||
ItemPolicyBuilder setGet(ItemPolicyValue policyValue) { | ||
this.get = policyValue.value; | ||
return this; | ||
} | ||
|
||
ItemPolicyBuilder setListMy(ItemPolicyValue policyValue) { | ||
this.listMy = policyValue.value; | ||
return this; | ||
} | ||
|
||
ItemPolicyBuilder setListAll(ItemPolicyValue policyValue) { | ||
|
||
this.listAll = policyValue.value; | ||
return this; | ||
} | ||
|
||
ItemPolicyBuilder setCreate(ItemPolicyValue policyValue) { | ||
this.create = policyValue.value; | ||
return this; | ||
} | ||
|
||
ItemPolicyBuilder setUpdate(ItemPolicyValue policyValue) { | ||
this.update = policyValue.value; | ||
return this; | ||
} | ||
|
||
ItemPolicyBuilder setDelete(ItemPolicyValue policyValue) { | ||
this.delete = policyValue.value; | ||
return this; | ||
} | ||
|
||
ItemPolicy build() { | ||
return new ItemPolicy( | ||
get, | ||
listMy, | ||
listAll, | ||
create, | ||
update, | ||
delete | ||
); | ||
} | ||
} |
Oops, something went wrong.