All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.security.deployment.DenyingUnannotatedTransformer Maven / Gradle / Ivy

There is a newer version: 3.17.0.CR1
Show newest version
package io.quarkus.security.deployment;

import static io.quarkus.security.deployment.SecurityTransformerUtils.DENY_ALL;

import java.util.List;

import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.MethodInfo;

import io.quarkus.arc.processor.AnnotationsTransformer;

/**
 * @author Michal Szynkiewicz, [email protected]
 */
public class DenyingUnannotatedTransformer implements AnnotationsTransformer {

    @Override
    public boolean appliesTo(AnnotationTarget.Kind kind) {
        return kind == AnnotationTarget.Kind.CLASS;
    }

    @Override
    public void transform(TransformationContext transformationContext) {
        ClassInfo classInfo = transformationContext.getTarget().asClass();
        List methods = classInfo.methods();
        if (!SecurityTransformerUtils.hasStandardSecurityAnnotation(classInfo)
                && methods.stream().anyMatch(SecurityTransformerUtils::hasStandardSecurityAnnotation)) {
            transformationContext.transform().add(DENY_ALL).done();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy