[java-oidc-common] branch main updated: Add simple collection JOSE Object credential resolver

Phil Smart philip.smart at jisc.ac.uk
Thu Nov 24 15:45:18 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=03ff6c3e02cb98c3b15a1cf71f9ec7f7ef634386

The following commit(s) were added to refs/heads/main by this push:
     new 03ff6c3  Add simple collection JOSE Object credential resolver
03ff6c3 is described below

commit 03ff6c3e02cb98c3b15a1cf71f9ec7f7ef634386
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Thu Nov 24 15:45:15 2022 +0000

    Add simple collection JOSE Object credential resolver
    
     - For the RP's keyset endpoint
---
 ...nAllCollectionJOSEObjectCredentialResolver.java | 89 ++++++++++++++++++++++
 1 file changed, 89 insertions(+)

diff --git a/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/security/credential/impl/ReturnAllCollectionJOSEObjectCredentialResolver.java b/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/security/credential/impl/ReturnAllCollectionJOSEObjectCredentialResolver.java
new file mode 100644
index 0000000..c33a6d9
--- /dev/null
+++ b/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/security/credential/impl/ReturnAllCollectionJOSEObjectCredentialResolver.java
@@ -0,0 +1,89 @@
+/*
+ * 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.credential.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.security.credential.Credential;
+
+import net.shibboleth.oidc.security.credential.JOSEObjectCredentialResolver;
+import net.shibboleth.utilities.java.support.annotation.ParameterName;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
+import net.shibboleth.utilities.java.support.resolver.ResolverException;
+
+/**
+ * 
+ * An implementation of {@link JOSEObjectCredentialResolver} that uses a {@link Collection} as the underlying 
+ * credential source.
+ * 
+ * <p>Any criteria set is ignored, all credentials are always returned.</p>
+ * 
+ * <p>This is probably only appropriate for building keysets to publish, and not for resolving credentials
+ * to use for cryptographic operation.</p>
+ * 
+ */
+public class ReturnAllCollectionJOSEObjectCredentialResolver implements JOSEObjectCredentialResolver {
+    
+    /** List of credentials held by this resolver. */
+    private final List<Credential> collection;
+    
+    /**
+     * Constructor.
+     *
+     * @param credentials collection of credentials to be held by this resolver
+     */
+    public ReturnAllCollectionJOSEObjectCredentialResolver(
+            @Nonnull @ParameterName(name="credentials") final List<Credential> credentials) {
+        Constraint.isNotNull(credentials, "Input credentials list cannot be null");
+        
+        collection = new ArrayList<>(credentials);
+    }
+    
+    /**
+     * Constructor.
+     *
+     * @param credential a single credential to be held by this resolver
+     */
+    public ReturnAllCollectionJOSEObjectCredentialResolver(
+            @Nonnull @ParameterName(name="credential") final Credential credential) {
+        Constraint.isNotNull(credential, "Input credential cannot be null");
+        
+        collection = new ArrayList<>();
+        collection.add(credential);
+    }
+
+    @Override
+    public Iterable<Credential> resolve(final CriteriaSet criteria) throws ResolverException {
+        return collection;
+    }
+
+    @Override
+    public Credential resolveSingle(final CriteriaSet criteria) throws ResolverException {
+        final Iterable<Credential> creds = resolve(criteria);
+        if (creds.iterator().hasNext()) {
+            return creds.iterator().next();
+        }
+        return null;
+    }
+
+}

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


More information about the commits mailing list