Skip to content

Instantly share code, notes, and snippets.

@ctomc
Created December 17, 2012 17:34
Show Gist options
  • Save ctomc/4320163 to your computer and use it in GitHub Desktop.
Save ctomc/4320163 to your computer and use it in GitHub Desktop.
backward compatibility write handler
static class JASPIAuthenticationModulesAttributeWriter implements OperationStepHandler {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
OperationStepHandler addHandler = context.getResourceRegistration().getSubModel(PathAddress.EMPTY_ADDRESS.append(AUTH_MODULE)).getOperationHandler(PathAddress.EMPTY_ADDRESS, "add");
for (ModelNode module : operation.get(VALUE).asList()) {
ModelNode addModuleOp = module.clone();
String code = addModuleOp.get(CODE).asString();
PathElement relativePath = PathElement.pathElement(AUTH_MODULE, code);
PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)).append(relativePath);
boolean exists = context.readResource(PathAddress.EMPTY_ADDRESS).hasChild(relativePath);
if (exists) {
ModelNode removeModuleOp = Util.createRemoveOperation(address);
context.addStep(removeModuleOp, new SecurityDomainReloadRemoveHandler(), OperationContext.Stage.IMMEDIATE);
}
addModuleOp.get(OP_ADDR).set(address.toModelNode());
addModuleOp.get(OP).set(ADD);
context.addStep(addModuleOp, addHandler, OperationContext.Stage.IMMEDIATE);
context.stepCompleted();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment