static boolean isVisible(OperationEntry operationEntry, OperationContext context) { Set<OperationEntry.Flag> flags = operationEntry.getFlags(); return operationEntry.getType() == OperationEntry.EntryType.PUBLIC && !flags.contains(OperationEntry.Flag.HIDDEN) && (context.getProcessType() != ProcessType.DOMAIN_SERVER || flags.contains(OperationEntry.Flag.RUNTIME_ONLY) || flags.contains(OperationEntry.Flag.READ_ONLY)); } }
static boolean isVisible(OperationEntry operationEntry, OperationContext context) { Set<OperationEntry.Flag> flags = operationEntry.getFlags(); return operationEntry.getType() == OperationEntry.EntryType.PUBLIC && !flags.contains(OperationEntry.Flag.HIDDEN) && (context.getProcessType() != ProcessType.DOMAIN_SERVER || flags.contains(OperationEntry.Flag.RUNTIME_ONLY) || flags.contains(OperationEntry.Flag.READ_ONLY)); } }
@Override void getOperationDescriptions(final ListIterator<PathElement> iterator, final Map<String, OperationEntry> providers, final boolean inherited) { Map<String, OperationEntry> temp = new HashMap<String, OperationEntry>(); target.getOperationDescriptions(iterator, temp, inherited); for (Map.Entry<String, OperationEntry> entry : providers.entrySet()) { providers.put(entry.getKey(), new OperationEntry(handler, entry.getValue().getDescriptionProvider(), entry.getValue().isInherited(), entry.getValue().getType(), entry.getValue().getFlags())); } }
@Override void getOperationDescriptions(final ListIterator<PathElement> iterator, final Map<String, OperationEntry> providers, final boolean inherited) { Map<String, OperationEntry> temp = new HashMap<String, OperationEntry>(); target.getOperationDescriptions(iterator, temp, inherited); for (Map.Entry<String, OperationEntry> entry : providers.entrySet()) { OperationEntry value = entry.getValue(); providers.put(entry.getKey(), new OperationEntry(handler, value.getDescriptionProvider(), value.isInherited(), value.getType(), value.getFlags(), value.getAccessConstraints())); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ImmutableManagementResourceRegistration registry = context.getResourceRegistration(); final Map<String, OperationEntry> operations = registry.getOperationDescriptions(PathAddress.EMPTY_ADDRESS, true); final ModelNode result = new ModelNode(); if (operations.size() > 0) { for (final Map.Entry<String, OperationEntry> entry : operations.entrySet()) { if (entry.getValue().getType() == OperationEntry.EntryType.PUBLIC) { if (context.getProcessType() != ProcessType.DOMAIN_SERVER || entry.getValue().getFlags().contains(OperationEntry.Flag.RUNTIME_ONLY)) { result.add(entry.getKey()); } } } } else { result.setEmptyList(); } context.getResult().set(result); context.stepCompleted(); } }
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); for (final Map.Entry<String, OperationEntry> entry : operations.entrySet()) { if (entry.getValue().getType() == OperationEntry.EntryType.PUBLIC) { if (context.getProcessType() != ProcessType.DOMAIN_SERVER || entry.getValue().getFlags().contains(OperationEntry.Flag.RUNTIME_ONLY)) {
@Override OperationEntry getOperationEntry(final ListIterator<PathElement> iterator, final String operationName, OperationEntry inherited) { OperationEntry targetOp = target.getOperationEntry(iterator, operationName, inherited); if (targetOp == null) { return null; } return new OperationEntry(handler, targetOp.getDescriptionProvider(), targetOp.isInherited(), targetOp.getType(), targetOp.getFlags()); }
@Override OperationEntry getOperationEntry(final ListIterator<PathElement> iterator, final String operationName, OperationEntry inherited) { OperationEntry targetOp = target.getOperationEntry(iterator, operationName, inherited); if (targetOp == null) { return null; } return new OperationEntry(handler, targetOp.getDescriptionProvider(), targetOp.isInherited(), targetOp.getType(), targetOp.getFlags(), null); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (MGMT_OP_LOGGER.isTraceEnabled()) { MGMT_OP_LOGGER.tracef("Executing %s %s", operation.get(OP), operation.get(OP_ADDR)); } final PathAddress address = context.getCurrentAddress(); final String operationName = operation.require(OP).asString(); final OperationEntry stepOperation = resolveOperationHandler(address, operationName); if (stepOperation != null) { if (!context.isBooting() && stepOperation.getType() == OperationEntry.EntryType.PRIVATE && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString())) { // End user trying to invoke a private op. Respond as if there is no such operation context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, address)); } else { context.addModelStep(stepOperation.getOperationDefinition(), stepOperation.getOperationHandler(), false); } } else { ImmutableManagementResourceRegistration child = managementModel.get().getRootResourceRegistration().getSubModel(address); if (child == null) { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noSuchResourceType(address)); } else { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, address)); } } context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (MGMT_OP_LOGGER.isTraceEnabled()) { MGMT_OP_LOGGER.tracef("Executing %s %s", operation.get(OP), operation.get(OP_ADDR)); } final PathAddress address = context.getCurrentAddress(); final String operationName = operation.require(OP).asString(); final OperationEntry stepOperation = resolveOperationHandler(address, operationName); if (stepOperation != null) { if (!context.isBooting() && stepOperation.getType() == OperationEntry.EntryType.PRIVATE && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString())) { // End user trying to invoke a private op. Respond as if there is no such operation context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, address)); } else { context.addModelStep(stepOperation.getOperationDefinition(), stepOperation.getOperationHandler(), false); } } else { ImmutableManagementResourceRegistration child = managementModel.get().getRootResourceRegistration().getSubModel(address); if (child == null) { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noSuchResourceType(address)); } else { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, address)); } } context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); } }
static void executeDirectOperation(OperationContext context, ModelNode operation, boolean checkPrivate) throws OperationFailedException { final String operationName = operation.require(OP).asString(); final ImmutableManagementResourceRegistration registration = context.getResourceRegistration(); PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR)); final OperationEntry stepEntry = context.getRootResourceRegistration().getOperationEntry(pathAddress, operationName); if (stepEntry != null) { boolean illegalPrivateStep = checkPrivate && stepEntry.getType() == OperationEntry.EntryType.PRIVATE && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString()); if (illegalPrivateStep) { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress)); } else { context.addModelStep(stepEntry.getOperationDefinition(), stepEntry.getOperationHandler(), false); } } else { if (! context.isBooting()) { if (registration == null) { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noSuchResourceType(pathAddress)); } else { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress)); } } } }
static void executeDirectOperation(OperationContext context, ModelNode operation, boolean checkPrivate) throws OperationFailedException { final String operationName = operation.require(OP).asString(); final ImmutableManagementResourceRegistration registration = context.getResourceRegistration(); PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR)); final OperationEntry stepEntry = context.getRootResourceRegistration().getOperationEntry(pathAddress, operationName); if (stepEntry != null) { boolean illegalPrivateStep = checkPrivate && stepEntry.getType() == OperationEntry.EntryType.PRIVATE && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString()); if (illegalPrivateStep) { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress)); } else { context.addModelStep(stepEntry.getOperationDefinition(), stepEntry.getOperationHandler(), false); } } else { if (! context.isBooting()) { if (registration == null) { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noSuchResourceType(pathAddress)); } else { context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress)); } } } }
private static OpData getOpData(OperationContext context, ModelNode subOperation, ModelNode response, PathAddress stepAddress, OperationHandlerResolver handlerResolver, boolean rejectPrivateOperations) throws OperationFailedException { ImmutableManagementResourceRegistration registry = context.getRootResourceRegistration(); String stepOpName = subOperation.require(OP).asString(); OperationEntry operationEntry = registry.getOperationEntry(stepAddress, stepOpName); if (operationEntry == null) { ImmutableManagementResourceRegistration child = registry.getSubModel(stepAddress); if (child == null) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noSuchResourceType(stepAddress)); } else { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(stepOpName, stepAddress)); } } else if (operationEntry.getType() == OperationEntry.EntryType.PRIVATE) { if (rejectPrivateOperations || (subOperation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(subOperation.get(OPERATION_HEADERS, CALLER_TYPE).asString()))) { // Not allowed; respond as if there is no such operation throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(stepOpName, stepAddress)); } } OperationStepHandler osh = handlerResolver.getOperationStepHandler(stepOpName, stepAddress, subOperation, operationEntry); return new OpData(subOperation, operationEntry.getOperationDefinition(), osh, response); }
private static OpData getOpData(OperationContext context, ModelNode subOperation, ModelNode response, PathAddress stepAddress, OperationHandlerResolver handlerResolver, boolean rejectPrivateOperations) throws OperationFailedException { ImmutableManagementResourceRegistration registry = context.getRootResourceRegistration(); String stepOpName = subOperation.require(OP).asString(); OperationEntry operationEntry = registry.getOperationEntry(stepAddress, stepOpName); if (operationEntry == null) { ImmutableManagementResourceRegistration child = registry.getSubModel(stepAddress); if (child == null) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noSuchResourceType(stepAddress)); } else { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(stepOpName, stepAddress)); } } else if (operationEntry.getType() == OperationEntry.EntryType.PRIVATE) { if (rejectPrivateOperations || (subOperation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(subOperation.get(OPERATION_HEADERS, CALLER_TYPE).asString()))) { // Not allowed; respond as if there is no such operation throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(stepOpName, stepAddress)); } } OperationStepHandler osh = handlerResolver.getOperationStepHandler(stepOpName, stepAddress, subOperation, operationEntry); return new OpData(subOperation, operationEntry.getOperationDefinition(), osh, response); }
if (entry.getType() == EntryType.PRIVATE || entry.getFlags().contains(OperationEntry.Flag.HIDDEN)) { return;
if (entry.getType() == EntryType.PRIVATE || entry.getFlags().contains(OperationEntry.Flag.HIDDEN)) { return;
if (entry.getType() == EntryType.PRIVATE) { return;
if (entry.getType() == EntryType.PRIVATE) { return;
if (entry != null) { if (!context.isBooting() && entry.getType() == OperationEntry.EntryType.PRIVATE && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString())) {
if (entry != null) { if (!context.isBooting() && entry.getType() == OperationEntry.EntryType.PRIVATE && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString())) {