[jbossws-commits] JBossWS SVN: r15929 - in container/jboss71/branches/jbossws-jboss711/src/main: java/org/jboss/as/webservices/tests and 1 other directories.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Tue Mar 13 07:48:00 EDT 2012
Author: alessio.soldano at jboss.com
Date: 2012-03-13 07:47:59 -0400 (Tue, 13 Mar 2012)
New Revision: 15929
Modified:
container/jboss71/branches/jbossws-jboss711/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java
container/jboss71/branches/jbossws-jboss711/src/main/java/org/jboss/as/webservices/tests/RemoteDeployer.java
container/jboss71/branches/jbossws-jboss711/src/main/resources/org/jboss/as/webservices/dmr/LocalDescriptions.properties
Log:
Synch with AS 7.1.1.Final release
Modified: container/jboss71/branches/jbossws-jboss711/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java
===================================================================
--- container/jboss71/branches/jbossws-jboss711/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java 2012-03-13 11:11:46 UTC (rev 15928)
+++ container/jboss71/branches/jbossws-jboss711/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java 2012-03-13 11:47:59 UTC (rev 15929)
@@ -21,6 +21,7 @@
*/
package org.jboss.as.webservices.dmr;
+import org.jboss.as.controller.PathAddress;
import static org.jboss.as.webservices.WSLogger.ROOT_LOGGER;
import static org.jboss.as.webservices.dmr.Constants.ENDPOINT;
import static org.jboss.as.webservices.dmr.Constants.ENDPOINT_CONFIG;
@@ -129,7 +130,8 @@
newControllers.add(ServerConfigService.install(serviceTarget, serverConfig, verificationHandler));
newControllers.add(EndpointRegistryService.install(serviceTarget, verificationHandler));
- String defaultHost = context.getRootResource().getChild(PathElement.pathElement("subsystem", "web")).getModel().get("default-virtual-server").asString();
+ final Resource webSubsystem = context.readResourceFromRoot(PathAddress.pathAddress(PathElement.pathElement("subsystem", "web")));
+ String defaultHost = webSubsystem.getModel().get("default-virtual-server").asString();
newControllers.add(PortComponentLinkService.install(serviceTarget, defaultHost, verificationHandler));
}
}
Modified: container/jboss71/branches/jbossws-jboss711/src/main/java/org/jboss/as/webservices/tests/RemoteDeployer.java
===================================================================
--- container/jboss71/branches/jbossws-jboss711/src/main/java/org/jboss/as/webservices/tests/RemoteDeployer.java 2012-03-13 11:11:46 UTC (rev 15928)
+++ container/jboss71/branches/jbossws-jboss711/src/main/java/org/jboss/as/webservices/tests/RemoteDeployer.java 2012-03-13 11:47:59 UTC (rev 15929)
@@ -19,26 +19,28 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.as.webservices.tests;
+package org.jboss.as.webservices.deployer;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
-import static org.jboss.as.security.Constants.AUTHENTICATION;
-import static org.jboss.as.security.Constants.CODE;
-import static org.jboss.as.security.Constants.FLAG;
-import static org.jboss.as.security.Constants.MODULE_OPTIONS;
-import static org.jboss.as.security.Constants.SECURITY_DOMAIN;
-
import java.io.IOException;
import java.net.InetAddress;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.sasl.RealmCallback;
+import javax.security.sasl.RealmChoiceCallback;
+
import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.OperationBuilder;
import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
import org.jboss.as.controller.client.helpers.standalone.DeploymentPlan;
import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
@@ -49,9 +51,35 @@
import org.jboss.logging.Logger;
import org.jboss.wsf.spi.deployer.Deployer;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ALLOW_RESOURCE_SERVICE_RESTART;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILURE_DESCRIPTION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_HEADERS;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELEASE_VERSION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUIRED;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ROLLBACK_ON_RUNTIME_FAILURE;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;
+import static org.jboss.as.security.Constants.AUTHENTICATION;
+import static org.jboss.as.security.Constants.CLASSIC;
+import static org.jboss.as.security.Constants.CODE;
+import static org.jboss.as.security.Constants.FLAG;
+import static org.jboss.as.security.Constants.LOGIN_MODULES;
+import static org.jboss.as.security.Constants.MODULE_OPTIONS;
+import static org.jboss.as.security.Constants.SECURITY_DOMAIN;
+
/**
* Remote deployer that uses AS7 client deployment API.
*
+ * TODO: this class leaks the ModelControllerClient
+ *
* @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
* @author <a href="mailto:alessio.soldano at jboss.com">Alessio Soldano</a>
*/
@@ -59,23 +87,27 @@
private static final Logger LOGGER = Logger.getLogger(RemoteDeployer.class);
private static final int PORT = 9999;
+
private static final String JBWS_DEPLOYER_HOST = "jbossws.deployer.host";
private static final String JBWS_DEPLOYER_PORT = "jbossws.deployer.port";
+ private static final String JBWS_DEPLOYER_AUTH_USER = "jbossws.deployer.authentication.username";
+ private static final String JBWS_DEPLOYER_AUTH_PWD = "jbossws.deployer.authentication.password";
private final Map<URL, String> url2Id = new HashMap<URL, String>();
- private final InetAddress address = InetAddress.getByName("127.0.0.1");
+ private final CallbackHandler callbackHandler = getCallbackHandler();
+ private final ServerDeploymentManager deploymentManager;
+ private final ModelControllerClient modelControllerClient;
- private ServerDeploymentManager deploymentManager;
-
public RemoteDeployer() throws IOException {
final String host = System.getProperty(JBWS_DEPLOYER_HOST);
InetAddress address;
- if (host != null) {
+ if(host != null) {
address = InetAddress.getByName(host);
} else {
address = InetAddress.getByName("localhost");
}
final Integer port = Integer.getInteger(JBWS_DEPLOYER_PORT, PORT);
- deploymentManager = ServerDeploymentManager.Factory.create(address, port);
+ deploymentManager = ServerDeploymentManager.Factory.create(address, port, callbackHandler);
+ modelControllerClient = ModelControllerClient.Factory.create(address, port, callbackHandler);
}
@Override
@@ -88,7 +120,6 @@
url2Id.put(archiveURL, uniqueId);
}
- @Override
public void undeploy(final URL archiveURL) throws Exception {
final DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
final String uniqueName = url2Id.get(archiveURL);
@@ -108,8 +139,7 @@
final ServerDeploymentPlanResult planResult = deploymentManager.execute(plan).get();
if (deployAction != null) {
- final ServerDeploymentActionResult actionResult = planResult
- .getDeploymentActionResult(deployAction.getId());
+ final ServerDeploymentActionResult actionResult = planResult.getDeploymentActionResult(deployAction.getId());
if (actionResult != null) {
final Exception deploymentException = (Exception) actionResult.getDeploymentException();
if (deploymentException != null)
@@ -122,54 +152,124 @@
}
}
- @Override
- public void addSecurityDomain(String name, Map<String, String> authenticationOptions) throws Exception {
- ModelControllerClient client = ModelControllerClient.Factory.create(address, PORT);
- ModelNode result = createSecurityDomain(client, name, authenticationOptions);
- checkResult(result);
- }
+ public String getServerVersion() throws Exception {
+ final ModelNode request = new ModelNode();
+ request.get(OP).set(READ_ATTRIBUTE_OPERATION);
+ request.get(OP_ADDR).setEmptyList();
+ request.get(NAME).set(RELEASE_VERSION);
- @Override
- public void removeSecurityDomain(String name) throws Exception {
- ModelControllerClient client = ModelControllerClient.Factory.create(address, PORT);
- ModelNode result = removeSecurityDomain(client, name);
- checkResult(result);
+ final ModelNode response = applyUpdate(request, getModelControllerClient());
+ return response.get(RESULT).asString();
}
- private static ModelNode createSecurityDomain(ModelControllerClient client, String name, Map<String, String> authenticationOptions) throws IOException {
+ public void addSecurityDomain(String name, Map<String, String> authenticationOptions) throws Exception {
+ final List<ModelNode> updates = new ArrayList<ModelNode>();
+
ModelNode op = new ModelNode();
op.get(OP).set(ADD);
op.get(OP_ADDR).add(SUBSYSTEM, "security");
op.get(OP_ADDR).add(SECURITY_DOMAIN, name);
- ModelNode loginModule = op.get(AUTHENTICATION).add();
+ updates.add(op);
+
+ op = new ModelNode();
+ op.get(OP).set(ADD);
+ op.get(OP_ADDR).add(SUBSYSTEM, "security");
+ op.get(OP_ADDR).add(SECURITY_DOMAIN, name);
+ op.get(OP_ADDR).add(AUTHENTICATION, CLASSIC);
+
+ final ModelNode loginModule = op.get(LOGIN_MODULES).add();
loginModule.get(CODE).set("UsersRoles");
- loginModule.get(FLAG).set("required");
- ModelNode moduleOptions = loginModule.get(MODULE_OPTIONS);
+ loginModule.get(FLAG).set(REQUIRED);
+ op.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
+ updates.add(op);
+
+ final ModelNode moduleOptions = loginModule.get(MODULE_OPTIONS);
if (authenticationOptions != null) {
- for (String k : authenticationOptions.keySet()) {
+ for (final String k : authenticationOptions.keySet()) {
moduleOptions.add(k, authenticationOptions.get(k));
}
}
- return client.execute(op);
+
+ applyUpdates(updates, getModelControllerClient());
}
- private static ModelNode removeSecurityDomain(ModelControllerClient client, String name) throws IOException {
- ModelNode op = new ModelNode();
+ public void removeSecurityDomain(String name) throws Exception {
+ final ModelNode op = new ModelNode();
op.get(OP).set(REMOVE);
op.get(OP_ADDR).add(SUBSYSTEM, "security");
op.get(OP_ADDR).add(SECURITY_DOMAIN, name);
- return client.execute(op);
+ op.get(OPERATION_HEADERS, ROLLBACK_ON_RUNTIME_FAILURE).set(false);
+
+ applyUpdate(op, getModelControllerClient());
}
- private static void checkResult(ModelNode result) throws Exception {
- if (result.hasDefined("outcome") && "success".equals(result.get("outcome").asString())) {
- if (result.hasDefined("result")) {
- LOGGER.info(result.get("result"));
+ private ModelControllerClient getModelControllerClient() {
+ return modelControllerClient;
+ }
+
+ private static void applyUpdates(final List<ModelNode> updates, final ModelControllerClient client) throws Exception {
+ for (final ModelNode update : updates) {
+ applyUpdate(update, client);
+ }
+ }
+
+ private static ModelNode applyUpdate(final ModelNode update, final ModelControllerClient client) throws Exception {
+ final ModelNode result = client.execute(new OperationBuilder(update).build());
+ checkResult(result);
+ return result;
+ }
+
+ private static void checkResult(final ModelNode result) throws Exception {
+ if (result.hasDefined(OUTCOME) && SUCCESS.equals(result.get(OUTCOME).asString())) {
+ if (result.hasDefined(RESULT)) {
+ LOGGER.info(result.get(RESULT));
}
- } else if (result.hasDefined("failure-description")) {
- throw new Exception(result.get("failure-description").toString());
+ } else if (result.hasDefined(FAILURE_DESCRIPTION)) {
+ throw new Exception(result.get(FAILURE_DESCRIPTION).toString());
} else {
- throw new Exception("Operation not successful; outcome = " + result.get("outcome"));
+ throw new Exception("Operation not successful; outcome = " + result.get(OUTCOME));
}
}
+
+ private static CallbackHandler getCallbackHandler() {
+ final String username = getSystemProperty(JBWS_DEPLOYER_AUTH_USER, null);
+ if (username == null || ("${" + JBWS_DEPLOYER_AUTH_USER + "}").equals(username)) {
+ return null;
+ }
+ String pwd = getSystemProperty(JBWS_DEPLOYER_AUTH_PWD, null);
+ if (("${" + JBWS_DEPLOYER_AUTH_PWD + "}").equals(pwd)) {
+ pwd = null;
+ }
+ final String password = pwd;
+ return new CallbackHandler() {
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ for (Callback current : callbacks) {
+ if (current instanceof NameCallback) {
+ NameCallback ncb = (NameCallback) current;
+ ncb.setName(username);
+ } else if (current instanceof PasswordCallback) {
+ PasswordCallback pcb = (PasswordCallback) current;
+ pcb.setPassword(password.toCharArray());
+ } else if (current instanceof RealmCallback) {
+ RealmCallback rcb = (RealmCallback) current;
+ rcb.setText(rcb.getDefaultText());
+ } else if (current instanceof RealmChoiceCallback) {
+ // Ignored but not rejected.
+ } else {
+ throw new UnsupportedCallbackException(current);
+ }
+ }
+ }
+ };
+ }
+
+ private static String getSystemProperty(final String name, final String defaultValue) {
+ PrivilegedAction<String> action = new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty(name, defaultValue);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+
}
Modified: container/jboss71/branches/jbossws-jboss711/src/main/resources/org/jboss/as/webservices/dmr/LocalDescriptions.properties
===================================================================
--- container/jboss71/branches/jbossws-jboss711/src/main/resources/org/jboss/as/webservices/dmr/LocalDescriptions.properties 2012-03-13 11:11:46 UTC (rev 15928)
+++ container/jboss71/branches/jbossws-jboss711/src/main/resources/org/jboss/as/webservices/dmr/LocalDescriptions.properties 2012-03-13 11:47:59 UTC (rev 15929)
@@ -1,5 +1,7 @@
ws=The configuration of the web services subsystem.
ws.add=Adds the web services subsystem.
+ws.remove=Removes the web services subsystem.
+deployment=Runtime resources exposed by web service components in the deployment.
endpoint=Webservice endpoint.
endpoint.name=Webservice endpoint name.
endpoint.context=Webservice endpoint context.
@@ -20,16 +22,16 @@
response.count=Count of responses the endpoint generated.
fault.count=Count of faults the endpoint generated.
-endpoint.config=Webservice Endpoint configuration
-endpoint.config.add=Add a new endpoint configuration
-endpoint.config.remove=Remove a endpoint configuration
-endpoint.config.name=Endpoint configuration name
-protocol.binding=Protocol binding value
-servicename.pattern=Service name pattern
-portname.pattern=Port name pattern
+endpoint.config=Webservice endpoint configuration
+endpoint.config.add=Add endpoint configuration
+endpoint.config.remove=Remove endpoint configuration
+endpoint.config.pre.handler.chain=Endpoint configuration PRE handler chain
+endpoint.config.post.handler.chain=Endpoint configuration POST handler chain
+endpoint.config.property=Endpoint configuration property
+endpoint.config.property.add=Add endpoint configuration property
+endpoint.config.property.remove=Remove endpoint configuration property
+endpoint.config.property.value="Endpoint configuration property value
+protocol.binding=Protocol binding
+handler=Endpoint handler
handler.name=Handler name
handler.class=Handler class
-property.name=Property name
-property.value=Property value
-feature.name=Feature name
-feature.value=Feature value
More information about the jbossws-commits
mailing list