Search in sources :

Example 1 with MessageDescriptor

use of com.sun.enterprise.deployment.runtime.common.MessageDescriptor 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;
}
Also used : MessageDescriptor(com.sun.enterprise.deployment.runtime.common.MessageDescriptor) ArrayList(java.util.ArrayList) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 2 with MessageDescriptor

use of com.sun.enterprise.deployment.runtime.common.MessageDescriptor in project Payara by payara.

the class BaseAuthConfig method isMatchingMSD.

private static boolean isMatchingMSD(MethodDescriptor targetMD, MessageSecurityDescriptor mSD) {
    List<MessageDescriptor> 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;
}
Also used : MessageDescriptor(com.sun.enterprise.deployment.runtime.common.MessageDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 3 with MessageDescriptor

use of com.sun.enterprise.deployment.runtime.common.MessageDescriptor in project Payara by payara.

the class AuthMessagePolicy method getSOAPPolicies.

public static MessagePolicy[] getSOAPPolicies(MessageSecurityBindingDescriptor binding, String operation, boolean onePolicy) {
    MessagePolicy requestPolicy = null;
    MessagePolicy responsePolicy = null;
    if (binding != null) {
        List<MessageSecurityDescriptor> messageSecurityDescriptors = null;
        String layer = binding.getAttributeValue(AUTH_LAYER);
        if (SOAP.equals(layer)) {
            messageSecurityDescriptors = binding.getMessageSecurityDescriptors();
        }
        if (messageSecurityDescriptors != null) {
            if (onePolicy) {
                if (messageSecurityDescriptors.size() > 0) {
                    MessageSecurityDescriptor msd = messageSecurityDescriptors.get(0);
                    requestPolicy = getMessagePolicy(msd.getRequestProtectionDescriptor());
                    responsePolicy = getMessagePolicy(msd.getResponseProtectionDescriptor());
                }
            } else {
                // try to match
                MessageSecurityDescriptor matchMsd = null;
                for (int i = 0; i < messageSecurityDescriptors.size(); i++) {
                    MessageSecurityDescriptor msd = messageSecurityDescriptors.get(i);
                    List<MessageDescriptor> msgDescs = msd.getMessageDescriptors();
                    for (int j = i + 1; j < msgDescs.size(); j++) {
                        // XXX don't know how to get JavaMethod from operation
                        MessageDescriptor msgDesc = (MessageDescriptor) msgDescs.get(j);
                        String opName = msgDesc.getOperationName();
                        if ((opName == null && matchMsd == null)) {
                            matchMsd = msd;
                        } else if (opName != null && opName.equals(operation)) {
                            matchMsd = msd;
                            break;
                        }
                    }
                    if (matchMsd != null) {
                        requestPolicy = getMessagePolicy(matchMsd.getRequestProtectionDescriptor());
                        responsePolicy = getMessagePolicy(matchMsd.getResponseProtectionDescriptor());
                    }
                }
            }
        }
    }
    return new MessagePolicy[] { requestPolicy, responsePolicy };
}
Also used : MessageDescriptor(com.sun.enterprise.deployment.runtime.common.MessageDescriptor) MessagePolicy(javax.security.auth.message.MessagePolicy) MessageSecurityDescriptor(com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor) WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint)

Example 4 with MessageDescriptor

use of com.sun.enterprise.deployment.runtime.common.MessageDescriptor in project Payara by payara.

the class AuthMessagePolicy method getSOAPPolicies.

