hsheinblatt commented on code in PR #1361:
URL: https://github.com/apache/knox/pull/1361#discussion_r3901313273


##########
gateway-spi/src/main/java/org/apache/knox/gateway/services/knoxidf/delegation/DelegationPolicy.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.knox.gateway.services.knoxidf.delegation;
+
+import java.time.Instant;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Immutable representation of a stored delegation policy record.
+ */
+public class DelegationPolicy {
+
+  private final String registrationId;
+  private final String actorAuthority;
+  private final String actorId;
+  private final String name;
+  private final String status;
+  private final Integer tokenTtlSec;
+  private final String description;
+  private final String createdBy;
+  private final Instant createdAt;
+  private final Instant updatedAt;
+  private final boolean allowHeadlessExchange;
+  private final Set<String> canActForUsers;
+  private final Set<String> canActForGroups;
+  private final Map<String, Set<String>> resourcePolicy;
+
+  public DelegationPolicy(String registrationId, String actorAuthority, String 
actorId,
+      String name, String status, Integer tokenTtlSec, String description, 
String createdBy,
+      Instant createdAt, Instant updatedAt, boolean allowHeadlessExchange,
+      Set<String> canActForUsers, Set<String> canActForGroups,
+      Map<String, Set<String>> resourcePolicy) {
+    this.registrationId = registrationId;
+    this.actorAuthority = actorAuthority;
+    this.actorId = actorId;
+    this.name = name;
+    this.status = status;
+    this.tokenTtlSec = tokenTtlSec;
+    this.description = description;
+    this.createdBy = createdBy;
+    this.createdAt = createdAt;
+    this.updatedAt = updatedAt;
+    this.allowHeadlessExchange = allowHeadlessExchange;
+    this.canActForUsers = Collections.unmodifiableSet(new 
HashSet<>(canActForUsers));
+    this.canActForGroups = Collections.unmodifiableSet(new 
HashSet<>(canActForGroups));
+    Map<String, Set<String>> copy = new HashMap<>();
+    for (Map.Entry<String, Set<String>> entry : resourcePolicy.entrySet()) {
+      copy.put(entry.getKey(), Collections.unmodifiableSet(new 
HashSet<>(entry.getValue())));
+    }
+    this.resourcePolicy = Collections.unmodifiableMap(copy);

Review Comment:
   Added



##########
gateway-spi/src/main/java/org/apache/knox/gateway/services/knoxidf/delegation/PolicyCheckRequest.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.knox.gateway.services.knoxidf.delegation;
+
+import java.util.Set;
+
+/**
+ * Immutable input to {@link 
DelegationPolicyService#evaluate(PolicyCheckRequest)}.
+ */
+public class PolicyCheckRequest {
+
+  private final String actorAuthority;
+  private final String actorId;
+  private final String subjectName;
+  private final String requestedResource;
+  private final Set<String> requestedScopes;
+  private final boolean headlessExchange;
+
+  public PolicyCheckRequest(String actorAuthority, String actorId, String 
subjectName,
+      String requestedResource, Set<String> requestedScopes, boolean 
headlessExchange) {
+    this.actorAuthority = actorAuthority;
+    this.actorId = actorId;
+    this.subjectName = subjectName;
+    this.requestedResource = requestedResource;
+    this.requestedScopes = requestedScopes;
+    this.headlessExchange = headlessExchange;
+  }

Review Comment:
   Added



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to