use of com.sun.enterprise.config.serverbeans.ProviderConfig in project Payara by payara.
the class CreateMessageSecurityProvider method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are parameter names and the values the parameter values
*
* @param context information
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
List<MessageSecurityConfig> mscs = secService.getMessageSecurityConfig();
// Let's find the correct MessageSecurityConfig. As of now,
// there can be only two of them - one for SOAP and one for
// HttpServlet
MessageSecurityConfig msgSecCfg = null;
for (MessageSecurityConfig msc : mscs) {
if (msc.getAuthLayer().equals(authLayer)) {
msgSecCfg = msc;
}
}
// then, add a new provider config under it provided it is not duplicate
if (msgSecCfg != null) {
// check if there exists a provider config by the
// specified provider name; if so return failure.
List<ProviderConfig> pcs = msgSecCfg.getProviderConfig();
for (ProviderConfig pc : pcs) {
if (pc.getProviderId().equals(providerId)) {
report.setMessage(localStrings.getLocalString("create.message.security.provider.duplicatefound", "Message security provider named {0} exists. " + "Cannot add duplicate.", providerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
// No duplicate message security providers found. So add one.
try {
ConfigSupport.apply(new SingleConfigCode<MessageSecurityConfig>() {
public Object run(MessageSecurityConfig param) throws PropertyVetoException, TransactionFailure {
ProviderConfig newPC = param.createChild(ProviderConfig.class);
populateProviderConfigElement(newPC);
param.getProviderConfig().add(newPC);
// security config object
if (isDefaultProvider) {
if (providerType.equals(SERVER) || providerType.equals(CLIENT_SERVER)) {
param.setDefaultProvider(providerId);
}
if (providerType.equals(CLIENT) || providerType.equals(CLIENT_SERVER)) {
param.setDefaultClientProvider(providerId);
}
}
return newPC;
}
}, msgSecCfg);
} catch (TransactionFailure e) {
report.setMessage(localStrings.getLocalString("create.message.security.provider.fail", "Creation of message security provider named {0} failed", providerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
report.setMessage(localStrings.getLocalString("create.message.security.provider.success", "Creation of message security provider named {0} completed " + "successfully", providerId));
} else // Now if there is NO message security config for this type of layer
// then, first add a message security config for the layer and then
// add a provider config under this message security config
{
try {
ConfigSupport.apply(new SingleConfigCode<SecurityService>() {
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure {
MessageSecurityConfig newMSC = param.createChild(MessageSecurityConfig.class);
newMSC.setAuthLayer(authLayer);
param.getMessageSecurityConfig().add(newMSC);
ProviderConfig newPC = newMSC.createChild(ProviderConfig.class);
populateProviderConfigElement(newPC);
newMSC.getProviderConfig().add(newPC);
// security config object
if (isDefaultProvider) {
if (providerType.equals(SERVER) || providerType.equals(CLIENT_SERVER)) {
newMSC.setDefaultProvider(providerId);
}
if (providerType.equals(CLIENT) || providerType.equals(CLIENT_SERVER)) {
newMSC.setDefaultClientProvider(providerId);
}
}
return newMSC;
}
}, secService);
} catch (TransactionFailure e) {
report.setMessage(localStrings.getLocalString("create.message.security.provider.fail", "Creation of message security provider named {0} failed", providerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
/* report.setMessage(localStrings.getLocalString(
"create.message.security.provider.success",
"Creation of message security provider named {0} completed " +
"successfully", providerId)); */
}
}
use of com.sun.enterprise.config.serverbeans.ProviderConfig in project Payara by payara.
the class DeleteMessageSecurityProvider method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
@Override
public void execute(AdminCommandContext context) {
ActionReport report = context.getActionReport();
List<ProviderConfig> pcs = msgSecCfg.getProviderConfig();
for (ProviderConfig pc : pcs) {
if (pc.getProviderId().equals(providerId)) {
thePC = pc;
try {
ConfigSupport.apply(new SingleConfigCode<MessageSecurityConfig>() {
public Object run(MessageSecurityConfig param) throws PropertyVetoException, TransactionFailure {
if ((param.getDefaultProvider() != null) && param.getDefaultProvider().equals(thePC.getProviderId())) {
param.setDefaultProvider(null);
}
if ((param.getDefaultClientProvider() != null) && param.getDefaultClientProvider().equals(thePC.getProviderId())) {
param.setDefaultClientProvider(null);
}
param.getProviderConfig().remove(thePC);
return null;
}
}, msgSecCfg);
} catch (TransactionFailure e) {
e.printStackTrace();
report.setMessage(localStrings.getLocalString("delete.message.security.provider.fail", "Deletion of message security provider named {0} failed", providerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
/*report.setMessage(localStrings.getLocalString(
"delete.message.security.provider.success",
"Deletion of message security provider {0} completed " +
"successfully", providerId));*/
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return;
}
}
}
use of com.sun.enterprise.config.serverbeans.ProviderConfig in project Payara by payara.
the class ConfigDomainParser method processServerConfig.
private void processServerConfig(SecurityService service, Map<String, GFServerConfigProvider.InterceptEntry> newConfig) throws IOException {
List<MessageSecurityConfig> configList = service.getMessageSecurityConfig();
if (configList != null) {
Iterator<MessageSecurityConfig> cit = configList.iterator();
while (cit.hasNext()) {
MessageSecurityConfig next = cit.next();
// single message-security-config for each auth-layer
// auth-layer is synonymous with intercept
String intercept = parseInterceptEntry(next, newConfig);
List<ProviderConfig> provList = next.getProviderConfig();
if (provList != null) {
Iterator<ProviderConfig> pit = provList.iterator();
while (pit.hasNext()) {
ProviderConfig provider = pit.next();
parseIDEntry(provider, newConfig, intercept);
}
}
}
}
}
use of com.sun.enterprise.config.serverbeans.ProviderConfig in project Payara by payara.
the class ConfigDomainParser method processServerConfig.
private void processServerConfig(SecurityService service, Map<String, GFServerConfigProvider.InterceptEntry> newConfig) throws IOException {
List<MessageSecurityConfig> configList = service.getMessageSecurityConfig();
if (configList != null) {
Iterator<MessageSecurityConfig> cit = configList.iterator();
while (cit.hasNext()) {
MessageSecurityConfig next = cit.next();
// single message-security-config for each auth-layer
// auth-layer is synonymous with intercept
String intercept = parseInterceptEntry(next, newConfig);
List<ProviderConfig> provList = next.getProviderConfig();
if (provList != null) {
Iterator<ProviderConfig> pit = provList.iterator();
while (pit.hasNext()) {
ProviderConfig provider = pit.next();
parseIDEntry(provider, newConfig, intercept);
}
}
}
}
}
use of com.sun.enterprise.config.serverbeans.ProviderConfig in project Payara by payara.
the class ListMessageSecurityProvider method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
secService.getMessageSecurityConfig();
report.getTopMessagePart().setMessage(localStrings.getLocalString("list.message.security.provider.success", "list-message-security-providers successful"));
report.getTopMessagePart().setChildrenType("");
for (MessageSecurityConfig msc : secService.getMessageSecurityConfig()) {
if (authLayer == null) {
for (ProviderConfig pc : msc.getProviderConfig()) {
ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(pc.getProviderId());
}
} else {
if (msc.getAuthLayer().equals(authLayer)) {
for (ProviderConfig pc : msc.getProviderConfig()) {
ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(pc.getProviderId());
}
}
}
}
}
Aggregations