use of org.jvnet.hk2.config.TransactionFailure 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
*/
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 org.jvnet.hk2.config.TransactionFailure in project Payara by payara.
the class DeleteAuthRealm 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) {
ActionReport report = context.getActionReport();
try {
ConfigSupport.apply(new SingleConfigCode<SecurityService>() {
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure {
param.getAuthRealm().remove(authRealm);
// temporary fix - since the SecurityConfigListener is not being called on an realm delete.
SecurityConfigListener.authRealmDeleted(authRealm);
return null;
}
}, securityService);
} catch (TransactionFailure e) {
report.setMessage(localStrings.getLocalString("delete.auth.realm.fail", "Deletion of Authrealm {0} failed", authRealmName) + " " + e.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.jvnet.hk2.config.TransactionFailure in project Payara by payara.
the class DeleteJaccProvider method execute.
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
try {
List<JaccProvider> jaccProviders = securityService.getJaccProvider();
JaccProvider jprov = null;
for (JaccProvider jaccProv : jaccProviders) {
if (jaccProv.getName().equals(jaccprovider)) {
jprov = jaccProv;
break;
}
}
final JaccProvider jaccprov = jprov;
ConfigSupport.apply(new SingleConfigCode<SecurityService>() {
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure {
param.getJaccProvider().remove(jaccprov);
return null;
}
}, securityService);
} catch (TransactionFailure e) {
report.setMessage(localStrings.getLocalString("delete.jacc.provider.fail", "Deletion of JaccProvider {0} failed", jaccprovider) + " " + e.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.jvnet.hk2.config.TransactionFailure in project Payara by payara.
the class LDAPAdminAccessConfigurator method createLDAPRealm.
// this had been called renameRealm, but in the SecurityConfigListener, the method authRealmUpdated actually does a create...
/* private void createBackupRealm(final StringBuilder sb, AuthRealm realm, final String to) throws PropertyVetoException, TransactionFailure {
SingleConfigCode<AuthRealm> scc = new SingleConfigCode<AuthRealm>() {
@Override
public Object run(AuthRealm realm) throws PropertyVetoException, TransactionFailure {
appendNL(sb, lsm.getString("config.to.ldap", FIXED_ADMIN_REALM_NAME, to));
realm.setName(to);
return realm;
}
};
ConfigSupport.apply(scc, realm);
}*/
private AuthRealm createLDAPRealm(SecurityService ss) throws TransactionFailure, PropertyVetoException {
AuthRealm ar = ss.createChild(AuthRealm.class);
ar.setClassname(LDAPRealm.class.getName());
ar.setName(FIXED_ADMIN_REALM_NAME);
List<Property> props = ar.getProperty();
Property p = ar.createChild(Property.class);
p.setName(DIR_P);
p.setValue(url);
props.add(p);
p = ar.createChild(Property.class);
p.setName(BASEDN_P);
p.setValue(basedn);
props.add(p);
p = ar.createChild(Property.class);
p.setName(JAAS_P);
p.setValue(JAAS_V);
props.add(p);
if (ldapGroupName != null) {
p = ar.createChild(Property.class);
p.setName(Realm.PARAM_GROUP_MAPPING);
// appears as gfdomain1->asadmin in domain.xml
p.setValue(ldapGroupName + "->asadmin");
props.add(p);
}
return ar;
}
use of org.jvnet.hk2.config.TransactionFailure in project Payara by payara.
the class LDAPAdminAccessConfigurator method updateSecurityProvider.
/* private String getNewRealmName(SecurityService ss) {
List<AuthRealm> realms = ss.getAuthRealm();
String pref = ORIG_ADMIN_REALM_NAME + "-";
int index = 0; //last one
for (AuthRealm realm : realms) {
if (realm.getName().indexOf(pref) >= 0) {
index = Integer.parseInt(realm.getName().substring(pref.length()));
}
}
return pref + (index+1);
}*/
private void updateSecurityProvider(final Transaction t, final SecurityProvider w_sp, final StringBuilder sb) throws TransactionFailure, PropertyVetoException {
for (SecurityProviderConfig spc : w_sp.getSecurityProviderConfig()) {
if ((spc instanceof LoginModuleConfig) && spc.getName().equals(ADMIN_FILE_LM_NAME)) {
final LoginModuleConfig w_lmConfig = t.enroll((LoginModuleConfig) spc);
w_lmConfig.setModuleClass(LDAPLoginModule.class.getName());
sb.append(lsm.getString("ldap.authProviderConfigOK", w_sp.getName()));
return;
}
}
throw new TransactionFailure(lsm.getString("ldap.noAuthProviderConfig", w_sp.getName(), ADMIN_FILE_LM_NAME));
}
Aggregations