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;
}
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);
}
}
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;
}
Aggregations