[java-oidc-common] branch main updated: Add claim exists activation condition for JWT validation

Phil Smart philip.smart at jisc.ac.uk
Wed Feb 2 17:38:29 UTC 2022


This is an automated email from the git hooks/post-receive script.

philsmart pushed a commit to branch main
in repository java-oidc-common.

View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=6e65454f005f4d9b8002ae2b521de4d0980875c6

The following commit(s) were added to refs/heads/main by this push:
     new 6e65454  Add claim exists activation condition for JWT validation
6e65454 is described below

commit 6e65454f005f4d9b8002ae2b521de4d0980875c6
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Wed Feb 2 17:38:23 2022 +0000

    Add claim exists activation condition for JWT validation
---
 .../impl/ClaimExistsActivationCondition.java       | 54 ++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/security/jwt/claims/impl/ClaimExistsActivationCondition.java b/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/security/jwt/claims/impl/ClaimExistsActivationCondition.java
new file mode 100644
index 0000000..8ba5eaa
--- /dev/null
+++ b/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/security/jwt/claims/impl/ClaimExistsActivationCondition.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID 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
+ *
+ *    http://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.
+ */
+
+package net.shibboleth.oidc.security.jwt.claims.impl;
+
+import java.util.function.BiPredicate;
+
+import javax.annotation.Nonnull;
+import javax.annotation.concurrent.ThreadSafe;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+import com.nimbusds.jwt.JWTClaimsSet;
+
+import net.shibboleth.utilities.java.support.annotation.ParameterName;
+
+/** Activation condition to check a claim exists in the claims set.*/
+ at ThreadSafe
+public class ClaimExistsActivationCondition implements BiPredicate<ProfileRequestContext, JWTClaimsSet> {
+    
+    /** The name of the claim to check exists in the claims set.*/
+    @Nonnull final String claimToCheck;
+    
+    /**
+     * 
+     * Constructor.
+     *
+     * @param claimName the name of the claim to check exists in the claims set.
+     */
+    public ClaimExistsActivationCondition(
+            @Nonnull @ParameterName(name="claimToCheck") final String claimName) {
+        claimToCheck = claimName;
+    }
+
+    @Override
+    public boolean test(@Nonnull final ProfileRequestContext context, @Nonnull final JWTClaimsSet claims) {
+        return claims.getClaim(claimToCheck) != null;
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list