use of com.sun.enterprise.deployment.EjbDescriptor in project Payara by payara.
the class SecIORInterceptor method addCSIv2Components.
private void addCSIv2Components(IORInfo iorInfo) {
EjbDescriptor desc = null;
try {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ".addCSIv2Components->: " + " " + iorInfo);
}
if (cluster != null && cluster.isEnabled()) {
// CSIv2SSLTaggedComponentHandler.
return;
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ".addCSIv2Components ");
}
// ORB orb = helper.getORB();
int sslMutualAuthPort = getServerPort("SSL_MUTUALAUTH");
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ".addCSIv2Components: sslMutualAuthPort: " + sslMutualAuthPort);
}
CSIV2TaggedComponentInfo ctc = new CSIV2TaggedComponentInfo(orb, sslMutualAuthPort);
desc = ctc.getEjbDescriptor(iorInfo);
// Create CSIv2 tagged component
int sslport = getServerPort("SSL");
// }
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ".addCSIv2Components: sslport: " + sslport);
}
TaggedComponent csiv2Comp = null;
if (desc != null) {
csiv2Comp = ctc.createSecurityTaggedComponent(sslport, desc);
} else {
// this is not an EJB object, must be a non-EJB CORBA object
csiv2Comp = ctc.createSecurityTaggedComponent(sslport);
}
iorInfo.add_ior_component(csiv2Comp);
} finally {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ".addCSIv2Components<-: " + " " + iorInfo + " " + desc);
}
}
}
use of com.sun.enterprise.deployment.EjbDescriptor in project Payara by payara.
the class ActiveJmsResourceAdapter method getJMSDestination.
/*
* Get JMS destination resource from ejb module
*/
private JMSDestinationDefinitionDescriptor getJMSDestination(String logicalDestination, EjbBundleDescriptor ejbBundleDescriptor) {
JMSDestinationDefinitionDescriptor destination = getJMSDestination(logicalDestination, ejbBundleDescriptor.getResourceDescriptors(JavaEEResourceType.JMSDD));
if (isValidDestination(destination)) {
return destination;
}
Set<EjbDescriptor> ejbDescriptors = (Set<EjbDescriptor>) ejbBundleDescriptor.getEjbs();
for (EjbDescriptor ejbDescriptor : ejbDescriptors) {
destination = getJMSDestination(logicalDestination, ejbDescriptor.getResourceDescriptors(JavaEEResourceType.JMSDD));
if (isValidDestination(destination)) {
return destination;
}
}
return null;
}
use of com.sun.enterprise.deployment.EjbDescriptor in project Payara by payara.
the class PipeHelper method authorize.
public void authorize(Packet request) throws Exception {
// SecurityContext constructor should set initiator to
// unathenticated if Subject is null or empty
Subject s = (Subject) request.invocationProperties.get(PipeConstants.CLIENT_SUBJECT);
if (s == null || (s.getPrincipals().isEmpty() && s.getPublicCredentials().isEmpty())) {
SecurityContext.setUnauthenticatedContext();
} else {
SecurityContext sC = new SecurityContext(s);
SecurityContext.setCurrent(sC);
}
if (isEjbEndpoint) {
if (invManager == null) {
throw new RuntimeException(localStrings.getLocalString("enterprise.webservice.noEjbInvocationManager", "Cannot validate request : invocation manager null for EJB WebService"));
}
ComponentInvocation inv = (ComponentInvocation) invManager.getCurrentInvocation();
// consumed
if (ejbDelegate != null) {
ejbDelegate.setSOAPMessage(request.getMessage(), inv);
}
Exception ie;
Method m = null;
if (seiModel != null) {
JavaMethod jm = request.getMessage().getMethod(seiModel);
m = (jm != null) ? jm.getMethod() : null;
} else {
// WebServiceProvider
WebServiceEndpoint endpoint = (WebServiceEndpoint) map.get(PipeConstants.SERVICE_ENDPOINT);
EjbDescriptor ejbDescriptor = endpoint.getEjbComponentImpl();
if (ejbDescriptor != null) {
final String ejbImplClassName = ejbDescriptor.getEjbImplClassName();
if (ejbImplClassName != null) {
try {
m = (Method) AppservAccessController.doPrivileged(new PrivilegedExceptionAction() {
@Override
public Object run() throws Exception {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Class clazz = Class.forName(ejbImplClassName, true, loader);
return clazz.getMethod("invoke", new Class[] { Object.class });
}
});
} catch (PrivilegedActionException pae) {
throw new RuntimeException(pae.getException());
}
}
}
}
if (m != null) {
if (ejbDelegate != null) {
try {
if (!ejbDelegate.authorize(inv, m)) {
throw new Exception(localStrings.getLocalString("enterprise.webservice.methodNotAuth", "Client not authorized for invocation of {0}", new Object[] { m }));
}
} catch (UnmarshalException e) {
String errorMsg = localStrings.getLocalString("enterprise.webservice.errorUnMarshalMethod", "Error unmarshalling method for ejb {0}", new Object[] { ejbName() });
ie = new UnmarshalException(errorMsg);
ie.initCause(e);
throw ie;
} catch (Exception e) {
ie = new Exception(localStrings.getLocalString("enterprise.webservice.methodNotAuth", "Client not authorized for invocation of {0}", new Object[] { m }));
ie.initCause(e);
throw ie;
}
}
}
}
}
use of com.sun.enterprise.deployment.EjbDescriptor in project Payara by payara.
the class CmrFieldsAccessorExposition method runIndividualCmrTest.
/**
* run an individual verifier test of a declated cmr field of the class
*
* @param entity the descriptor for the entity bean containing the cmp-field
* @param info the descriptor for the declared cmr field
* @param c the class owning the cmp field
* @parma r the result object to use to put the test results in
*
* @return true if the test passed
*/
protected boolean runIndividualCmrTest(Descriptor descriptor, RelationRoleDescriptor rrd, Class c, Result result) {
// check first if this is one-to-one or many-to-one relationship ...previous version of ejb specs
// if ((!rrd.getIsMany() && !rrd.getPartner().getIsMany()) ||
// (rrd.getIsMany() && !rrd.getPartner().getIsMany())) {
// }
// everyone falls back and should be checked
boolean pass = true;
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
// should not have accessor methods exposed.
if (((EjbDescriptor) descriptor).getRemoteClassName() != null && !((((EjbDescriptor) descriptor).getRemoteClassName()).equals(""))) {
String interfaceType = ((EjbDescriptor) descriptor).getRemoteClassName();
try {
CMRFieldInfo info = rrd.getCMRFieldInfo();
Class remoteInterface = Class.forName(interfaceType, false, getVerifierContext().getClassLoader());
String getMethodName = "get" + Character.toUpperCase(info.name.charAt(0)) + info.name.substring(1);
String setMethodName = "set" + Character.toUpperCase(info.name.charAt(0)) + info.name.substring(1);
Method getMethod = getMethod(remoteInterface, getMethodName, null);
if (getMethod != null) {
addErrorDetails(result, compName);
result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmrFieldsAccessorExposition.failed", "Error : CMR field {0} accessor method [ {1} ] is exposed through the component interface [ {2} ]", new Object[] { "get", info.name, interfaceType }));
pass = false;
} else {
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.addGoodDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmrFieldsAccessorExposition.passed", "CMR field {0} accessor method [ {1} ] is not exposed through the component interface [ {2} ]", new Object[] { "get", info.name, interfaceType }));
pass = true;
}
Class[] parms = { info.type };
Method setMethod = getMethod(remoteInterface, setMethodName, parms);
if (setMethod != null) {
addErrorDetails(result, compName);
result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmrFieldsAccessorExposition.failed", "Error : CMR field {0} accessor method [ {1} ] is exposed through the component interface [ {2} ]", new Object[] { "set", info.name, interfaceType }));
pass = false;
} else {
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.addGoodDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmrFieldsAccessorExposition.passed", "CMR field [{0}] accessor method [ {1} ] is not exposed through the component interface [ {2} ]", new Object[] { "set", info.name, interfaceType }));
}
} catch (Exception e) {
Verifier.debug(e);
addErrorDetails(result, compName);
result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmrFieldsAccessorExposition.failedException", "Error: [{0}] class not found or local interface not defined", new Object[] { interfaceType }));
pass = false;
}
}
return pass;
}
use of com.sun.enterprise.deployment.EjbDescriptor in project Payara by payara.
the class DeploymentImpl method loadBeanDeploymentArchive.
@Override
public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass) {
if (logger.isLoggable(FINE)) {
logger.log(FINE, CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE, new Object[] { beanClass });
}
List<BeanDeploymentArchive> beanDeploymentArchives = getBeanDeploymentArchives();
ListIterator<BeanDeploymentArchive> lIter = beanDeploymentArchives.listIterator();
while (lIter.hasNext()) {
BeanDeploymentArchive bda = lIter.next();
if (logger.isLoggable(FINE)) {
logger.log(FINE, CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CHECKING, new Object[] { beanClass, bda.getId() });
}
if (((BeanDeploymentArchiveImpl) bda).getModuleBeanClasses().contains(beanClass.getName())) {
// as Weld automatically add theses classes to the BDA's bean Classes
if (logger.isLoggable(FINE)) {
logger.log(FINE, CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_TO_EXISTING, new Object[] { beanClass.getName(), bda });
}
return bda;
}
// and get the right BDA for the beanClass
if (!bda.getBeanDeploymentArchives().isEmpty()) {
for (BeanDeploymentArchive subBda : bda.getBeanDeploymentArchives()) {
Collection<String> moduleBeanClassNames = ((BeanDeploymentArchiveImpl) subBda).getModuleBeanClasses();
if (logger.isLoggable(FINE)) {
logger.log(FINE, CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CHECKING_SUBBDA, new Object[] { beanClass, subBda.getId() });
}
boolean match = moduleBeanClassNames.contains(beanClass.getName());
if (match) {
// as Weld automatically add theses classes to the BDA's bean Classes
if (logger.isLoggable(FINE)) {
logger.log(FINE, CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_TO_EXISTING, new Object[] { beanClass.getName(), subBda });
}
return subBda;
}
}
}
}
BeanDeploymentArchive extensionBDA = extensionBDAMap.get(beanClass.getClassLoader());
if (extensionBDA != null) {
return extensionBDA;
}
// If the BDA was not found for the Class, create one and add it
if (logger.isLoggable(FINE)) {
logger.log(FINE, CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CREATE_NEW_BDA, new Object[] { beanClass });
}
List<Class<?>> beanClasses = new ArrayList<>();
List<URL> beanXMLUrls = new CopyOnWriteArrayList<>();
Set<EjbDescriptor> ejbs = new HashSet<>();
beanClasses.add(beanClass);
BeanDeploymentArchive newBda = new BeanDeploymentArchiveImpl(beanClass.getName(), beanClasses, beanXMLUrls, ejbs, context);
// have to create new InjectionServicesImpl for each new BDA so injection context is propagated for the correct bundle
newBda.getServices().add(InjectionServices.class, new InjectionServicesImpl(injectionManager, DOLUtils.getCurrentBundleForContext(context), this));
BeansXml beansXml = newBda.getBeansXml();
if (beansXml == null || !beansXml.getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
if (logger.isLoggable(FINE)) {
logger.log(FINE, CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_NEW_BDA_TO_ROOTS, new Object[] {});
}
lIter = beanDeploymentArchives.listIterator();
while (lIter.hasNext()) {
BeanDeploymentArchive bda = lIter.next();
bda.getBeanDeploymentArchives().add(newBda);
}
if (logger.isLoggable(FINE)) {
logger.log(FINE, CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_RETURNING_NEWLY_CREATED_BDA, new Object[] { beanClass, newBda });
}
beanDeploymentArchives.add(newBda);
idToBeanDeploymentArchive.put(newBda.getId(), newBda);
extensionBDAMap.put(beanClass.getClassLoader(), newBda);
return newBda;
}
return null;
}
Aggregations