ru.hts.springwebdoclet.annotation.method.RolesAllowedAnnotationHandler Maven / Gradle / Ivy
package ru.hts.springwebdoclet.annotation.method;
import com.sun.javadoc.AnnotationDesc;
import com.sun.javadoc.AnnotationValue;
import ru.hts.springwebdoclet.annotation.AnnotationHandler;
import ru.hts.springwebdoclet.render.RenderContext;
import javax.annotation.security.RolesAllowed;
import java.util.ArrayList;
import java.util.List;
/**
* Processes @RolesAllowed
annotation
* @author Ivan Sungurov
*/
public class RolesAllowedAnnotationHandler implements AnnotationHandler {
@Override
public RenderContext handle(AnnotationDesc annotationDoc, Object target) {
RenderContext context = new RenderContext();
List roles = new ArrayList();
for (AnnotationDesc.ElementValuePair param : annotationDoc.elementValues()) {
if ("value".equals(param.element().name())) {
AnnotationValue[] values = (AnnotationValue[]) param.value().value();
for (AnnotationValue value : values) {
roles.add(value.value().toString());
}
}
}
context.put("roles", roles);
return context;
}
@Override
public Class getSupportedAnnotation() {
return RolesAllowed.class;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy