use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class BaseAuthConfig method getContextForMethod.
/* When method argument is null, returns the default AC
* if there is one, or the onePolicy shared by all methods
* if there is one, or throws an error.
* method is called with null argument when the method
* cannot be determined (e.g. when the message is encrypted)
*/
private Object getContextForMethod(Method m) {
Object rvalue = null;
synchronized (contextLock) {
if (defaultContext_ != null) {
rvalue = defaultContext_;
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "WSS: ForMethod returning default_context: {0}", rvalue);
}
return rvalue;
}
}
if (m != null) {
int match = -1;
MethodDescriptor targetMD = new MethodDescriptor(m);
for (int i = 0; i < messageSecurityDescriptors_.size(); i++) {
if (isMatchingMSD(targetMD, (MessageSecurityDescriptor) messageSecurityDescriptors_.get(i))) {
if (match < 0) {
match = i;
} else if (!policiesAreEqual((MessageSecurityDescriptor) messageSecurityDescriptors_.get(match), (MessageSecurityDescriptor) messageSecurityDescriptors_.get(i))) {
// set to unprotected because of conflicting policies
rvalue = explicitNull;
match = -1;
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "WSS: ForMethod detected conflicting policies: {0}.{1}", new Object[] { match, i });
}
break;
}
}
}
if (match >= 0) {
rvalue = contexts_.get(match);
if (rvalue == null) {
rvalue = explicitNull;
}
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "WSS: ForMethod returning matched context: {0}", rvalue);
}
}
} else if (onePolicy_ && contexts_.size() > 0) {
// ISSUE: since the method is undefined we will not be
// able to tell if the defined policy covers this method.
// We will be optimistic and try the policy, because
// the server will reject the call if the method is not
// covered by the policy.
// If the policy is not null, there remains a problem at the
// client on the response side, as it is possible that the
// client will enforce the wrong policy on the response.
// For this reason, messages in sun-application-client.xml
// should be keyed by operation-name.
rvalue = contexts_.get(0);
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "WSS: ForMethod resorting to first context: {0}", rvalue);
}
} else {
if (logger.isLoggable(Level.FINE)) {
logger.fine("WSS: Unable to select policy for SOAP Message");
}
throw new RuntimeException("Unable to select policy for Message");
}
return rvalue;
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class BaseAuthConfig method isMatchingMSD.
private static boolean isMatchingMSD(MethodDescriptor targetMD, MessageSecurityDescriptor mSD) {
ArrayList messageDescriptors = mSD.getMessageDescriptors();
if (messageDescriptors.isEmpty()) {
// element, and the deployment will be allowed to succeed.
return true;
}
for (int i = 0; i < messageDescriptors.size(); i++) {
MessageDescriptor nextMD = (MessageDescriptor) messageDescriptors.get(i);
MethodDescriptor mD = nextMD.getMethodDescriptor();
String opName = nextMD.getOperationName();
if (opName == null && (mD == null || mD.implies(targetMD))) {
return true;
}
}
return false;
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class AbstractAuthAnnotationHandler method postProcessAnnotation.
/**
* This method is for processing security annotation associated to ejb.
* Dervied class call this method may like to override
*
* protected void processEjbMethodSecurity(Annotation authAnnotation,
* MethodDescriptor md, EjbDescriptor ejbDesc)
*/
@Override
public void postProcessAnnotation(AnnotationInfo ainfo, AnnotatedElementHandler aeHandler) throws AnnotationProcessorException {
EjbContext ejbContext = (EjbContext) aeHandler;
EjbDescriptor ejbDesc = ejbContext.getDescriptor();
Annotation authAnnotation = ainfo.getAnnotation();
if (!ejbContext.isInherited() && (ejbDesc.getMethodPermissionsFromDD() == null || ejbDesc.getMethodPermissionsFromDD().size() == 0)) {
for (MethodDescriptor md : getMethodAllDescriptors(ejbDesc)) {
processEjbMethodSecurity(authAnnotation, md, ejbDesc);
}
} else {
Class classAn = (Class) ainfo.getAnnotatedElement();
for (Object next : ejbDesc.getSecurityBusinessMethodDescriptors()) {
MethodDescriptor md = (MethodDescriptor) next;
// override by existing info
if (classAn.equals(ejbContext.getDeclaringClass(md)) && !hasMethodPermissionsFromDD(md, ejbDesc)) {
processEjbMethodSecurity(authAnnotation, md, ejbDesc);
}
}
}
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class EjbDescriptorImpl method getRemoveMethods.
/**
* Get the remove methods of the EJB
*
* @return An iterator over the remove methods
*/
@Override
public Collection<Method> getRemoveMethods() {
Set<Method> removeMethods = new HashSet<Method>();
if (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
if (sessionDesc.isStateful() && sessionDesc.hasRemoveMethods()) {
for (MethodDescriptor mDesc : sessionDesc.getRemoveMethodDescriptors()) {
Method m = mDesc.getMethod(ejbDesc);
if (m == null) {
throw new IllegalStateException("Can't resolve remove method " + mDesc + " For EJB " + sessionDesc.getName());
}
removeMethods.add(m);
}
}
}
return removeMethods;
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class EjbEntityNode method writeDescriptor.
@Override
public Node writeDescriptor(Node parent, String nodeName, EjbEntityDescriptor ejbDesc) {
Node ejbNode = super.writeDescriptor(parent, nodeName, ejbDesc);
writeDisplayableComponentInfo(ejbNode, ejbDesc);
writeCommonHeaderEjbDescriptor(ejbNode, ejbDesc);
appendTextChild(ejbNode, EjbTagNames.PERSISTENCE_TYPE, ejbDesc.getPersistenceType());
appendTextChild(ejbNode, EjbTagNames.PRIMARY_KEY_CLASS, ejbDesc.getPrimaryKeyClassName());
appendTextChild(ejbNode, EjbTagNames.REENTRANT, ejbDesc.getReentrant());
// cmp entity beans related tags
if (ejbDesc instanceof EjbCMPEntityDescriptor) {
EjbCMPEntityDescriptor cmpDesc = (EjbCMPEntityDescriptor) ejbDesc;
if (cmpDesc.getCMPVersion() == EjbCMPEntityDescriptor.CMP_1_1) {
appendTextChild(ejbNode, EjbTagNames.CMP_VERSION, EjbTagNames.CMP_1_VERSION);
} else {
appendTextChild(ejbNode, EjbTagNames.CMP_VERSION, EjbTagNames.CMP_2_VERSION);
}
appendTextChild(ejbNode, EjbTagNames.ABSTRACT_SCHEMA_NAME, cmpDesc.getAbstractSchemaName());
// cmp-field*
CmpFieldNode cmpNode = new CmpFieldNode();
for (Iterator fields = cmpDesc.getPersistenceDescriptor().getCMPFields().iterator(); fields.hasNext(); ) {
FieldDescriptor aField = (FieldDescriptor) fields.next();
cmpNode.writeDescriptor(ejbNode, EjbTagNames.CMP_FIELD, aField);
}
if (cmpDesc.getPrimaryKeyFieldDesc() != null) {
appendTextChild(ejbNode, EjbTagNames.PRIMARY_KEY_FIELD, cmpDesc.getPrimaryKeyFieldDesc().getName());
}
}
// env-entry*
writeEnvEntryDescriptors(ejbNode, ejbDesc.getEnvironmentProperties().iterator());
// ejb-ref * and ejb-local-ref*
writeEjbReferenceDescriptors(ejbNode, ejbDesc.getEjbReferenceDescriptors().iterator());
// service-ref*
writeServiceReferenceDescriptors(ejbNode, ejbDesc.getServiceReferenceDescriptors().iterator());
// resource-ref*
writeResourceRefDescriptors(ejbNode, ejbDesc.getResourceReferenceDescriptors().iterator());
// resource-env-ref*
writeResourceEnvRefDescriptors(ejbNode, ejbDesc.getResourceEnvReferenceDescriptors().iterator());
// message-destination-ref*
writeMessageDestinationRefDescriptors(ejbNode, ejbDesc.getMessageDestinationReferenceDescriptors().iterator());
// persistence-context-ref*
writeEntityManagerReferenceDescriptors(ejbNode, ejbDesc.getEntityManagerReferenceDescriptors().iterator());
// persistence-unit-ref*
writeEntityManagerFactoryReferenceDescriptors(ejbNode, ejbDesc.getEntityManagerFactoryReferenceDescriptors().iterator());
// post-construct
writeLifeCycleCallbackDescriptors(ejbNode, TagNames.POST_CONSTRUCT, ejbDesc.getPostConstructDescriptors());
// pre-destroy
writeLifeCycleCallbackDescriptors(ejbNode, TagNames.PRE_DESTROY, ejbDesc.getPreDestroyDescriptors());
// all descriptors (includes DSD, MSD, JMSCFD, JMSDD,AOD, CFD)*
writeResourceDescriptors(ejbNode, ejbDesc.getAllResourcesDescriptors().iterator());
// security-role-ref*
writeRoleReferenceDescriptors(ejbNode, ejbDesc.getRoleReferences().iterator());
// security-identity
writeSecurityIdentityDescriptor(ejbNode, ejbDesc);
// query
if (ejbDesc instanceof EjbCMPEntityDescriptor) {
EjbCMPEntityDescriptor cmpDesc = (EjbCMPEntityDescriptor) ejbDesc;
Set queriedMethods = cmpDesc.getPersistenceDescriptor().getQueriedMethods();
if (queriedMethods.size() > 0) {
QueryNode queryNode = new QueryNode();
for (Iterator e = queriedMethods.iterator(); e.hasNext(); ) {
queryNode.writeDescriptor(ejbNode, EjbTagNames.QUERY, cmpDesc.getPersistenceDescriptor().getQueryFor((MethodDescriptor) e.next()));
}
}
}
return ejbNode;
}
Aggregations