use of org.jboss.wsf.spi.deployment.Endpoint in project wildfly by wildfly.
the class ModelDeploymentAspect method start.
@Override
public void start(final Deployment dep) {
final DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class);
if (unit instanceof WSEndpointDeploymentUnit)
return;
final DeploymentResourceSupport deploymentResourceSupport = unit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
for (final Endpoint endpoint : dep.getService().getEndpoints()) {
final ModelNode endpointModel;
try {
endpointModel = deploymentResourceSupport.getDeploymentSubModel(WSExtension.SUBSYSTEM_NAME, PathElement.pathElement(ENDPOINT, URLEncoder.encode(getId(endpoint), "UTF-8")));
} catch (final UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
endpointModel.get(ENDPOINT_NAME).set(getName(endpoint));
endpointModel.get(ENDPOINT_CONTEXT).set(getContext(endpoint));
endpointModel.get(ENDPOINT_CLASS).set(endpoint.getTargetBeanName());
endpointModel.get(ENDPOINT_TYPE).set(endpoint.getType().toString());
endpointModel.get(ENDPOINT_WSDL).set(endpoint.getAddress() + "?wsdl");
}
}
use of org.jboss.wsf.spi.deployment.Endpoint in project wildfly by wildfly.
the class WSEndpointMetrics method getEndpointMetricsFragment.
@SuppressWarnings("unchecked")
private ModelNode getEndpointMetricsFragment(final ModelNode operation, final ServiceRegistry registry) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
String endpointId;
try {
endpointId = URLDecoder.decode(address.getLastElement().getValue(), "UTF-8");
} catch (final UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
final String metricName = operation.require(NAME).asString();
final String webContext = endpointId.substring(0, endpointId.indexOf(":"));
final String endpointName = endpointId.substring(endpointId.indexOf(":") + 1);
ServiceName endpointServiceName = WSServices.ENDPOINT_SERVICE.append("context=" + webContext).append(endpointName);
ServiceController<Endpoint> service = (ServiceController<Endpoint>) currentServiceContainer().getService(endpointServiceName);
Endpoint endpoint = service.getValue();
if (endpoint == null) {
throw new OperationFailedException(WSLogger.ROOT_LOGGER.noMetricsAvailable());
}
final ModelNode result = new ModelNode();
final EndpointMetrics endpointMetrics = endpoint.getEndpointMetrics();
if (MIN_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getMinProcessingTime());
} else if (MAX_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getMaxProcessingTime());
} else if (AVERAGE_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getAverageProcessingTime());
} else if (TOTAL_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getTotalProcessingTime());
} else if (REQUEST_COUNT.getName().equals(metricName)) {
result.set(endpointMetrics.getRequestCount());
} else if (RESPONSE_COUNT.getName().equals(metricName)) {
result.set(endpointMetrics.getResponseCount());
} else if (FAULT_COUNT.getName().equals(metricName)) {
result.set(endpointMetrics.getFaultCount());
}
return result;
}
use of org.jboss.wsf.spi.deployment.Endpoint in project wildfly by wildfly.
the class WebMetaDataModifier method configureEndpoints.
/**
* Configures transport servlet class for every found webservice endpoint.
*
* @param dep webservice deployment
* @param jbossWebMD web meta data
*/
private void configureEndpoints(final Deployment dep, final JBossWebMetaData jbossWebMD) {
final String transportClassName = this.getTransportClassName(dep);
WSLogger.ROOT_LOGGER.trace("Modifying servlets");
// get a list of the endpoint bean class names
final Set<String> epNames = new HashSet<String>();
for (Endpoint ep : dep.getService().getEndpoints()) {
epNames.add(ep.getTargetBeanName());
}
// fix servlet class names for endpoints
for (final ServletMetaData servletMD : jbossWebMD.getServlets()) {
final String endpointClassName = ASHelper.getEndpointClassName(servletMD);
if (endpointClassName != null && endpointClassName.length() > 0) {
// exclude JSP
if (epNames.contains(endpointClassName)) {
// set transport servlet
servletMD.setServletClass(WSFServlet.class.getName());
WSLogger.ROOT_LOGGER.tracef("Setting transport class: %s for endpoint: %s", transportClassName, endpointClassName);
final List<ParamValueMetaData> initParams = WebMetaDataHelper.getServletInitParams(servletMD);
// configure transport class name
WebMetaDataHelper.newParamValue(WSFServlet.STACK_SERVLET_DELEGATE_CLASS, transportClassName, initParams);
// configure webservice endpoint
WebMetaDataHelper.newParamValue(Endpoint.SEPID_DOMAIN_ENDPOINT, endpointClassName, initParams);
} else if (endpointClassName.startsWith("org.apache.cxf")) {
throw WSLogger.ROOT_LOGGER.invalidWSServlet(endpointClassName);
}
}
}
}
use of org.jboss.wsf.spi.deployment.Endpoint in project wildfly by wildfly.
the class WebMetaDataCreator method getRealmName.
private String getRealmName(final Deployment dep) {
for (final Endpoint ejbEndpoint : dep.getService().getEndpoints()) {
final String realmName = ejb3SecurityAccessor.getRealmName(ejbEndpoint);
final boolean hasRealmName = realmName != null;
if (hasRealmName) {
return realmName;
}
}
return null;
}
use of org.jboss.wsf.spi.deployment.Endpoint in project wildfly by wildfly.
the class WebMetaDataCreator method createSecurityConstraints.
/**
* Creates security constraints part of web.xml descriptor.
* <p/>
* <pre>
* <security-constraint>
* <web-resource-collection>
* <web-resource-name>EJBEndpointShortName</web-resource-name>
* <url-pattern>EJBEndpointURLPattern</url-pattern>
* <http-method>GET</http-method>
* <http-method>POST</http-method>
* </web-resource-collection>
* <auth-constraint>
* <role-name>*</role-name>
* </auth-constraint>
* <user-data-constraint>
* <transport-guarantee>EjbTransportGuarantee</transport-guarantee>
* </user-data-constraint>
* </security-constraint>
* </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);
}
}
}
}
Aggregations