Skip to content

Commit 04e31aa

Browse files
committed
Add interface and models for synchronizing ACL policies
1 parent e79a2d3 commit 04e31aa

File tree

9 files changed

+452
-0
lines changed

9 files changed

+452
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable.model.catalog.policy;
20+
21+
import java.time.Instant;
22+
import java.util.Map;
23+
24+
import lombok.Builder;
25+
import lombok.Value;
26+
27+
/** A snapshot of all access control data at a given point in time. */
28+
@Value
29+
@Builder
30+
public class InternalAccessControlPolicySnapshot {
31+
/**
32+
* A unique identifier representing this snapshot's version.
33+
*
34+
* <p>This could be a UUID, timestamp string, or any value that guarantees uniqueness across
35+
* snapshots.
36+
*/
37+
String versionId;
38+
39+
/**
40+
* The moment in time when this snapshot was created.
41+
*
42+
* <p>Useful for maintaining an audit trail or comparing how policies have changed over time.
43+
*/
44+
Instant timestamp;
45+
46+
/**
47+
* A map of user names to {@link InternalUser} objects, capturing individual users' details such
48+
* as assigned roles, auditing metadata, etc.
49+
*/
50+
Map<String, InternalUser> usersByName;
51+
52+
/**
53+
* A map of group names to {@link InternalUserGroup} objects, representing logical groupings of
54+
* users for easier role management.
55+
*/
56+
Map<String, InternalUserGroup> groupsByName;
57+
58+
/**
59+
* A map of role names to {@link InternalRole} objects, defining the privileges and security rules
60+
* each role entails.
61+
*/
62+
Map<String, InternalRole> rolesByName;
63+
64+
/**
65+
* A map of additional properties or metadata related to this snapshot. This map provides
66+
* flexibility for storing information without modifying the main schema of the snapshot.
67+
*/
68+
Map<String, String> properties;
69+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable.model.catalog.policy;
20+
21+
import java.time.Instant;
22+
23+
import lombok.Builder;
24+
import lombok.Value;
25+
26+
/**
27+
* Contains change-log information for roles, users, or user groups, enabling traceability of who
28+
* created or last modified them.
29+
*
30+
* <p>This class is useful for governance and compliance scenarios, where an audit trail is
31+
* necessary. It can be extended to include additional fields such as reasonForChange or
32+
* changeDescription.
33+
*/
34+
@Value
35+
@Builder
36+
public class InternalChangeLogInfo {
37+
/** The username or identifier of the entity that created this record. */
38+
String createdBy;
39+
40+
/** The username or identifier of the entity that last modified this record. */
41+
String lastModifiedBy;
42+
43+
/** The timestamp when this record was created. */
44+
Instant createdAt;
45+
46+
/** The timestamp when this record was last modified. */
47+
Instant lastModifiedAt;
48+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable.model.catalog.policy;
20+
21+
import lombok.Builder;
22+
import lombok.Value;
23+
24+
/**
25+
* Represents a single privilege assignment for a securable object.
26+
*
27+
* <p>This defines the kind of operation (e.g., SELECT, CREATE, MODIFY) and whether it is allowed or
28+
* denied. Some catalogs may only accept ALLOW rules and treat all other operations as denied by
29+
* default.
30+
*/
31+
@Value
32+
@Builder
33+
public class InternalPrivilege {
34+
/**
35+
* The type of privilege, such as SELECT, CREATE, or MODIFY. Each implementation can define its
36+
* own set of enums.
37+
*/
38+
String privilegeType;
39+
40+
/**
41+
* The decision, typically ALLOW or DENY. Some catalogs may not support DENY explicitly,
42+
* defaulting to ALLOW.
43+
*/
44+
String privilegeDecision;
45+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable.model.catalog.policy;
20+
21+
import java.util.List;
22+
import java.util.Map;
23+
24+
import lombok.Builder;
25+
import lombok.Value;
26+
27+
/**
28+
* Represents a role within the catalog.
29+
*
30+
* <p>A role can be granted access to multiple securable objects, each with its own set of
31+
* privileges. Audit info is stored to track the role's creation and modifications, and a properties
32+
* map can hold additional metadata.
33+
*/
34+
@Value
35+
@Builder
36+
public class InternalRole {
37+
/** The unique name or identifier for the role. */
38+
String name;
39+
40+
/** The list of securable objects this role can access. */
41+
List<InternalSecurableObject> securableObjects;
42+
43+
/** Contains information about how and when this role was created and last modified. */
44+
InternalChangeLogInfo changeLogInfo;
45+
46+
/**
47+
* A map to store additional metadata or properties related to this role. For example, this might
48+
* include a description, usage instructions, or any catalog-specific fields.
49+
*/
50+
Map<String, String> properties;
51+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable.model.catalog.policy;
20+
21+
import java.util.List;
22+
23+
import lombok.Builder;
24+
import lombok.Value;
25+
26+
/**
27+
* Represents a securable object in the catalog, which can be managed by access control.
28+
*
29+
* <p>Examples of securable objects include catalogs, schemas, tables, views, or any other data
30+
* objects that require fine-grained privilege management. Each securable object can have one or
31+
* more privileges assigned to it.
32+
*/
33+
@Value
34+
@Builder
35+
public class InternalSecurableObject {
36+
/**
37+
* The type of securable object, such as TABLE, VIEW, FUNCTION, etc. Each implementation can
38+
* define its own set of enums.
39+
*/
40+
String securableObjectType;
41+
/** The set of privileges assigned to this object. */
42+
List<InternalPrivilege> privileges;
43+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable.model.catalog.policy;
20+
21+
import java.util.List;
22+
23+
import lombok.Builder;
24+
import lombok.Value;
25+
26+
/**
27+
* Represents an individual user within the catalog.
28+
*
29+
* <p>A user may be assigned multiple roles, and can also belong to a specific user group. Audit
30+
* information is stored to allow tracking of who created or last modified the user.
31+
*/
32+
@Value
33+
@Builder
34+
public class InternalUser {
35+
/** The unique name or identifier for the user. */
36+
String name;
37+
38+
/** The list of roles assigned to this user. */
39+
List<InternalRole> roles;
40+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable.model.catalog.policy;
20+
21+
import java.util.List;
22+
23+
import lombok.Builder;
24+
import lombok.Value;
25+
26+
/**
27+
* Represents a user group within the catalog.
28+
*
29+
* <p>Groups can have multiple roles assigned, and also include audit information to track creation
30+
* and modifications.
31+
*/
32+
@Value
33+
@Builder
34+
public class InternalUserGroup {
35+
/** The unique name or identifier for the user group. */
36+
String name;
37+
38+
/** The list of roles assigned to this group. */
39+
List<InternalRole> roles;
40+
41+
/** Contains information about how and when this group was created and last modified. */
42+
InternalChangeLogInfo changeLogInfo;
43+
}

0 commit comments

Comments
 (0)