-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid using deprecated InterceptorBindingRegistrar#registerAdditional…
…Bindings
- Loading branch information
Showing
4 changed files
with
24 additions
and
40 deletions.
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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import java.util.Collection; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import javax.annotation.security.DenyAll; | ||
import javax.annotation.security.RolesAllowed; | ||
|
@@ -12,13 +13,16 @@ | |
import org.jboss.jandex.DotName; | ||
import org.jboss.jandex.MethodInfo; | ||
|
||
import io.quarkus.arc.processor.InterceptorBindingRegistrar; | ||
|
||
/** | ||
* @author Michal Szynkiewicz, [email protected] | ||
*/ | ||
public class SecurityTransformerUtils { | ||
public static final DotName DENY_ALL = DotName.createSimple(DenyAll.class.getName()); | ||
public static final DotName ROLES_ALLOWED = DotName.createSimple(RolesAllowed.class.getName()); | ||
private static final Set<DotName> SECURITY_ANNOTATIONS = SecurityAnnotationsRegistrar.SECURITY_BINDINGS.keySet(); | ||
private static final Set<DotName> SECURITY_ANNOTATIONS = SecurityAnnotationsRegistrar.SECURITY_BINDINGS.stream() | ||
.map(InterceptorBindingRegistrar.InterceptorBinding::getName).collect(Collectors.toSet()); | ||
|
||
public static boolean hasStandardSecurityAnnotation(MethodInfo methodInfo) { | ||
return hasStandardSecurityAnnotation(methodInfo.annotations()); | ||
|
16 changes: 5 additions & 11 deletions
16
...c/main/java/io/quarkus/spring/security/deployment/SpringSecurityAnnotationsRegistrar.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 |
---|---|---|
@@ -1,27 +1,21 @@ | ||
package io.quarkus.spring.security.deployment; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.List; | ||
|
||
import org.jboss.jandex.DotName; | ||
import org.springframework.security.access.annotation.Secured; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
|
||
import io.quarkus.arc.processor.InterceptorBindingRegistrar; | ||
|
||
public class SpringSecurityAnnotationsRegistrar implements InterceptorBindingRegistrar { | ||
|
||
public static final Map<DotName, Set<String>> SECURITY_BINDINGS = new HashMap<>(); | ||
|
||
static { | ||
SECURITY_BINDINGS.put(DotName.createSimple(Secured.class.getName()), Collections.singleton("value")); | ||
SECURITY_BINDINGS.put(DotName.createSimple(PreAuthorize.class.getName()), Collections.singleton("value")); | ||
} | ||
private static final List<InterceptorBinding> SECURITY_BINDINGS = List.of( | ||
InterceptorBinding.of(Secured.class, Collections.singleton("value")), | ||
InterceptorBinding.of(PreAuthorize.class, Collections.singleton("value"))); | ||
|
||
@Override | ||
public Map<DotName, Set<String>> registerAdditionalBindings() { | ||
public List<InterceptorBinding> getAdditionalBindings() { | ||
return SECURITY_BINDINGS; | ||
} | ||
} |
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