Search in sources :

Example 1 with SecurityConfiguration

use of org.glassfish.security.services.config.SecurityConfiguration in project Payara by payara.

the class CLIUtil method findSecurityProvider.

public static SecurityProvider findSecurityProvider(final Domain domain, final String serviceName, final String providerName, final ActionReport report) {
    // Get the security provider config
    final SecurityConfiguration sc = findSecurityConfiguration(domain, serviceName, report);
    if (sc == null) {
        return null;
    }
    SecurityProvider provider = sc.getSecurityProviderByName(providerName);
    if (provider == null) {
        report.setMessage("Unable to locate security provider: " + providerName);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return null;
    }
    return provider;
}
Also used : SecurityProvider(org.glassfish.security.services.config.SecurityProvider) SecurityConfiguration(org.glassfish.security.services.config.SecurityConfiguration)

Example 2 with SecurityConfiguration

use of org.glassfish.security.services.config.SecurityConfiguration in project Payara by payara.

the class CreateSecurityService method execute.

/**
 * Execute the create-security-service admin command.
 */
@Override
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    // Setup the service type and configuration handler
    if (AUTHENTICATION.equalsIgnoreCase(serviceType)) {
        clazzServiceType = AuthenticationService.class;
        serviceConfigHandler = new AuthenticationConfigHandler();
    } else {
        report.setMessage("Invalid security service type specified: " + serviceType);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    // Add service configuration to the security configurations
    // TODO - Add validation logic required for base service configuration
    SecurityConfiguration config = null;
    try {
        config = (SecurityConfiguration) ConfigSupport.apply(new SingleConfigCode<SecurityConfigurations>() {

            @Override
            public Object run(SecurityConfigurations param) throws PropertyVetoException, TransactionFailure {
                SecurityConfiguration svcConfig = param.createChild(clazzServiceType);
                svcConfig.setName(serviceName);
                svcConfig.setDefault(enableDefault.toString());
                param.getSecurityServices().add(svcConfig);
                return svcConfig;
            }
        }, secConfigs);
    } catch (TransactionFailure transactionFailure) {
        report.setMessage("Unable to create security service: " + transactionFailure.getMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(transactionFailure);
        return;
    }
    // TODO - Add validation logic required for specific service configuration
    if ((config != null) && (configuration != null) && (!configuration.isEmpty())) {
        serviceConfigHandler.setupConfiguration(report, config);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) SecurityConfigurations(org.glassfish.security.services.config.SecurityConfigurations) SecurityConfiguration(org.glassfish.security.services.config.SecurityConfiguration) ActionReport(org.glassfish.api.ActionReport)

Example 3 with SecurityConfiguration

use of org.glassfish.security.services.config.SecurityConfiguration in project Payara by payara.

the class CLIUtil method findSecurityConfiguration.

public static SecurityConfiguration findSecurityConfiguration(final Domain domain, final String serviceName, final ActionReport report) {
    // Lookup the security configurations
    SecurityConfigurations secConfigs = domain.getExtensionByType(SecurityConfigurations.class);
    if (secConfigs == null) {
        report.setMessage("Unable to locate security configurations");
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return null;
    }
    // Get the security service
    SecurityConfiguration ssc = secConfigs.getSecurityServiceByName(serviceName);
    if (ssc == null) {
        report.setMessage("Unable to locate security service: " + serviceName);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return null;
    }
    return ssc;
}
Also used : SecurityConfigurations(org.glassfish.security.services.config.SecurityConfigurations) SecurityConfiguration(org.glassfish.security.services.config.SecurityConfiguration)

Aggregations

SecurityConfiguration (org.glassfish.security.services.config.SecurityConfiguration)3 SecurityConfigurations (org.glassfish.security.services.config.SecurityConfigurations)2 PropertyVetoException (java.beans.PropertyVetoException)1 ActionReport (org.glassfish.api.ActionReport)1 SecurityProvider (org.glassfish.security.services.config.SecurityProvider)1 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)1