forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#44306 from michalvavrik/feature/security…
…-extension-refactoring Replace deprecated methods and classes in Quarkus Security and tiny bit of refactoring
- Loading branch information
Showing
11 changed files
with
111 additions
and
111 deletions.
There are no files selected for viewing
29 changes: 15 additions & 14 deletions
29
...src/main/java/io/quarkus/security/deployment/AdditionalDenyingUnannotatedTransformer.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,35 +1,36 @@ | ||
package io.quarkus.security.deployment; | ||
|
||
import static io.quarkus.security.deployment.SecurityProcessor.createMethodDescription; | ||
import static io.quarkus.security.spi.SecurityTransformerUtils.DENY_ALL; | ||
|
||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.function.Consumer; | ||
import java.util.function.Predicate; | ||
|
||
import org.jboss.jandex.AnnotationTarget; | ||
import jakarta.annotation.security.DenyAll; | ||
|
||
import org.jboss.jandex.AnnotationTransformation; | ||
import org.jboss.jandex.MethodInfo; | ||
|
||
import io.quarkus.arc.processor.AnnotationsTransformer; | ||
import io.quarkus.security.spi.runtime.MethodDescription; | ||
|
||
public class AdditionalDenyingUnannotatedTransformer implements AnnotationsTransformer { | ||
final class AdditionalDenyingUnannotatedTransformer | ||
implements Predicate<MethodInfo>, Consumer<AnnotationTransformation.TransformationContext> { | ||
|
||
private final Set<MethodDescription> methods; | ||
|
||
public AdditionalDenyingUnannotatedTransformer(Collection<MethodDescription> methods) { | ||
this.methods = new HashSet<>(methods); | ||
AdditionalDenyingUnannotatedTransformer(Collection<MethodDescription> methods) { | ||
this.methods = Set.copyOf(methods); | ||
} | ||
|
||
@Override | ||
public boolean appliesTo(AnnotationTarget.Kind kind) { | ||
return kind == AnnotationTarget.Kind.METHOD; | ||
public void accept(AnnotationTransformation.TransformationContext ctx) { | ||
ctx.add(DenyAll.class); | ||
} | ||
|
||
@Override | ||
public void transform(TransformationContext context) { | ||
MethodDescription methodDescription = createMethodDescription(context.getTarget().asMethod()); | ||
if (methods.contains(methodDescription)) { | ||
context.transform().add(DENY_ALL).done(); | ||
} | ||
public boolean test(MethodInfo methodInfo) { | ||
MethodDescription methodDescription = createMethodDescription(methodInfo); | ||
return methods.contains(methodDescription); | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
...ity/deployment/src/main/java/io/quarkus/security/deployment/DenyUnannotatedPredicate.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,19 @@ | ||
package io.quarkus.security.deployment; | ||
|
||
import java.util.List; | ||
import java.util.function.Predicate; | ||
|
||
import org.jboss.jandex.ClassInfo; | ||
import org.jboss.jandex.MethodInfo; | ||
|
||
import io.quarkus.security.spi.SecurityTransformerUtils; | ||
|
||
final class DenyUnannotatedPredicate implements Predicate<ClassInfo> { | ||
|
||
@Override | ||
public boolean test(ClassInfo classInfo) { | ||
List<MethodInfo> methods = classInfo.methods(); | ||
return !SecurityTransformerUtils.hasSecurityAnnotation(classInfo) | ||
&& methods.stream().anyMatch(SecurityTransformerUtils::hasSecurityAnnotation); | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
...eployment/src/main/java/io/quarkus/security/deployment/DenyingUnannotatedTransformer.java
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.