-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SmallRye JWT - register synthetic bean for optional claims
- Loading branch information
1 parent
849c28e
commit b8e5f55
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
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
26 changes: 26 additions & 0 deletions
26
...t/runtime/src/main/java/io/quarkus/smallrye/jwt/runtime/auth/RawOptionalClaimCreator.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,26 @@ | ||
package io.quarkus.smallrye.jwt.runtime.auth; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import javax.enterprise.context.spi.CreationalContext; | ||
import javax.enterprise.inject.spi.InjectionPoint; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.BeanCreator; | ||
import io.quarkus.arc.InjectionPointProvider; | ||
import io.smallrye.jwt.auth.cdi.RawClaimTypeProducer; | ||
|
||
public class RawOptionalClaimCreator implements BeanCreator<Optional<?>> { | ||
|
||
@Override | ||
public Optional<?> create(CreationalContext<Optional<?>> creationalContext, Map<String, Object> params) { | ||
InjectionPoint injectionPoint = InjectionPointProvider.get(); | ||
if (injectionPoint == null) { | ||
throw new IllegalStateException("No current injection point found"); | ||
} | ||
RawClaimTypeProducer rawClaimTypeProducer = Arc.container().instance(RawClaimTypeProducer.class).get(); | ||
return rawClaimTypeProducer.getOptionalValue(injectionPoint); | ||
} | ||
|
||
} |
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
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