Search in sources :

Example 1 with MessageSecurityConfig

use of com.sun.enterprise.config.serverbeans.MessageSecurityConfig in project Payara by payara.

the class MessageSecurityConfigEventListenerImpl method handleCreate.

/**
 * @param event Event to be processed.
 * @throws AdminEventListenerException when the listener is unable to process the event.
 */
public <T extends ConfigBeanProxy> NotProcessed handleCreate(T instance) {
    NotProcessed notProcessed = null;
    logger.fine("MessageSecurityConfigEventListenerImpl - handleCreate called");
    if (instance instanceof MessageSecurityConfig) {
        GFServerConfigProvider.loadConfigContext(service);
    } else {
        notProcessed = new NotProcessed("unimplemented: unknown instance: " + instance.getClass().getName());
    }
    return notProcessed;
}
Also used : NotProcessed(org.jvnet.hk2.config.NotProcessed) MessageSecurityConfig(com.sun.enterprise.config.serverbeans.MessageSecurityConfig)

Example 2 with MessageSecurityConfig

use of com.sun.enterprise.config.serverbeans.MessageSecurityConfig in project Payara by payara.

the class MessageSecurityConfigEventListenerImpl method handleDelete.

/**
 * @param event Event to be processed.
 * @throws AdminEventListenerException when the listener is unable to process the event.
 */
public <T extends ConfigBeanProxy> NotProcessed handleDelete(T instance) {
    NotProcessed notProcessed = null;
    logger.fine("MessageSecurityConfigEventListenerImpl - handleDelete called");
    if (instance instanceof MessageSecurityConfig) {
        GFServerConfigProvider.loadConfigContext(service);
    } else {
        notProcessed = new NotProcessed("unimplemented: unknown instance: " + instance.getClass().getName());
    }
    return notProcessed;
}
Also used : NotProcessed(org.jvnet.hk2.config.NotProcessed) MessageSecurityConfig(com.sun.enterprise.config.serverbeans.MessageSecurityConfig)

Example 3 with MessageSecurityConfig

use of com.sun.enterprise.config.serverbeans.MessageSecurityConfig 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;
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ProviderConfig(com.sun.enterprise.config.serverbeans.ProviderConfig) MessageSecurityConfig(com.sun.enterprise.config.serverbeans.MessageSecurityConfig) ActionReport(org.glassfish.api.ActionReport)

Example 4 with MessageSecurityConfig

use of com.sun.enterprise.config.serverbeans.MessageSecurityConfig 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));  */
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ProviderConfig(com.sun.enterprise.config.serverbeans.ProviderConfig) SecurityService(com.sun.enterprise.config.serverbeans.SecurityService) MessageSecurityConfig(com.sun.enterprise.config.serverbeans.MessageSecurityConfig) ActionReport(org.glassfish.api.ActionReport)

Example 5 with MessageSecurityConfig

use of com.sun.enterprise.config.serverbeans.MessageSecurityConfig 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);
                }
            }
        }
    }
}
Also used : ProviderConfig(com.sun.enterprise.config.serverbeans.ProviderConfig) MessageSecurityConfig(com.sun.enterprise.config.serverbeans.MessageSecurityConfig)

Aggregations

MessageSecurityConfig (com.sun.enterprise.config.serverbeans.MessageSecurityConfig)8 ProviderConfig (com.sun.enterprise.config.serverbeans.ProviderConfig)5 ActionReport (org.glassfish.api.ActionReport)3 NotProcessed (org.jvnet.hk2.config.NotProcessed)3 PropertyVetoException (java.beans.PropertyVetoException)2 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)2 SecurityService (com.sun.enterprise.config.serverbeans.SecurityService)1