@Override public Subject getSubject() { return wrapped.getSubject(); }
@Override public Subject getSubject() { return wrapped.getSubject(); }
@Override public void execute(final AdminCommandContext context) { try { if (origCL != ccl) { thread.setContextClassLoader(ccl); } /* * Execute the command in the security context of the * previously-authenticated subject. */ Subject.doAs(context.getSubject(), new PrivilegedAction<Void> () { @Override public Void run() { command.execute(context); return null; } }); } finally { if (origCL != ccl) { thread.setContextClassLoader(origCL); } } } };
@Override public void execute(final AdminCommandContext context) { try { if (origCL != ccl) { thread.setContextClassLoader(ccl); } /* * Execute the command in the security context of the * previously-authenticated subject. */ Subject.doAs(context.getSubject(), new PrivilegedAction<Void> () { @Override public Void run() { command.execute(context); return null; } }); } finally { if (origCL != ccl) { thread.setContextClassLoader(origCL); } } } };
public int runAdminCommandOnNode(Node node, StringBuilder output, boolean waitForReaderThreads, List<String> args, AdminCommandContext context) throws SSHCommandExecutionException, ProcessManagerException, UnsupportedOperationException, IllegalArgumentException { if (node == null) { throw new IllegalArgumentException("Node is null"); } final List<String> stdinLines = new ArrayList<String>(); stdinLines.add(AsadminInput.versionSpecifier()); stdinLines.add(AUTH_TOKEN_STDIN_LINE_PREFIX + authTokenManager.createToken(context.getSubject())); args.add(0, "--interactive=false"); // No prompting! if (node.isLocal()) { return runAdminCommandOnLocalNode(node, output, waitForReaderThreads, args, stdinLines); } else { return runAdminCommandOnRemoteNode(node, output, args, stdinLines); } }
private void validateInstanceDirUnique(ActionReport report, AdminCommandContext context) { CommandInvocation listInstances = cr.getCommandInvocation("list-instances", report, context.getSubject()); ParameterMap map = new ParameterMap(); map.add("whichTarget", theNode.getName()); listInstances.parameters(map); listInstances.execute(); Properties pro = listInstances.report().getExtraProperties(); if (pro != null){ List<HashMap> instanceList = (List<HashMap>) pro.get("instanceList"); if (instanceList == null) return; for (HashMap instanceMap : instanceList) { final File nodeDirFile = (nodeDir != null ? new File(nodeDir) : defaultLocalNodeDirFile()); File instanceDir = new File(new File(nodeDirFile.toString(), theNode.getName()), instance); String instanceName = (String)instanceMap.get("name"); File instanceListDir = new File(new File(nodeDirFile.toString(), theNode.getName()), instance); if (instance.equalsIgnoreCase(instanceName) && instanceDir.equals(instanceListDir)) { String msg = Strings.get("Instance.duplicateInstanceDir", instance, instanceName); logger.warning(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(msg); return; } } } }
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); try { validateJMSDestName(destName); validateJMSDestType(destType); } catch (IllegalArgumentException e) { report.setMessage(e.getMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; } if (destType.equals(JMS_DEST_TYPE_QUEUE)) { if (props == null) { props = new Properties(); } if (!props.containsKey(MAX_ACTIVE_CONSUMERS_PROPERTY) && !props.containsKey(MAX_ACTIVE_CONSUMERS_ATTRIBUTE)) { props.put(MAX_ACTIVE_CONSUMERS_ATTRIBUTE, DEFAULT_MAX_ACTIVE_CONSUMERS); } } try { createJMSDestination(report, context.getSubject()); } catch (Exception e) { report.setMessage(localStrings.getLocalString("create.jms.destination.CannotCreateJMSDest", "Unable to create JMS Destination.")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; } }
public void validateExecutorServiceLookupName(AdminCommandContext context, String targetName, String exeLookupName) { if ("concurrent/__defaultManagedExecutorService".equals(exeLookupName)) { return; } try { CommandRunner runner = serviceLocator.getService(CommandRunner.class); ActionReport subReport = context.getActionReport().addSubActionsReport(); CommandRunner.CommandInvocation inv = runner.getCommandInvocation("list-managed-executor-services", subReport, context.getSubject()); ParameterMap params = new ParameterMap(); params.add("target", targetName); inv.parameters(params); inv.execute(); Properties props = subReport.getExtraProperties(); if (props != null) { if (props.get("managedExecutorServices") != null) { List<HashMap<String, String>> map = (List<HashMap<String, String>>) props.get("managedExecutorServices"); for (HashMap<String, String> e : map) { if (e.get("name").equals(exeLookupName)) { return; } } } } throw new GlassFishBatchValidationException("No ExecutorService mapped to " + exeLookupName); } catch (Exception ex) { throw new GlassFishBatchValidationException("Exception during validation: ", ex); } }
public void validateDataSourceLookupName(AdminCommandContext context, String targetName, String dsLookupName) { try { CommandRunner runner = serviceLocator.getService(CommandRunner.class); ActionReport subReport = context.getActionReport().addSubActionsReport(); CommandRunner.CommandInvocation inv = runner.getCommandInvocation("list-jdbc-resources", subReport, context.getSubject()); ParameterMap params = new ParameterMap(); params.add("target", targetName); inv.parameters(params); inv.execute(); Properties props = subReport.getExtraProperties(); if (props != null) { if (props.get("jdbcResources") != null) { List<HashMap<String, String>> map = (List<HashMap<String, String>>) props.get("jdbcResources"); for (HashMap<String, String> e : map) { if (e.get("name").equals(dsLookupName)) { return; } } } } throw new GlassFishBatchValidationException("No DataSource mapped to " + dsLookupName); } catch (Exception ex) { throw new GlassFishBatchValidationException("Exception during validation: ", ex); } }
boolean result; CommandRunner.CommandInvocation inv = runner.getCommandInvocation( "_recover-transactions-internal", report, context.getSubject());
context.getSubject());
CommandInvocation ci = cr.getCommandInvocation("_update-node", report, context.getSubject()); ParameterMap map = new ParameterMap(); map.add("DEFAULT", name);
@Override public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); Logger logger = context.getLogger(); Node node = nodes.getNode(name); if (node == null) { //no node to delete nothing to do here String msg = Strings.get("noSuchNode", name); logger.warning(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(msg); return; } if (!(node.getType().equals("CONFIG") )){ //no node to delete nothing to do here String msg = Strings.get("notConfigNodeType", name); logger.warning(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(msg); return; } CommandInvocation ci = cr.getCommandInvocation("_delete-node", report, context.getSubject()); ParameterMap map = new ParameterMap(); map.add("DEFAULT", name); ci.parameters(map); ci.execute(); }
private ActionReport executeInternalCommand(AdminCommandContext context, String targetInstanceName) { String commandName = getCommandName(); ParameterMap params = new ParameterMap(); params.add("target", targetInstanceName); fillParameterMap(params); CommandRunner runner = serviceLocator.getService(CommandRunner.class); ActionReport subReport = context.getActionReport().addSubActionsReport(); CommandRunner.CommandInvocation inv = runner.getCommandInvocation(commandName, subReport, context.getSubject()); inv.parameters(params); inv.execute(); return subReport; }
CommandInvocation ci = cr.getCommandInvocation("_create-node", report, context.getSubject()); ParameterMap map = new ParameterMap(); map.add("DEFAULT", name);
@Override public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); if (name == null) name = nodehost; if (nodes.getNode(name) != null) { //already created nothing to do here return; } CommandInvocation ci = cr.getCommandInvocation("_create-node", report, context.getSubject()); ParameterMap map = new ParameterMap(); map.add("DEFAULT", name); map.add(NodeUtils.PARAM_NODEDIR, nodedir); map.add(NodeUtils.PARAM_INSTALLDIR, installdir); map.add(NodeUtils.PARAM_NODEHOST, nodehost); map.add(NodeUtils.PARAM_TYPE,"CONFIG"); ci.parameters(map); ci.execute(); }
CommandInvocation ci = cr.getCommandInvocation("_create-node", report, context.getSubject()); ci.parameters(map); ci.execute();
CommandInvocation ci = cr.getCommandInvocation("_delete-node", report, context.getSubject()); ParameterMap map = new ParameterMap(); map.add("DEFAULT", name);
private void executeFromCheckpoint(JobManager.Checkpoint checkpoint, boolean revert, AdminCommandEventBroker eventBroker) { Job job = checkpoint.getJob(); if (subject == null) { subject = checkpoint.getContext().getSubject();
private void executeFromCheckpoint(JobManager.Checkpoint checkpoint, boolean revert, AdminCommandEventBroker eventBroker) { Job job = checkpoint.getJob(); if (subject == null) { subject = checkpoint.getContext().getSubject();