final Target target = getTarget(targetName);
check1ToN(target);
final ConfigTarget configTarget = target.getConfigTarget();
boolean bMessageConfigJustCreated = false;
Config config = ConfigAPIHelper.getConfigByName(getConfigContext(), configTarget.getName());
SecurityService securityService = config.getSecurityService();
//message-security-config
MessageSecurityConfig messageSecurity = securityService.getMessageSecurityConfigByAuthLayer(messageLayer);
if(messageSecurity==null)
{
// we have to create it
messageSecurity = new MessageSecurityConfig();
messageSecurity.setAuthLayer(messageLayer);
bMessageConfigJustCreated = true;
}
//provider-config
ProviderConfig provider = new ProviderConfig();
provider.setClassName(providerClassName);
provider.setProviderId(providerId);
provider.setProviderType(providerType);
//properties
if (null != props)
{
provider.setElementProperty(convertPropertiesToElementProperties(props));
}
//request-policy
if(requestAuthSource!=null || requestAuthRecipient!=null )
{
RequestPolicy requestPolicy = new RequestPolicy();
if(requestAuthSource!=null)
requestPolicy.setAuthSource(requestAuthSource);
if(requestAuthRecipient!=null)
requestPolicy.setAuthRecipient(requestAuthRecipient);
provider.setRequestPolicy(requestPolicy);
}
//response-policy
if(responseAuthSource!=null || responseAuthRecipient!=null )
{
ResponsePolicy responsePolicy = new ResponsePolicy();
if(responseAuthSource!=null)
responsePolicy.setAuthSource(responseAuthSource);
if(responseAuthRecipient!=null)
responsePolicy.setAuthRecipient(responseAuthRecipient);
provider.setResponsePolicy(responsePolicy);
}
messageSecurity.addProviderConfig(provider);
//set default provider
if(isDefaultProvider)
{
if(PROVIDER_TYPE_SERVER.equals(providerType))
messageSecurity.setDefaultProvider(providerId);
else if(PROVIDER_TYPE_CLIENT.equals(providerType))
messageSecurity.setDefaultClientProvider(providerId);
else
{
messageSecurity.setDefaultProvider(providerId);
messageSecurity.setDefaultClientProvider(providerId);
}
}
if(bMessageConfigJustCreated)
{
securityService.addMessageSecurityConfig(messageSecurity);
}
return getMBeanRegistry().getMbeanObjectName("provider-config",
new String[]{getDomainName(), configTarget.getName(), messageLayer, providerId});
}