Search in sources :

Example 1 with HttpEndpoint

use of org.jboss.wsf.spi.deployment.HttpEndpoint in project wildfly by wildfly.

the class WebMetaDataCreator method createSecurityConstraints.

/**
     * Creates security constraints part of web.xml descriptor.
     * <p/>
     * <pre>
     * &lt;security-constraint&gt;
     *   &lt;web-resource-collection&gt;
     *     &lt;web-resource-name&gt;EJBEndpointShortName&lt;/web-resource-name&gt;
     *     &lt;url-pattern&gt;EJBEndpointURLPattern&lt;/url-pattern&gt;
     *     &lt;http-method&gt;GET&lt;/http-method&gt;
     *     &lt;http-method&gt;POST&lt;/http-method&gt;
     *   &lt;/web-resource-collection&gt;
     *   &lt;auth-constraint&gt;
     *     &lt;role-name&gt;*&lt;/role-name&gt;
     *   &lt;/auth-constraint&gt;
     *   &lt;user-data-constraint&gt;
     *     &lt;transport-guarantee&gt;EjbTransportGuarantee&lt;/transport-guarantee&gt;
     *   &lt;/user-data-constraint&gt;
     * &lt;/security-constraint&gt;
     * </pre>
     *
     * @param dep        webservice deployment
     * @param jbossWebMD jboss web meta data
     */
private void createSecurityConstraints(final Deployment dep, final JBossWebMetaData jbossWebMD) {
    WSLogger.ROOT_LOGGER.trace("Creating security constraints");
    for (final Endpoint ejbEndpoint : dep.getService().getEndpoints()) {
        final boolean secureWsdlAccess = ejb3SecurityAccessor.isSecureWsdlAccess(ejbEndpoint);
        final String transportGuarantee = ejb3SecurityAccessor.getTransportGuarantee(ejbEndpoint);
        final boolean hasTransportGuarantee = transportGuarantee != null;
        final String authMethod = ejb3SecurityAccessor.getAuthMethod(ejbEndpoint);
        final boolean hasAuthMethod = authMethod != null;
        if (ejbEndpoint instanceof HttpEndpoint && (hasAuthMethod || hasTransportGuarantee)) {
            final List<SecurityConstraintMetaData> securityConstraints = WebMetaDataHelper.getSecurityConstraints(jbossWebMD);
            // security-constraint
            final SecurityConstraintMetaData securityConstraint = WebMetaDataHelper.newSecurityConstraint(securityConstraints);
            // web-resource-collection
            final WebResourceCollectionsMetaData webResourceCollections = WebMetaDataHelper.getWebResourceCollections(securityConstraint);
            final String endpointName = ejbEndpoint.getShortName();
            final String urlPattern = ((HttpEndpoint) ejbEndpoint).getURLPattern();
            WSLogger.ROOT_LOGGER.tracef("Creating web resource collection for endpoint: %s, URL pattern: %s", endpointName, urlPattern);
            WebMetaDataHelper.newWebResourceCollection(endpointName, urlPattern, secureWsdlAccess, webResourceCollections);
            // auth-constraint
            if (hasAuthMethod) {
                WSLogger.ROOT_LOGGER.tracef("Creating auth constraint for endpoint: %s", endpointName);
                WebMetaDataHelper.newAuthConstraint(WebMetaDataHelper.getAllRoles(), securityConstraint);
            }
            // user-data-constraint
            if (hasTransportGuarantee) {
                WSLogger.ROOT_LOGGER.tracef("Creating new user data constraint for endpoint: %s, transport guarantee: %s", endpointName, transportGuarantee);
                WebMetaDataHelper.newUserDataConstraint(transportGuarantee, securityConstraint);
            }
        }
    }
}
Also used : WebResourceCollectionsMetaData(org.jboss.metadata.web.spec.WebResourceCollectionsMetaData) HttpEndpoint(org.jboss.wsf.spi.deployment.HttpEndpoint) Endpoint(org.jboss.wsf.spi.deployment.Endpoint) HttpEndpoint(org.jboss.wsf.spi.deployment.HttpEndpoint) SecurityConstraintMetaData(org.jboss.metadata.web.spec.SecurityConstraintMetaData)

Example 2 with HttpEndpoint

use of org.jboss.wsf.spi.deployment.HttpEndpoint in project wildfly by wildfly.

the class WebMetaDataCreator method createServletMappings.

/**
     * Creates servlet-mapping part of web.xml descriptor.
     * <p/>
     * <pre>
     * &lt;servlet-mapping&gt;
     *   &lt;servlet-name&gt;EJBEndpointShortName&lt;/servlet-name&gt;
     *   &lt;url-pattern&gt;EJBEndpointURLPattern&lt;/url-pattern&gt;
     * &lt;/servlet-mapping&gt;
     * </pre>
     *
     * @param dep        webservice deployment
     * @param jbossWebMD jboss web meta data
     */
private void createServletMappings(final Deployment dep, final JBossWebMetaData jbossWebMD) {
    WSLogger.ROOT_LOGGER.trace("Creating servlet mappings");
    final List<ServletMappingMetaData> servletMappings = WebMetaDataHelper.getServletMappings(jbossWebMD);
    for (final Endpoint ep : dep.getService().getEndpoints()) {
        if (ep instanceof HttpEndpoint) {
            final String endpointName = ep.getShortName();
            final List<String> urlPatterns = WebMetaDataHelper.getUrlPatterns(((HttpEndpoint) ep).getURLPattern());
            WSLogger.ROOT_LOGGER.tracef("Servlet name: %s, URL patterns: %s", endpointName, urlPatterns);
            WebMetaDataHelper.newServletMapping(endpointName, urlPatterns, servletMappings);
        }
    }
}
Also used : ServletMappingMetaData(org.jboss.metadata.web.spec.ServletMappingMetaData) HttpEndpoint(org.jboss.wsf.spi.deployment.HttpEndpoint) Endpoint(org.jboss.wsf.spi.deployment.Endpoint) HttpEndpoint(org.jboss.wsf.spi.deployment.HttpEndpoint)

Aggregations

Endpoint (org.jboss.wsf.spi.deployment.Endpoint)2 HttpEndpoint (org.jboss.wsf.spi.deployment.HttpEndpoint)2 SecurityConstraintMetaData (org.jboss.metadata.web.spec.SecurityConstraintMetaData)1 ServletMappingMetaData (org.jboss.metadata.web.spec.ServletMappingMetaData)1 WebResourceCollectionsMetaData (org.jboss.metadata.web.spec.WebResourceCollectionsMetaData)1