use of com.sun.enterprise.config.serverbeans.SecurityService in project Payara by payara.
the class ChangeAdminPassword method preAuthorization.
@Override
public boolean preAuthorization(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
// Issue 17513 Fix - Check for null passwords if secureadmin is enabled
secureAdmin = domain.getSecureAdmin();
if (SecureAdmin.Util.isEnabled(secureAdmin)) {
if ((newpassword == null) || (newpassword.isEmpty())) {
report.setMessage(localStrings.getLocalString("null_empty_password", "The new password is null or empty"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return false;
}
}
final List<Config> configList = configs.getConfig();
config = configList.get(0);
SecurityService securityService = config.getSecurityService();
fileAuthRealm = null;
for (AuthRealm authRealm : securityService.getAuthRealm()) {
if (authRealm.getName().equals(adminService.getAuthRealmName())) {
fileAuthRealm = authRealm;
break;
}
}
if (fileAuthRealm == null) {
report.setMessage(localStrings.getLocalString("change.admin.password.adminrealmnotfound", "Server " + "Error: There is no admin realm to perform this operation"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return false;
}
return true;
}
use of com.sun.enterprise.config.serverbeans.SecurityService in project Payara by payara.
the class CreateAuditModule method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are paramter names and the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
// check if there exists an audit module by the specified name
// if so return failure.
List<AuditModule> ams = securityService.getAuditModule();
for (AuditModule am : ams) {
if (am.getName().equals(auditModuleName)) {
report.setMessage(localStrings.getLocalString("create.audit.module.duplicatefound", "AuditModule named {0} exists. " + "Cannot add duplicate AuditModule.", auditModuleName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
// No duplicate audit modules found. So add one.
try {
ConfigSupport.apply(new SingleConfigCode<SecurityService>() {
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure {
AuditModule newAuditModule = param.createChild(AuditModule.class);
populateAuditModuleElement(newAuditModule);
param.getAuditModule().add(newAuditModule);
return newAuditModule;
}
}, securityService);
} catch (TransactionFailure e) {
report.setMessage(localStrings.getLocalString("create.audit.module.fail", "Creation of AuditModule {0} failed", auditModuleName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
// report.setMessage(localStrings.getLocalString("create.audit.module.success",
// "Creation of AuditModule {0} completed successfully", auditModuleName));
}
use of com.sun.enterprise.config.serverbeans.SecurityService in project Payara by payara.
the class CreateAuthRealm 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
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
// No duplicate auth realms found. So add one.
try {
ConfigSupport.apply(new SingleConfigCode<SecurityService>() {
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure {
AuthRealm newAuthRealm = param.createChild(AuthRealm.class);
populateAuthRealmElement(newAuthRealm);
param.getAuthRealm().add(newAuthRealm);
// In case of cluster instances, this is required to
// avoid issues with the listener's callback method
SecurityConfigListener.authRealmCreated(config, newAuthRealm);
return newAuthRealm;
}
}, securityService);
} catch (TransactionFailure e) {
report.setMessage(localStrings.getLocalString("create.auth.realm.fail", "Creation of Authrealm {0} failed", authRealmName) + " " + e.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of com.sun.enterprise.config.serverbeans.SecurityService in project Payara by payara.
the class CreateJACCProvider method execute.
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
// No duplicate auth realms found. So add one.
try {
ConfigSupport.apply(new SingleConfigCode<SecurityService>() {
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure {
JaccProvider newJacc = param.createChild(JaccProvider.class);
newJacc.setName(jaccProviderName);
newJacc.setPolicyConfigurationFactoryProvider(polConfFactoryClass);
newJacc.setPolicyProvider(polProviderClass);
configureProperties(newJacc);
param.getJaccProvider().add(newJacc);
return newJacc;
}
}, securityService);
} catch (TransactionFailure e) {
report.setMessage(localStrings.getLocalString("create.auth.realm.fail", "Creation of Authrealm {0} failed", jaccProviderName) + " " + e.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Aggregations