001/* 002 * Copyright 2026 Revetware LLC. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.revetsec.scim; 018 019import com.google.errorprone.annotations.CheckReturnValue; 020import org.jspecify.annotations.NonNull; 021import javax.annotation.concurrent.Immutable; 022import java.util.List; 023import java.util.Set; 024import static java.util.Objects.requireNonNull; 025 026/** An immutable ordered, schema-bound PATCH request. Parsing does not authorize a mutation. 027 * The private registration proof prevents applying permissively parsed input under a different policy. 028 * @since 1.0.0 029 */ 030@Immutable 031@CheckReturnValue 032public final class ScimPatchRequest { 033 private final @NonNull ScimResourceType resourceType; 034 private final @NonNull List<@NonNull ScimPatchOperation> operations; 035 private final @NonNull Set<@NonNull ScimAttributePath> requestedAttributePaths; 036 private final @NonNull Set<@NonNull ScimAttributePath> suppliedAttributePaths; 037 private final @NonNull Object semanticContext; 038 ScimPatchRequest(@NonNull ScimResourceType type, @NonNull List<@NonNull ScimPatchOperation> operations, 039 @NonNull Set<@NonNull ScimAttributePath> requested, @NonNull Set<@NonNull ScimAttributePath> supplied, 040 @NonNull Object context) { 041 resourceType=requireNonNull(type); this.operations=List.copyOf(operations); 042 requestedAttributePaths=Set.copyOf(requested); suppliedAttributePaths=Set.copyOf(supplied); 043 semanticContext=requireNonNull(context); 044 } 045 /** Returns the registered target resource type. 046 * @return the type 047 * @since 1.0.0 */ 048 public @NonNull ScimResourceType getResourceType() { return resourceType; } 049 /** Returns ordered operations with their original request indexes. 050 * @return the immutable operations 051 * @since 1.0.0 */ 052 public @NonNull List<@NonNull ScimPatchOperation> getOperations() { return operations; } 053 /** Returns conservative canonical attempted targets and selector paths for application authorization. 054 * @return the immutable requested paths 055 * @since 1.0.0 */ 056 public @NonNull Set<@NonNull ScimAttributePath> getRequestedAttributePaths() { return requestedAttributePaths; } 057 /** Returns only canonical leaf paths actually supplied, including explicit nulls and empty containers. 058 * @return the immutable supplied paths 059 * @since 1.0.0 */ 060 public @NonNull Set<@NonNull ScimAttributePath> getSuppliedAttributePaths() { return suppliedAttributePaths; } 061 @NonNull Object getSemanticContext() { return semanticContext; } 062 /** Returns a fixed redacted description. 063 * @return the description 064 * @since 1.0.0 */ 065 @Override public @NonNull String toString() { return "ScimPatchRequest{<redacted>}"; } 066}