use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class DynamicWebServletRegistrationImpl method removePatternFromServlet.
@Override
protected void removePatternFromServlet(Wrapper wrapper, String pattern) {
super.removePatternFromServlet(wrapper, pattern);
WebBundleDescriptor wbd = getWebBundleDescriptor();
if (wbd == null) {
throw new IllegalStateException("Missing WebBundleDescriptor for " + getName());
}
WebComponentDescriptor wcd = wbd.getWebComponentByCanonicalName(wrapper.getName());
if (wcd == null) {
throw new IllegalStateException("Missing WebComponentDescriptor for " + wrapper.getName());
}
wcd.removeUrlPattern(pattern);
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class DynamicWebServletRegistrationImpl method declareRoles.
@Override
public void declareRoles(String... roleNames) {
super.declareRoles(roleNames);
WebBundleDescriptor bundleDescriptor = getWebBundleDescriptor();
for (String roleName : roleNames) {
bundleDescriptor.addRole(new Role(roleName));
}
bundleDescriptor.setPolicyModified(true);
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class ServletSecurityHandler method processAnnotation.
private HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, WebComponentDescriptor webCompDesc) throws AnnotationProcessorException {
Class webCompClass = (Class) ainfo.getAnnotatedElement();
if (!HttpServlet.class.isAssignableFrom(webCompClass)) {
log(Level.SEVERE, ainfo, localStrings.getLocalString("web.deployment.annotation.handlers.needtoextend", "The Class {0} having annotation {1} need to be a derived class of {2}.", new Object[] { webCompClass.getName(), SecurityConstraint.class.getName(), HttpServlet.class.getName() }));
return getDefaultFailedResult();
}
Set<String> urlPatterns = getUrlPatternsWithoutSecurityConstraint(webCompDesc);
if (urlPatterns.size() > 0) {
WebBundleDescriptor webBundleDesc = webCompDesc.getWebBundleDescriptor();
ServletSecurity servletSecurityAn = (ServletSecurity) ainfo.getAnnotation();
HttpMethodConstraint[] httpMethodConstraints = servletSecurityAn.httpMethodConstraints();
for (HttpMethodConstraint httpMethodConstraint : httpMethodConstraints) {
String httpMethod = httpMethodConstraint.value();
if (httpMethod == null || httpMethod.length() == 0) {
return getDefaultFailedResult();
}
createSecurityConstraint(webBundleDesc, urlPatterns, httpMethodConstraint.rolesAllowed(), httpMethodConstraint.emptyRoleSemantic(), httpMethodConstraint.transportGuarantee(), httpMethod);
}
HttpConstraint httpConstraint = servletSecurityAn.value();
boolean isDefault = isDefaultHttpConstraint(httpConstraint);
if (isDefault && (httpMethodConstraints.length > 0)) {
if (logger.isLoggable(Level.FINER)) {
StringBuilder methodString = new StringBuilder();
for (HttpMethodConstraint httpMethodConstraint : httpMethodConstraints) {
methodString.append(" ");
methodString.append(httpMethodConstraint.value());
}
for (String pattern : urlPatterns) {
logger.finer("Pattern: " + pattern + " assumes default unprotected configuration for all methods except:" + methodString);
}
}
}
if (!isDefault || (httpMethodConstraints.length == 0)) {
SecurityConstraint securityConstraint = createSecurityConstraint(webBundleDesc, urlPatterns, httpConstraint.rolesAllowed(), httpConstraint.value(), httpConstraint.transportGuarantee(), null);
// we know there is one WebResourceCollection there
WebResourceCollection webResColl = securityConstraint.getWebResourceCollections().iterator().next();
for (HttpMethodConstraint httpMethodConstraint : httpMethodConstraints) {
// exclude constrained httpMethod from the top level constraint
webResColl.addHttpMethodOmission(httpMethodConstraint.value());
}
}
}
return getDefaultProcessedResult();
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class ActiveJmsResourceAdapter method getJMSDestination.
/*
* Get JMS destination resource from application
*/
private JMSDestinationDefinitionDescriptor getJMSDestination(String logicalDestination, Application application) {
if (application == null) {
return null;
}
JMSDestinationDefinitionDescriptor destination = getJMSDestination(logicalDestination, application.getResourceDescriptors(JavaEEResourceType.JMSDD));
if (isValidDestination(destination)) {
return destination;
}
Set<WebBundleDescriptor> webBundleDescriptors = application.getBundleDescriptors(WebBundleDescriptor.class);
for (WebBundleDescriptor webBundleDescriptor : webBundleDescriptors) {
destination = getJMSDestination(logicalDestination, webBundleDescriptor.getResourceDescriptors(JavaEEResourceType.JMSDD));
if (isValidDestination(destination)) {
return destination;
}
}
Set<EjbBundleDescriptor> ejbBundleDescriptors = application.getBundleDescriptors(EjbBundleDescriptor.class);
for (EjbBundleDescriptor ejbBundleDescriptor : ejbBundleDescriptors) {
destination = getJMSDestination(logicalDestination, ejbBundleDescriptor);
if (isValidDestination(destination)) {
return destination;
}
}
Set<ApplicationClientDescriptor> appClientDescriptors = application.getBundleDescriptors(ApplicationClientDescriptor.class);
for (ApplicationClientDescriptor appClientDescriptor : appClientDescriptors) {
destination = getJMSDestination(logicalDestination, appClientDescriptor.getResourceDescriptors(JavaEEResourceType.JMSDD));
if (isValidDestination(destination)) {
return destination;
}
}
return null;
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class ActiveJmsResourceAdapter method getJMSDestination.
/*
* Get JMS destination resource from web module
*/
private JMSDestinationDefinitionDescriptor getJMSDestination(String logicalDestination, ModuleDescriptor moduleDescriptor) {
WebBundleDescriptor webBundleDescriptor = (WebBundleDescriptor) moduleDescriptor.getDescriptor();
JMSDestinationDefinitionDescriptor destination = getJMSDestination(logicalDestination, webBundleDescriptor.getResourceDescriptors(JavaEEResourceType.JMSDD));
if (isValidDestination(destination)) {
return destination;
}
Collection<EjbBundleDescriptor> ejbBundleDescriptors = moduleDescriptor.getDescriptor().getExtensionsDescriptors(EjbBundleDescriptor.class);
for (EjbBundleDescriptor ejbBundleDescriptor : ejbBundleDescriptors) {
destination = getJMSDestination(logicalDestination, ejbBundleDescriptor);
if (isValidDestination(destination)) {
return destination;
}
}
return null;
}
Aggregations