public static MessagePolicy[] getSOAPPolicies(MessageSecurityBindingDescriptor binding, String operation, boolean onePolicy) {
    MessagePolicy requestPolicy = null;
    MessagePolicy responsePolicy = null;
    if (binding != null) {
        ArrayList<MessageSecurityDescriptor> msgSecDescs = null;
        String layer = binding.getAttributeValue(MessageSecurityBindingDescriptor.AUTH_LAYER);
        if (SOAP.equals(layer)) {
            msgSecDescs = binding.getMessageSecurityDescriptors();
        }
        if (msgSecDescs != null) {
            if (onePolicy) {
                if (msgSecDescs.size() > 0) {
                    MessageSecurityDescriptor msd = msgSecDescs.get(0);
                    requestPolicy = getMessagePolicy(msd.getRequestProtectionDescriptor());
                    responsePolicy = getMessagePolicy(msd.getResponseProtectionDescriptor());
                }
            } else {
                // try to match
                MessageSecurityDescriptor matchMsd = null;
                for (int i = 0; i < msgSecDescs.size(); i++) {
                    MessageSecurityDescriptor msd = msgSecDescs.get(i);
                    ArrayList msgDescs = msd.getMessageDescriptors();
                    for (int j = i + 1; j < msgDescs.size(); j++) {
                        // XXX don't know how to get JavaMethod from operation
                        MessageDescriptor msgDesc = (MessageDescriptor) msgDescs.get(j);
                        String opName = msgDesc.getOperationName();
                        if ((opName == null && matchMsd == null)) {
                            matchMsd = msd;
                        } else if (opName != null && opName.equals(operation)) {
                            matchMsd = msd;
                            break;
                        }
                    }
                    if (matchMsd != null) {
                        requestPolicy = getMessagePolicy(matchMsd.getRequestProtectionDescriptor());
                        responsePolicy = getMessagePolicy(matchMsd.getResponseProtectionDescriptor());
                    }
                }
            }
        }
    }
    return new MessagePolicy[] { requestPolicy, responsePolicy };
}
Also used : MessageDescriptor(com.sun.enterprise.deployment.runtime.common.MessageDescriptor) MessagePolicy(javax.security.auth.message.MessagePolicy) ArrayList(java.util.ArrayList) MessageSecurityDescriptor(com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor) WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint)

Example 5 with MessageDescriptor

use of com.sun.enterprise.deployment.runtime.common.MessageDescriptor in project Payara by payara.

the class BaseAuthConfig method getContextForOpName.

private Object getContextForOpName(String operation) {
    synchronized (contextLock) {
        if (contextsForOpNames_ == null) {
            // one time initialization of the opName to authContext array.
            contextsForOpNames_ = new HashMap();
            for (int i = 0; messageSecurityDescriptors_ != null && i < messageSecurityDescriptors_.size(); i++) {
                MessageSecurityDescriptor mSD = (MessageSecurityDescriptor) messageSecurityDescriptors_.get(i);
                ArrayList mDs = mSD.getMessageDescriptors();
                for (int j = 0; mDs != null && j < mDs.size(); j++) {
                    MessageDescriptor mD = (MessageDescriptor) mDs.get(j);
                    String opName = mD.getOperationName();
                    if (opName != null) {
                        if (contextsForOpNames_.containsKey(opName)) {
                            Integer k = (Integer) contextsForOpNames_.get(opName);
                            if (k != null) {
                                MessageSecurityDescriptor other = (MessageSecurityDescriptor) messageSecurityDescriptors_.get(k.intValue());
                                if (!policiesAreEqual(mSD, other)) {
                                    contextsForOpNames_.put(opName, null);
                                }
                            }
                        } else if (superMSD_ != null && !policiesAreEqual(mSD, superMSD_)) {
                            // set to null if operation policy differs from superPolicy
                            contextsForOpNames_.put(opName, null);
                        } else {
                            contextsForOpNames_.put(opName, Integer.valueOf(i));
                        }
                    }
                }
            }
        }
    }
    Object rvalue = null;
    if (operation != null) {
        if (contextsForOpNames_.containsKey(operation)) {
            Integer k = (Integer) contextsForOpNames_.get(operation);
            if (k != null) {
                rvalue = contexts_.get(k.intValue());
            }
        } else if (superIndex_ >= 0) {
            // if there is a msb that matches all methods, use the
            // associatedContext
            rvalue = contexts_.get(superIndex_);
        }
        if (rvalue == null) {
            // else return explicitNull under the assumption
            // that methodName was known, and no match was found
            rvalue = explicitNull;
        }
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "WSS: ForOpName={0} context: {1}", new Object[] { operation, rvalue });
        }
    }
    return rvalue;
}
Also used : MessageDescriptor(com.sun.enterprise.deployment.runtime.common.MessageDescriptor) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MessageSecurityDescriptor(com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor)

Aggregations

MessageDescriptor (com.sun.enterprise.deployment.runtime.common.MessageDescriptor)8 MessageSecurityDescriptor (com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor)4 ArrayList (java.util.ArrayList)3 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)2 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)2 HashMap (java.util.HashMap)2 MessagePolicy (javax.security.auth.message.MessagePolicy)2 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 ProtectionDescriptor (com.sun.enterprise.deployment.runtime.common.ProtectionDescriptor)1 Node (org.w3c.dom.Node)1