-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add JWT verification and extend tests
- Loading branch information
1 parent
3daaeeb
commit d83ce91
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
src/main/java/org/eclipse/tractusx/managedidentitywallets/utils/CompositDidResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* ******************************************************************************* | ||
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* ****************************************************************************** | ||
*/ | ||
|
||
package org.eclipse.tractusx.managedidentitywallets.utils; | ||
|
||
import org.eclipse.tractusx.ssi.lib.did.resolver.DidResolver; | ||
import org.eclipse.tractusx.ssi.lib.did.resolver.DidResolverException; | ||
import org.eclipse.tractusx.ssi.lib.model.did.Did; | ||
import org.eclipse.tractusx.ssi.lib.model.did.DidDocument; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Arrays; | ||
|
||
@Component | ||
public class CompositDidResolver implements DidResolver { | ||
DidResolver[] didResolvers; | ||
|
||
public CompositDidResolver(DidResolver... didResolvers) { | ||
this.didResolvers = didResolvers; | ||
} | ||
|
||
public DidDocument resolve(Did did) throws DidResolverException { | ||
DidResolver[] var2 = this.didResolvers; | ||
int var3 = var2.length; | ||
|
||
for(int var4 = 0; var4 < var3; ++var4) { | ||
DidResolver didResolver = var2[var4]; | ||
if (didResolver.isResolvable(did)) { | ||
try { | ||
DidDocument result = didResolver.resolve(did); | ||
if (result != null) { | ||
return result; | ||
} | ||
} catch (DidResolverException var7) { | ||
throw var7; | ||
} catch (Throwable var8) { | ||
throw new DidResolverException(String.format("Unrecognized exception: %s", var8.getClass().getName()), var8); | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public boolean isResolvable(Did did) { | ||
return Arrays.stream(this.didResolvers).anyMatch((resolver) -> resolver.isResolvable(did)); | ||
} | ||
|
||
public static org.eclipse.tractusx.ssi.lib.did.resolver.CompositeDidResolver append(DidResolver target, DidResolver toBeAppended) { | ||
return new org.eclipse.tractusx.ssi.lib.did.resolver.CompositeDidResolver(target, toBeAppended); | ||
} | ||
} | ||
|