Package org.jboss.metadata.web.spec

Examples of org.jboss.metadata.web.spec.ServletSecurityMetaData


* @author Remy Maucherat
*/
public class ServletSecurityMetaDataParser extends MetaDataElementParser {

    public static ServletSecurityMetaData parse(XMLStreamReader reader) throws XMLStreamException {
        ServletSecurityMetaData servletSecurity = new ServletSecurityMetaData();

        // Handle elements
        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case HTTP_METHOD_CONSTRAINT:
                    List<HttpMethodConstraintMetaData> httpMethodConstraints = servletSecurity.getHttpMethodConstraints();
                    if (httpMethodConstraints == null) {
                        httpMethodConstraints = new ArrayList<HttpMethodConstraintMetaData>();
                        servletSecurity.setHttpMethodConstraints(httpMethodConstraints);
                    }
                    httpMethodConstraints.add(HttpMethodConstraintMetaDataParser.parse(reader));
                    break;
                case EMPTY_ROLE_SEMANTIC:
                    servletSecurity.setEmptyRoleSemantic(EmptyRoleSemanticType.valueOf(reader.getElementText()));
                    break;
                case TRANSPORT_GUARANTEE:
                    servletSecurity.setTransportGuarantee(TransportGuaranteeType.valueOf(reader.getElementText()));
                    break;
                case ROLE_ALLOWED:
                    List<String> rolesAllowed = servletSecurity.getRolesAllowed();
                    if (rolesAllowed == null) {
                        rolesAllowed = new ArrayList<String>();
                        servletSecurity.setRolesAllowed(rolesAllowed);
                    }
                    rolesAllowed.add(reader.getElementText());
                    break;
                default: throw unexpectedElement(reader);
            }
View Full Code Here


                            multipartConfig.setFileSizeThreshold(multipartConfigMetaData.getFileSizeThreshold());
                            wrapper.setMultipartConfig(multipartConfig);
                        }
                        // Merge @ServletSecurity
                        if (annotation.getServletSecurity() != null && wrapper.getServletSecurity() == null) {
                            ServletSecurityMetaData servletSecurityAnnotation = annotation.getServletSecurity();
                            Collection<HttpMethodConstraintElement> methodConstraints = null;

                            EmptyRoleSemantic emptyRoleSemantic = EmptyRoleSemantic.PERMIT;
                            if (servletSecurityAnnotation.getEmptyRoleSemantic() != null) {
                                emptyRoleSemantic = EmptyRoleSemantic.valueOf(servletSecurityAnnotation.getEmptyRoleSemantic()
                                        .toString());
                            }
                            TransportGuarantee transportGuarantee = TransportGuarantee.NONE;
                            if (servletSecurityAnnotation.getTransportGuarantee() != null) {
                                transportGuarantee = TransportGuarantee.valueOf(servletSecurityAnnotation
                                        .getTransportGuarantee().toString());
                            }
                            String[] roleNames = servletSecurityAnnotation.getRolesAllowed().toArray(new String[0]);
                            HttpConstraintElement constraint = new HttpConstraintElement(emptyRoleSemantic, transportGuarantee,
                                    roleNames);

                            if (servletSecurityAnnotation.getHttpMethodConstraints() != null) {
                                methodConstraints = new HashSet<HttpMethodConstraintElement>();
                                for (HttpMethodConstraintMetaData annotationMethodConstraint : servletSecurityAnnotation
                                        .getHttpMethodConstraints()) {
                                    emptyRoleSemantic = EmptyRoleSemantic.PERMIT;
                                    if (annotationMethodConstraint.getEmptyRoleSemantic() != null) {
                                        emptyRoleSemantic = EmptyRoleSemantic.valueOf(annotationMethodConstraint
                                                .getEmptyRoleSemantic().toString());
View Full Code Here

TOP

Related Classes of org.jboss.metadata.web.spec.ServletSecurityMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.