use of com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor in project Payara by payara.
the class AuthMessagePolicy method oneSOAPPolicy.
public static boolean oneSOAPPolicy(MessageSecurityBindingDescriptor binding) {
boolean onePolicy = true;
ArrayList msgSecDescs = null;
if (binding != null) {
String layer = binding.getAttributeValue(MessageSecurityBindingDescriptor.AUTH_LAYER);
if (SOAP.equals(layer)) {
msgSecDescs = binding.getMessageSecurityDescriptors();
}
}
if (msgSecDescs == null) {
return true;
}
for (int i = 0; i < msgSecDescs.size(); i++) {
MessageSecurityDescriptor msd = (MessageSecurityDescriptor) msgSecDescs.get(i);
for (int j = 0; j < msgSecDescs.size(); j++) {
if (j != i && !policiesAreEqual(msd, ((MessageSecurityDescriptor) msgSecDescs.get(j)))) {
onePolicy = false;
}
}
}
return onePolicy;
}
use of com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor in project Payara by payara.
the class ServerAuthConfig method getConfig.
public static ServerAuthConfig getConfig(String authLayer, MessageSecurityBindingDescriptor binding, CallbackHandler cbh) throws AuthException {
ServerAuthConfig rvalue = null;
String provider = null;
ArrayList descriptors = null;
ServerAuthContext defaultContext = null;
if (binding != null) {
String layer = binding.getAttributeValue(MessageSecurityBindingDescriptor.AUTH_LAYER);
if (authLayer != null && layer.equals(authLayer)) {
provider = binding.getAttributeValue(MessageSecurityBindingDescriptor.PROVIDER_ID);
descriptors = binding.getMessageSecurityDescriptors();
}
}
if (descriptors == null || descriptors.size() == 0) {
defaultContext = getAuthContext(authLayer, provider, null, null, cbh);
if (defaultContext != null) {
rvalue = new ServerAuthConfig(defaultContext);
}
} else {
boolean hasPolicy = false;
ArrayList authContexts = new ArrayList();
for (int i = 0; i < descriptors.size(); i++) {
MessageSecurityDescriptor msd = (MessageSecurityDescriptor) descriptors.get(i);
AuthPolicy requestPolicy = getAuthPolicy(msd.getRequestProtectionDescriptor());
AuthPolicy responsePolicy = getAuthPolicy(msd.getResponseProtectionDescriptor());
if (requestPolicy.authRequired() || responsePolicy.authRequired()) {
authContexts.add(getAuthContext(authLayer, provider, requestPolicy, responsePolicy, cbh));
hasPolicy = true;
} else {
authContexts.add(null);
}
}
if (hasPolicy) {
rvalue = new ServerAuthConfig(descriptors, authContexts);
}
}
return rvalue;
}
use of com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor 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 };
}
use of com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor 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;
}
use of com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor in project Payara by payara.
the class ClientAuthConfig method getConfig.
public static ClientAuthConfig getConfig(String authLayer, MessageSecurityBindingDescriptor binding, CallbackHandler cbh) throws AuthException {
ClientAuthConfig rvalue = null;
String provider = null;
ArrayList descriptors = null;
ClientAuthContext defaultContext = null;
if (binding != null) {
String layer = binding.getAttributeValue(MessageSecurityBindingDescriptor.AUTH_LAYER);
if (authLayer != null && layer.equals(authLayer)) {
provider = binding.getAttributeValue(MessageSecurityBindingDescriptor.PROVIDER_ID);
descriptors = binding.getMessageSecurityDescriptors();
}
}
if (descriptors == null || descriptors.size() == 0) {
defaultContext = getAuthContext(authLayer, provider, null, null, cbh);
if (defaultContext != null) {
rvalue = new ClientAuthConfig(defaultContext);
}
} else {
boolean hasPolicy = false;
ArrayList authContexts = new ArrayList();
for (int i = 0; i < descriptors.size(); i++) {
MessageSecurityDescriptor msd = (MessageSecurityDescriptor) descriptors.get(i);
AuthPolicy requestPolicy = getAuthPolicy(msd.getRequestProtectionDescriptor());
AuthPolicy responsePolicy = getAuthPolicy(msd.getResponseProtectionDescriptor());
if (requestPolicy.authRequired() || responsePolicy.authRequired()) {
authContexts.add(getAuthContext(authLayer, provider, requestPolicy, responsePolicy, cbh));
hasPolicy = true;
} else {
authContexts.add(null);
}
}
if (hasPolicy) {
rvalue = new ClientAuthConfig(descriptors, authContexts);
}
}
return rvalue;
}
Aggregations