use of com.sun.enterprise.deployment.WebComponentDescriptor in project Payara by payara.
the class RealmAdapter method initializeRealm.
@Override
public void initializeRealm(Object descriptor, boolean isSystemApp, String realmName) {
this.isSystemApp = isSystemApp;
webDescriptor = (WebBundleDescriptor) descriptor;
computeRealmName(webDescriptor, realmName);
CONTEXT_ID = WebSecurityManager.getContextID(webDescriptor);
runAsPrincipals = new HashMap<String, String>();
for (WebComponentDescriptor componentDescriptor : webDescriptor.getWebComponentDescriptors()) {
RunAsIdentityDescriptor runAsDescriptor = componentDescriptor.getRunAsIdentity();
if (runAsDescriptor != null) {
String principal = runAsDescriptor.getPrincipal();
String servlet = componentDescriptor.getCanonicalName();
if (principal == null || servlet == null) {
logger.warning("web.realmadapter.norunas");
} else {
runAsPrincipals.put(servlet, principal);
logger.fine("Servlet " + servlet + " will run-as: " + principal);
}
}
}
this.moduleID = webDescriptor.getModuleID();
}
use of com.sun.enterprise.deployment.WebComponentDescriptor in project Payara by payara.
the class ServletWebServiceDelegate method postInit.
@Override
public void postInit(ServletConfig servletConfig) throws ServletException {
String servletName = "unknown";
try {
WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
ComponentEnvManager compEnvManager = wscImpl.getComponentEnvManager();
JndiNameEnvironment jndiNameEnv = compEnvManager.getCurrentJndiNameEnvironment();
WebBundleDescriptor webBundle = null;
if (jndiNameEnv != null && jndiNameEnv instanceof WebBundleDescriptor) {
webBundle = ((WebBundleDescriptor) jndiNameEnv);
} else {
throw new WebServiceException("Cannot intialize the JAXRPCServlet for " + jndiNameEnv);
}
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
servletName = servletConfig.getServletName();
WebComponentDescriptor webComponent = webBundle.getWebComponentByCanonicalName(servletName);
if (webComponent != null) {
WebServicesDescriptor webServices = webBundle.getWebServices();
Collection endpoints = webServices.getEndpointsImplementedBy(webComponent);
// Only 1 endpoint per servlet is supported, even though
// data structure implies otherwise.
endpoint_ = (WebServiceEndpoint) endpoints.iterator().next();
registerEndpoint(classLoader);
// security
if (secServ != null) {
SystemHandlerDelegate securityHandlerDelegate = secServ.getSecurityHandler(endpoint_);
if (securityHandlerDelegate != null) {
rpcDelegate_.setSystemHandlerDelegate(securityHandlerDelegate);
// need to invoke the endpoint lifecylcle
endpointImpl_ = JAXRPCEndpointImpl.class.cast(wsEngine_.createHandler(securityHandlerDelegate, endpoint_));
rpcDelegate_.setSystemHandlerDelegate(endpointImpl_);
}
}
} else {
throw new ServletException(servletName + " not found");
}
} catch (Throwable t) {
String msg = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.SERVLET_ENDPOINT_FAILURE), servletName);
logger.log(Level.WARNING, msg, t);
throw new ServletException(t);
}
}
use of com.sun.enterprise.deployment.WebComponentDescriptor in project Payara by payara.
the class WebServiceContextImpl method setServletName.
void setServletName(Set webComponentDescriptors) {
Iterator it = webComponentDescriptors.iterator();
String endpointName = null;
while (it.hasNext()) {
WebComponentDescriptor desc = (WebComponentDescriptor) it.next();
String name = desc.getCanonicalName();
if (JAXWS_SERVLET.equals(desc.getWebComponentImplementation())) {
endpointName = name;
}
if (desc.getSecurityRoleReferences().hasMoreElements()) {
servletName = name;
break;
}
}
if (servletName == null) {
servletName = endpointName;
}
}
use of com.sun.enterprise.deployment.WebComponentDescriptor in project Payara by payara.
the class WebBundleDescriptorImpl method addWebComponentDescriptor.
/**
* Adds a new Web Component Descriptor to me.
* @param webComponentDescriptor
*/
@Override
public void addWebComponentDescriptor(WebComponentDescriptor webComponentDescriptor) {
String name = webComponentDescriptor.getCanonicalName();
webComponentDescriptor.setWebBundleDescriptor(this);
WebComponentDescriptor resultDesc = combineWebComponentDescriptor(webComponentDescriptor);
// sync up urlPattern2ServletName map
for (String up : resultDesc.getUrlPatternsSet()) {
String oldName = getUrlPatternToServletNameMap().put(up, name);
if (oldName != null && (!oldName.equals(name))) {
throw new IllegalArgumentException(localStrings.getLocalString("web.deployment.exceptionsameurlpattern", "Servlet [{0}] and Servlet [{1}] have the same url pattern: [{2}]", new Object[] { oldName, name, up }));
}
}
}
use of com.sun.enterprise.deployment.WebComponentDescriptor in project Payara by payara.
the class WebBundleRuntimeNode method writeDescriptor.
/**
* write the descriptor class to a DOM tree and return it
*
* @param parent node for the DOM tree
* @param bundleDescriptor the descriptor to write
* @return the DOM tree top node
*/
@Override
public Node writeDescriptor(Node parent, WebBundleDescriptorImpl bundleDescriptor) {
Element web = (Element) super.writeDescriptor(parent, bundleDescriptor);
SunWebAppImpl sunWebApp = (SunWebAppImpl) bundleDescriptor.getSunDescriptor();
// context-root?
appendTextChild(web, RuntimeTagNames.CONTEXT_ROOT, bundleDescriptor.getContextRoot());
// security-role-mapping
SecurityRoleMapping[] roleMappings = sunWebApp.getSecurityRoleMapping();
if (roleMappings != null && roleMappings.length > 0) {
SecurityRoleMappingNode srmn = new SecurityRoleMappingNode();
for (SecurityRoleMapping roleMapping : roleMappings) {
srmn.writeDescriptor(web, RuntimeTagNames.SECURITY_ROLE_MAPPING, roleMapping);
}
}
// servlet
Set servlets = bundleDescriptor.getServletDescriptors();
org.glassfish.web.deployment.node.runtime.gf.ServletNode servletNode = new org.glassfish.web.deployment.node.runtime.gf.ServletNode();
for (Iterator itr = servlets.iterator(); itr.hasNext(); ) {
WebComponentDescriptor servlet = (WebComponentDescriptor) itr.next();
servletNode.writeDescriptor(web, RuntimeTagNames.SERVLET, servlet);
}
// idempotent-url-pattern
IdempotentUrlPattern[] patterns = sunWebApp.getIdempotentUrlPatterns();
if (patterns != null && patterns.length > 0) {
IdempotentUrlPatternNode node = new IdempotentUrlPatternNode();
for (IdempotentUrlPattern pattern : patterns) {
node.writeDescriptor(web, RuntimeTagNames.IDEMPOTENT_URL_PATTERN, pattern);
}
}
// session-config?
if (sunWebApp.getSessionConfig() != null) {
SessionConfigNode scn = new SessionConfigNode();
scn.writeDescriptor(web, RuntimeTagNames.SESSION_CONFIG, sunWebApp.getSessionConfig());
}
// ejb-ref*
Set<EjbReference> ejbRefs = bundleDescriptor.getEjbReferenceDescriptors();
if (ejbRefs.size() > 0) {
EjbRefNode node = new EjbRefNode();
for (EjbReference ejbRef : ejbRefs) {
node.writeDescriptor(web, RuntimeTagNames.EJB_REF, ejbRef);
}
}
// resource-ref*
Set<ResourceReferenceDescriptor> resourceRefs = bundleDescriptor.getResourceReferenceDescriptors();
if (resourceRefs.size() > 0) {
ResourceRefNode node = new ResourceRefNode();
for (ResourceReferenceDescriptor resourceRef : resourceRefs) {
node.writeDescriptor(web, RuntimeTagNames.RESOURCE_REF, resourceRef);
}
}
// resource-env-ref*
Set<ResourceEnvReferenceDescriptor> resourceEnvRefs = bundleDescriptor.getResourceEnvReferenceDescriptors();
if (resourceEnvRefs.size() > 0) {
ResourceEnvRefNode node = new ResourceEnvRefNode();
for (ResourceEnvReferenceDescriptor resourceEnvRef : resourceEnvRefs) {
node.writeDescriptor(web, RuntimeTagNames.RESOURCE_ENV_REF, resourceEnvRef);
}
}
// service-ref*
if (bundleDescriptor.hasServiceReferenceDescriptors()) {
ServiceRefNode serviceNode = new ServiceRefNode();
for (ServiceReferenceDescriptor next : bundleDescriptor.getServiceReferenceDescriptors()) {
serviceNode.writeDescriptor(web, WebServicesTagNames.SERVICE_REF, next);
}
}
// message-destination-ref*
MessageDestinationRefNode.writeMessageDestinationReferences(web, bundleDescriptor);
// cache?
Cache cache = sunWebApp.getCache();
if (cache != null) {
CacheNode cn = new CacheNode();
cn.writeDescriptor(web, RuntimeTagNames.CACHE, cache);
}
// class-loader?
ClassLoader classLoader = sunWebApp.getClassLoader();
if (classLoader != null) {
ClassLoaderNode cln = new ClassLoaderNode();
cln.writeDescriptor(web, RuntimeTagNames.CLASS_LOADER, classLoader);
}
// jsp-config?
if (sunWebApp.getJspConfig() != null) {
WebPropertyNode propertyNode = new WebPropertyNode();
Node jspConfig = appendChild(web, RuntimeTagNames.JSP_CONFIG);
propertyNode.writeDescriptor(jspConfig, RuntimeTagNames.PROPERTY, sunWebApp.getJspConfig().getWebProperty());
}
// locale-charset-info?
if (sunWebApp.getLocaleCharsetInfo() != null) {
LocaleCharsetInfoNode localeNode = new LocaleCharsetInfoNode();
localeNode.writeDescriptor(web, RuntimeTagNames.LOCALE_CHARSET_INFO, sunWebApp.getLocaleCharsetInfo());
}
// parameter-encoding?
if (sunWebApp.isParameterEncoding()) {
Element parameter = appendChild(web, RuntimeTagNames.PARAMETER_ENCODING);
if (sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.FORM_HINT_FIELD) != null) {
setAttribute(parameter, RuntimeTagNames.FORM_HINT_FIELD, sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.FORM_HINT_FIELD));
}
if (sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.DEFAULT_CHARSET) != null) {
setAttribute(parameter, RuntimeTagNames.DEFAULT_CHARSET, sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.DEFAULT_CHARSET));
}
}
// property*
WebPropertyNode props = new WebPropertyNode();
props.writeDescriptor(web, RuntimeTagNames.PROPERTY, sunWebApp.getWebProperty());
// valve*
if (sunWebApp.getValve() != null) {
ValveNode valve = new ValveNode();
valve.writeDescriptor(web, RuntimeTagNames.VALVE, sunWebApp.getValve());
}
// message-destination*
RuntimeDescriptorNode.writeMessageDestinationInfo(web, bundleDescriptor);
// webservice-description*
WebServiceRuntimeNode webServiceNode = new WebServiceRuntimeNode();
webServiceNode.writeWebServiceRuntimeInfo(web, bundleDescriptor);
// error-url
if (sunWebApp.getAttributeValue(SunWebApp.ERROR_URL) != null) {
setAttribute(web, RuntimeTagNames.ERROR_URL, sunWebApp.getAttributeValue(SunWebApp.ERROR_URL));
}
// httpservlet-security-provider
if (sunWebApp.getAttributeValue(SunWebApp.HTTPSERVLET_SECURITY_PROVIDER) != null) {
setAttribute(web, RuntimeTagNames.HTTPSERVLET_SECURITY_PROVIDER, sunWebApp.getAttributeValue(SunWebApp.HTTPSERVLET_SECURITY_PROVIDER));
}
// keep-state
appendTextChild(web, RuntimeTagNames.KEEP_STATE, String.valueOf(bundleDescriptor.getKeepState()));
return web;
}
Aggregations