[java-oidc-common] branch main updated: JCOMOIDC-13 - Hook for injecting "part" of claims verification chain

Scott Cantor cantor.2 at osu.edu
Mon Feb 22 22:59:40 UTC 2021


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

scantor 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=b25b241a1ff32f958c31c70f4e4dbf649207ce1f

The following commit(s) were added to refs/heads/main by this push:
       new  b25b241   JCOMOIDC-13 - Hook for injecting "part" of claims verification chain
b25b241 is described below

commit b25b241a1ff32f958c31c70f4e4dbf649207ce1f
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Feb 22 17:59:37 2021 -0500

    JCOMOIDC-13 - Hook for injecting "part" of claims verification chain
    
    https://issues.shibboleth.net/jira/browse/JCOMOIDC-13
---
 .../jwt/claims/impl/FunctionClaimsValidator.java   | 68 ++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/security/jwt/claims/impl/FunctionClaimsValidator.java b/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/security/jwt/claims/impl/FunctionClaimsValidator.java
new file mode 100644
index 0000000..1634f26
--- /dev/null
+++ b/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/security/jwt/claims/impl/FunctionClaimsValidator.java
@@ -0,0 +1,68 @@
+/*
+ * 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.BiFunction;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+import com.nimbusds.jwt.JWTClaimsSet;
+
+import net.shibboleth.oidc.jwt.claims.AbstractClaimsValidator;
+import net.shibboleth.oidc.jwt.claims.ClaimsValidator;
+import net.shibboleth.oidc.jwt.claims.JWTValidationException;
+import net.shibboleth.utilities.java.support.annotation.constraint.ThreadSafeAfterInit;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
+
+/**
+ * A {@link ClaimsValidator} that relies on an injected {@link BiFunction}.
+ */
+ at ThreadSafeAfterInit
+public class FunctionClaimsValidator extends AbstractClaimsValidator{
+    
+    /** The function to run. */
+    @Nullable private BiFunction<JWTClaimsSet,ProfileRequestContext,JWTValidationException> validator;
+    
+    /**
+     * Set the function to run.
+     * 
+     * @param function the function to run
+     */
+    public void setValidator(
+            @Nullable final BiFunction<JWTClaimsSet,ProfileRequestContext,JWTValidationException> function) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        validator = function;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void doValidate(@Nonnull final JWTClaimsSet claims, @Nonnull final ProfileRequestContext context) 
+            throws JWTValidationException {
+        
+        if (validator != null) {
+            final JWTValidationException e = validator.apply(claims, context);
+            if (e != null) {
+                throw e;
+            }
+        }
+    }
+
+}
\ No newline at end of file

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


More information about the commits mailing list