repo
stringlengths 1
191
⌀ | file
stringlengths 23
351
| code
stringlengths 0
5.32M
| file_length
int64 0
5.32M
| avg_line_length
float64 0
2.9k
| max_line_length
int64 0
288k
| extension_type
stringclasses 1
value |
---|---|---|---|---|---|---|
null | wildfly-main/rts/src/main/java/org/wildfly/extension/rts/service/AbstractRTSService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.rts.service;
import io.undertow.servlet.api.Deployment;
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.servlet.api.DeploymentManager;
import io.undertow.servlet.api.ListenerInfo;
import io.undertow.servlet.api.ServletContainer;
import io.undertow.servlet.api.ServletInfo;
import java.net.Inet4Address;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Supplier;
import jakarta.servlet.ServletException;
import org.jboss.as.network.SocketBinding;
import org.jboss.jbossts.star.service.ContextListener;
import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher;
import org.wildfly.extension.rts.logging.RTSLogger;
import org.wildfly.extension.undertow.Host;
/**
*
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*
*/
public class AbstractRTSService {
private final Supplier<Host> hostSupplier;
private final Supplier<SocketBinding> socketBindingSupplier;
private volatile Deployment deployment = null;
public AbstractRTSService(final Supplier<Host> hostSupplier, final Supplier<SocketBinding> socketBindingSupplier) {
this.hostSupplier = hostSupplier;
this.socketBindingSupplier = socketBindingSupplier;
}
protected DeploymentInfo getDeploymentInfo(final String name, final String contextPath, final Map<String, String> initialParameters) {
final DeploymentInfo deploymentInfo = new DeploymentInfo();
deploymentInfo.setClassLoader(ParticipantService.class.getClassLoader());
deploymentInfo.setContextPath(contextPath);
deploymentInfo.setDeploymentName(name);
deploymentInfo.addServlets(getResteasyServlet());
deploymentInfo.addListener(getRestATListener());
for (Entry<String, String> entry : initialParameters.entrySet()) {
deploymentInfo.addInitParameter(entry.getKey(), entry.getValue());
}
return deploymentInfo;
}
protected void deployServlet(final DeploymentInfo deploymentInfo) {
DeploymentManager manager = ServletContainer.Factory.newInstance().addDeployment(deploymentInfo);
manager.deploy();
deployment = manager.getDeployment();
try {
hostSupplier.get().registerDeployment(deployment, manager.start());
} catch (ServletException e) {
RTSLogger.ROOT_LOGGER.warn(e.getMessage(), e);
deployment = null;
}
}
protected void undeployServlet() {
if (deployment != null) {
hostSupplier.get().unregisterDeployment(deployment);
deployment = null;
}
}
protected String getBaseUrl() {
final String address = socketBindingSupplier.get().getAddress().getHostAddress();
final int port = socketBindingSupplier.get().getAbsolutePort();
if (socketBindingSupplier.get().getAddress() instanceof Inet4Address) {
return "http://" + address + ":" + port;
} else {
return "http://[" + address + "]:" + port;
}
}
private ServletInfo getResteasyServlet() {
final ServletInfo servletInfo = new ServletInfo("Resteasy", HttpServletDispatcher.class);
servletInfo.addMapping("/*");
return servletInfo;
}
private ListenerInfo getRestATListener() {
final ListenerInfo listenerInfo = new ListenerInfo(ContextListener.class);
return listenerInfo;
}
}
| 4,475 | 35.688525 | 138 | java |
null | wildfly-main/rts/src/main/java/org/wildfly/extension/rts/service/InboundBridgeService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.rts.service;
import com.arjuna.ats.arjuna.recovery.RecoveryManager;
import com.arjuna.ats.arjuna.recovery.RecoveryModule;
import com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule;
import com.arjuna.ats.jta.recovery.XAResourceOrphanFilter;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.narayana.rest.bridge.inbound.InboundBridge;
import org.jboss.narayana.rest.bridge.inbound.InboundBridgeOrphanFilter;
import org.jboss.narayana.rest.bridge.inbound.InboundBridgeRecoveryModule;
import org.wildfly.extension.rts.logging.RTSLogger;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
public class InboundBridgeService implements Service<InboundBridgeService> {
private RecoveryModule recoveryModule;
private XAResourceOrphanFilter orphanFilter;
@Override
public void start(StartContext startContext) throws StartException {
RTSLogger.ROOT_LOGGER.trace("InboundBridgeService.start");
addDeserializerAndOrphanFilter();
addRecoveryModule();
}
@Override
public void stop(StopContext stopContext) {
RTSLogger.ROOT_LOGGER.trace("InboundBridgeService.stop");
removeOrphanFilter();
removeRecoveryModule();
}
@Override
public InboundBridgeService getValue() throws IllegalStateException, IllegalArgumentException {
RTSLogger.ROOT_LOGGER.trace("InboundBridgeService.getValue");
return this;
}
private void addDeserializerAndOrphanFilter() {
final RecoveryManager recoveryManager = RecoveryManager.manager();
for (RecoveryModule recoveryModule : recoveryManager.getModules()) {
if (recoveryModule instanceof XARecoveryModule) {
orphanFilter = new InboundBridgeOrphanFilter();
((XARecoveryModule) recoveryModule).addXAResourceOrphanFilter(orphanFilter);
((XARecoveryModule) recoveryModule).addSerializableXAResourceDeserializer(new InboundBridge());
}
}
}
private void removeOrphanFilter() {
if (orphanFilter == null) {
return;
}
final RecoveryManager recoveryManager = RecoveryManager.manager();
for (RecoveryModule recoveryModule : recoveryManager.getModules()) {
if (recoveryModule instanceof XARecoveryModule) {
((XARecoveryModule) recoveryModule).removeXAResourceOrphanFilter(orphanFilter);
}
}
}
private void addRecoveryModule() {
final RecoveryManager recoveryManager = RecoveryManager.manager();
recoveryModule = new InboundBridgeRecoveryModule();
recoveryManager.addModule(recoveryModule);
}
private void removeRecoveryModule() {
if (recoveryModule == null) {
return;
}
final RecoveryManager recoveryManager = RecoveryManager.manager();
recoveryManager.removeModule(recoveryModule, false);
}
}
| 4,132 | 35.901786 | 111 | java |
null | wildfly-main/rts/src/main/java/org/wildfly/extension/rts/service/VolatileParticipantService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.rts.service;
import io.undertow.servlet.api.DeploymentInfo;
import org.jboss.as.network.SocketBinding;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.narayana.rest.integration.VolatileParticipantResource;
import org.jboss.narayana.rest.integration.api.ParticipantsManagerFactory;
import org.wildfly.extension.rts.jaxrs.VolatileParticipantApplication;
import org.wildfly.extension.rts.logging.RTSLogger;
import org.wildfly.extension.undertow.Host;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
/**
*
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*
*/
public final class VolatileParticipantService extends AbstractRTSService implements Service<VolatileParticipantService> {
public static final String CONTEXT_PATH = VolatileParticipantResource.BASE_PATH_SEGMENT;
private static final String DEPLOYMENT_NAME = "Volatile REST-AT Participant";
public VolatileParticipantService(Supplier<Host> hostSupplier, Supplier<SocketBinding> socketBindingSupplier) {
super(hostSupplier, socketBindingSupplier);
}
@Override
public VolatileParticipantService getValue() throws IllegalStateException, IllegalArgumentException {
RTSLogger.ROOT_LOGGER.trace("VolatileParticipantService.getValue");
return this;
}
@Override
public void start(StartContext context) throws StartException {
RTSLogger.ROOT_LOGGER.trace("VolatileParticipantService.start");
deployParticipant();
ParticipantsManagerFactory.getInstance().setBaseUrl(getBaseUrl());
}
@Override
public void stop(StopContext context) {
RTSLogger.ROOT_LOGGER.trace("ParticipantService.stop");
undeployServlet();
}
private void deployParticipant() {
undeployServlet();
final Map<String, String> initialParameters = new HashMap<String, String>();
initialParameters.put("jakarta.ws.rs.Application", VolatileParticipantApplication.class.getName());
final DeploymentInfo participantDeploymentInfo = getDeploymentInfo(DEPLOYMENT_NAME, CONTEXT_PATH, initialParameters);
deployServlet(participantDeploymentInfo);
}
}
| 3,375 | 36.932584 | 125 | java |
null | wildfly-main/rts/src/main/java/org/wildfly/extension/rts/service/ParticipantService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.rts.service;
import io.undertow.servlet.api.DeploymentInfo;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
import org.jboss.as.network.SocketBinding;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.narayana.rest.integration.ParticipantResource;
import org.jboss.narayana.rest.integration.api.ParticipantsManagerFactory;
import org.wildfly.extension.rts.jaxrs.ParticipantApplication;
import org.wildfly.extension.rts.logging.RTSLogger;
import org.wildfly.extension.undertow.Host;
/**
*
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*
*/
public final class ParticipantService extends AbstractRTSService implements Service<ParticipantService> {
public static final String CONTEXT_PATH = ParticipantResource.BASE_PATH_SEGMENT;
private static final String DEPLOYMENT_NAME = "REST-AT Participant";
public ParticipantService(Supplier<Host> hostSupplier, Supplier<SocketBinding> socketBindingSupplier) {
super(hostSupplier, socketBindingSupplier);
}
@Override
public ParticipantService getValue() throws IllegalStateException, IllegalArgumentException {
RTSLogger.ROOT_LOGGER.trace("ParticipantService.getValue");
return this;
}
@Override
public void start(StartContext context) throws StartException {
RTSLogger.ROOT_LOGGER.trace("ParticipantService.start");
deployParticipant();
ParticipantsManagerFactory.getInstance().setBaseUrl(getBaseUrl());
}
@Override
public void stop(StopContext context) {
RTSLogger.ROOT_LOGGER.trace("ParticipantService.stop");
undeployServlet();
}
private void deployParticipant() {
undeployServlet();
final Map<String, String> initialParameters = new HashMap<String, String>();
initialParameters.put("jakarta.ws.rs.Application", ParticipantApplication.class.getName());
final DeploymentInfo participantDeploymentInfo = getDeploymentInfo(DEPLOYMENT_NAME, CONTEXT_PATH, initialParameters);
deployServlet(participantDeploymentInfo);
}
}
| 3,287 | 35.533333 | 125 | java |
null | wildfly-main/rts/src/main/java/org/wildfly/extension/rts/service/CoordinatorService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.rts.service;
import io.undertow.servlet.api.DeploymentInfo;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
import org.jboss.as.network.SocketBinding;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.wildfly.extension.rts.jaxrs.CoordinatorApplication;
import org.wildfly.extension.rts.logging.RTSLogger;
import org.wildfly.extension.undertow.Host;
/**
*
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*
*/
public final class CoordinatorService extends AbstractRTSService implements Service<CoordinatorService> {
public static final String CONTEXT_PATH = "/rest-at-coordinator";
private static final String DEPLOYMENT_NAME = "REST-AT Coordinator";
public CoordinatorService(Supplier<Host> hostSupplier, Supplier<SocketBinding> socketBindingSupplier) {
super(hostSupplier, socketBindingSupplier);
}
@Override
public CoordinatorService getValue() throws IllegalStateException, IllegalArgumentException {
RTSLogger.ROOT_LOGGER.trace("CoordinatorService.getValue");
return this;
}
@Override
public void start(StartContext context) throws StartException {
RTSLogger.ROOT_LOGGER.trace("CoordinatorService.start");
deployCoordinator();
}
@Override
public void stop(StopContext context) {
RTSLogger.ROOT_LOGGER.trace("CoordinatorService.stop");
undeployServlet();
}
private void deployCoordinator() {
undeployServlet();
final Map<String, String> initialParameters = new HashMap<String, String>();
initialParameters.put("jakarta.ws.rs.Application", CoordinatorApplication.class.getName());
final DeploymentInfo coordinatorDeploymentInfo = getDeploymentInfo(DEPLOYMENT_NAME, CONTEXT_PATH, initialParameters);
deployServlet(coordinatorDeploymentInfo);
}
}
| 3,058 | 34.16092 | 125 | java |
null | wildfly-main/rts/src/main/java/org/wildfly/extension/rts/logging/RTSLogger.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.rts.logging;
import jakarta.ws.rs.container.ContainerResponseContext;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.LogMessage;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;
import static org.jboss.logging.Logger.Level.ERROR;
/**
*
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*
*/
@MessageLogger(projectCode = "WFLYRTS", length = 4)
public interface RTSLogger extends BasicLogger {
RTSLogger ROOT_LOGGER = Logger.getMessageLogger(RTSLogger.class, "org.wildfly.extension.rts");
@Message(id = 1, value = "Can't import global transaction to wildfly transaction client.")
IllegalStateException failueOnImportingGlobalTransactionFromWildflyClient(@Cause jakarta.transaction.SystemException se);
@LogMessage(level = ERROR)
@Message(id = 2, value = "Cannot get transaction status on handling response context %s")
void cannotGetTransactionStatus(ContainerResponseContext responseCtx, @Cause Throwable cause);
}
| 2,171 | 39.981132 | 125 | java |
null | wildfly-main/rts/src/main/java/org/wildfly/extension/rts/deployment/InboundBridgeDeploymentProcessor.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.rts.deployment;
import org.jboss.as.jaxrs.deployment.JaxrsAttachments;
import org.jboss.as.jaxrs.deployment.ResteasyDeploymentData;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.annotation.CompositeIndex;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.narayana.rest.bridge.inbound.EJBExceptionMapper;
import org.jboss.narayana.rest.bridge.inbound.InboundBridgeFilter;
import org.jboss.narayana.rest.bridge.inbound.TransactionalExceptionMapper;
import org.wildfly.extension.rts.jaxrs.ImportWildflyClientGlobalTransactionFilter;
import jakarta.ejb.Stateful;
import jakarta.ejb.Stateless;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.Path;
import java.util.List;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
public class InboundBridgeDeploymentProcessor implements DeploymentUnitProcessor {
private static final DotName PATH_DOT_NAME = DotName.createSimple(Path.class.getName());
private static final DotName TRANSACTIONAL_DOT_NAME = DotName.createSimple(Transactional.class.getName());
private static final DotName STATELESS_ATTRIBUTE_DOT_NAME = DotName.createSimple(Stateless.class.getName());
private static final DotName STATEFUL_ATTRIBUTE_DOT_NAME = DotName.createSimple(Stateful.class.getName());
private static final String[] PROVIDERS = new String[] {
InboundBridgeFilter.class.getName(),
ImportWildflyClientGlobalTransactionFilter.class.getName(),
TransactionalExceptionMapper.class.getName(),
EJBExceptionMapper.class.getName()
};
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (isBridgeRequired(deploymentUnit)) {
registerProviders(deploymentUnit);
}
}
private boolean isBridgeRequired(final DeploymentUnit deploymentUnit) {
final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
if (index == null) {
return false;
}
final List<AnnotationInstance> pathAnnotations = index.getAnnotations(PATH_DOT_NAME);
for (AnnotationInstance annotationInstance : pathAnnotations) {
final Object target = annotationInstance.target();
if (target instanceof ClassInfo) {
final ClassInfo classInfo = (ClassInfo) target;
if (classInfo.annotationsMap().get(TRANSACTIONAL_DOT_NAME) != null) {
return true;
}
if (classInfo.annotationsMap().get(STATELESS_ATTRIBUTE_DOT_NAME) != null ||
classInfo.annotationsMap().get(STATEFUL_ATTRIBUTE_DOT_NAME) != null) {
return true;
}
}
}
return false;
}
private void registerProviders(final DeploymentUnit deploymentUnit) {
final ResteasyDeploymentData resteasyDeploymentData = deploymentUnit.getAttachment(JaxrsAttachments.RESTEASY_DEPLOYMENT_DATA);
if (resteasyDeploymentData != null) {
for (final String provider : PROVIDERS) {
resteasyDeploymentData.getScannedProviderClasses().add(provider);
}
}
}
}
| 4,751 | 41.810811 | 134 | java |
null | wildfly-main/rts/src/main/java/org/wildfly/extension/rts/jaxrs/CoordinatorApplication.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.rts.jaxrs;
import java.util.Set;
import org.jboss.jbossts.star.service.TMApplication;
import jakarta.ws.rs.core.Application;
/**
*
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*
*/
public final class CoordinatorApplication extends Application {
private final TMApplication tmApplication;
public CoordinatorApplication() {
tmApplication = new TMApplication();
}
@Override
public Set<Class<?>> getClasses() {
return tmApplication.getClasses();
}
@Override
public Set<Object> getSingletons() {
return tmApplication.getSingletons();
}
}
| 1,677 | 30.660377 | 70 | java |
null | wildfly-main/rts/src/main/java/org/wildfly/extension/rts/jaxrs/ParticipantApplication.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.rts.jaxrs;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.jboss.narayana.rest.integration.HeuristicMapper;
import org.jboss.narayana.rest.integration.ParticipantResource;
import jakarta.ws.rs.core.Application;
/**
*
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*
*/
public final class ParticipantApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
return new HashSet<>(Arrays.asList(ParticipantResource.class, HeuristicMapper.class));
}
}
| 1,606 | 33.934783 | 94 | java |
null | wildfly-main/rts/src/main/java/org/wildfly/extension/rts/jaxrs/ImportWildflyClientGlobalTransactionFilter.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.rts.jaxrs;
import java.io.IOException;
import jakarta.annotation.Priority;
import jakarta.transaction.Status;
import jakarta.transaction.SystemException;
import jakarta.ws.rs.Priorities;
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.container.ContainerRequestFilter;
import jakarta.ws.rs.container.ContainerResponseContext;
import jakarta.ws.rs.container.ContainerResponseFilter;
import jakarta.ws.rs.ext.Provider;
import org.wildfly.extension.rts.logging.RTSLogger;
import org.wildfly.transaction.client.ContextTransactionManager;
import org.wildfly.transaction.client.LocalTransactionContext;
/**
* <p>
* Request and response filter which is expected to be called
* for the request side after the {@link org.jboss.narayana.rest.bridge.inbound.InboundBridgeFilter} is processed
* while on the response side before the {@link org.jboss.narayana.rest.bridge.inbound.InboundBridgeFilter} is processed.
* </p>
* <p>
* Purpose of this filter is an integration of WFTC with Narayana REST-AT Inbound Bridge.
* Inbound Bridge uses Narayana transactions while WFLY utilizes WFTC transactions (wrapping the underlaying Narayana) ones.
* For that on request side the Inbound bridge first creates the Narayana transaction and then the request
* filter makes the WFTC to wrap and to know about this transaction.
* On the response side the WFTC needs to suspend its wrapping transaction and then Narayana suspend its own
* transaction (which was already suspended by WFTC callback and thus is ignored on the Narayana side).
* </p>
* <p>
* The {@link org.jboss.narayana.rest.bridge.inbound.InboundBridgeFilter} defines its {@link Priority}
* as <code>{@code Priorities#USER}-100</code>. This WildFly filter has to be processed after the Narayana
* one and it needs to define higher priority.
* </p>
*
* @author Ondrej Chaloupka <[email protected]>
*/
@Provider
@Priority(Priorities.USER - 80)
public class ImportWildflyClientGlobalTransactionFilter implements ContainerRequestFilter, ContainerResponseFilter {
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
try {
// pull in any RTS transaction
LocalTransactionContext.getCurrent().importProviderTransaction();
} catch (SystemException se) {
throw RTSLogger.ROOT_LOGGER.failueOnImportingGlobalTransactionFromWildflyClient(se);
}
}
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
try {
// suspending context before returning to the client
if (ContextTransactionManager.getInstance() != null &&
ContextTransactionManager.getInstance().getStatus() != Status.STATUS_NO_TRANSACTION) {
ContextTransactionManager.getInstance().suspend();
}
} catch (SystemException se) {
RTSLogger.ROOT_LOGGER.cannotGetTransactionStatus(responseContext, se);
}
}
}
| 4,131 | 45.954545 | 126 | java |
null | wildfly-main/rts/src/main/java/org/wildfly/extension/rts/jaxrs/VolatileParticipantApplication.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.rts.jaxrs;
import org.jboss.narayana.rest.integration.VolatileParticipantResource;
import jakarta.ws.rs.core.Application;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
*
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*
*/
public final class VolatileParticipantApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
return new HashSet<>(Arrays.asList(VolatileParticipantResource.class));
}
}
| 1,546 | 34.159091 | 79 | java |
null | wildfly-main/webservices/opensaml-sysconfig/src/main/java/org/jboss/as/webservices/opensaml/sysconfig/SystemPropertiesSecMgrSource.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2022, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.opensaml.sysconfig;
import java.security.PrivilegedAction;
import java.util.Properties;
import org.kohsuke.MetaInfServices;
import org.opensaml.core.config.ConfigurationPropertiesSource;
import org.opensaml.core.config.ConfigurationService;
import org.opensaml.core.config.provider.SystemPropertyConfigurationPropertiesSource;
import static java.lang.System.getProperty;
import static java.security.AccessController.doPrivileged;
/**
* A ConfigurationPropertiesSource implementation to fix https://issues.redhat.com/browse/WFLY-16650
*/
@MetaInfServices
public class SystemPropertiesSecMgrSource implements ConfigurationPropertiesSource {
private SystemPropertyConfigurationPropertiesSource delegate = new SystemPropertyConfigurationPropertiesSource();
private Properties empty = new Properties(0);
private Properties patritionNameProperties = new Properties(1);
public Properties getProperties() {
try {
return delegate.getProperties();
} catch (SecurityException e) {
String value = doPrivileged((PrivilegedAction<String>) () -> getProperty(ConfigurationService.PROPERTY_PARTITION_NAME));
if (value == null) {
return empty;
} else {
value = System.getProperty(ConfigurationService.PROPERTY_PARTITION_NAME);
patritionNameProperties.setProperty(ConfigurationService.PROPERTY_PARTITION_NAME, value);
return patritionNameProperties;
}
}
}
}
| 2,581 | 41.327869 | 132 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/config/ServerConfigImplTestCase.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.config;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.net.URL;
import java.net.URLClassLoader;
import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.spi.management.StackConfig;
import org.jboss.wsf.spi.management.StackConfigFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* @author <a href="mailto:[email protected]>Alessio Soldano</a>
*/
public class ServerConfigImplTestCase {
private static ClassLoader origTCCL;
public ServerConfigImplTestCase() {
}
@Test
public void testIsModifiable() throws Exception {
ServerConfigImpl sc = newServerConfigImpl();
sc.create();
assertTrue(sc.isModifiable());
sc.incrementWSDeploymentCount();
assertFalse(sc.isModifiable());
sc.decrementWSDeploymentCount();
assertTrue(sc.isModifiable());
sc.incrementWSDeploymentCount();
sc.incrementWSDeploymentCount();
assertFalse(sc.isModifiable());
sc.create();
assertTrue(sc.isModifiable());
}
@Test
public void testSingleAttributeUpdate() throws Exception {
internalTestSingleAttributeUpdate(new Callback() {
@Override
public void setAttribute(ServerConfig sc) throws Exception {
sc.setModifySOAPAddress(true);
}
});
internalTestSingleAttributeUpdate(new Callback() {
@Override
public void setAttribute(ServerConfig sc) throws Exception {
sc.setWebServiceHost("foo");
}
});
internalTestSingleAttributeUpdate(new Callback() {
@Override
public void setAttribute(ServerConfig sc) throws Exception {
sc.setWebServicePort(976);
}
});
internalTestSingleAttributeUpdate(new Callback() {
@Override
public void setAttribute(ServerConfig sc) throws Exception {
sc.setWebServiceSecurePort(5435);
}
});
internalTestSingleAttributeUpdate(new Callback() {
@Override
public void setAttribute(ServerConfig sc) throws Exception {
sc.setWebServicePathRewriteRule("MY/TEST/PATH");
}
});
}
@Test
public void testMultipleAttributesUpdate() throws Exception {
Callback cbA = new Callback() {
@Override
public void setAttribute(ServerConfig sc) throws Exception {
sc.setModifySOAPAddress(true);
}
};
Callback cbB = new Callback() {
@Override
public void setAttribute(ServerConfig sc) throws Exception {
sc.setWebServiceHost("foo");
}
};
Callback cbC = new Callback() {
@Override
public void setAttribute(ServerConfig sc) throws Exception {
sc.setWebServicePort(976);
}
};
Callback cbD = new Callback() {
@Override
public void setAttribute(ServerConfig sc) throws Exception {
sc.setWebServiceSecurePort(5435);
}
};
Callback cbE = new Callback() {
@Override
public void setAttribute(ServerConfig sc) throws Exception {
sc.setWebServicePathRewriteRule("MY/TEST/PATH");
}
};
internalTestMultipleAttributeUpdate(cbA, new Callback[]{cbB, cbC, cbD, cbE});
internalTestMultipleAttributeUpdate(cbB, new Callback[]{cbA, cbC, cbD, cbE});
internalTestMultipleAttributeUpdate(cbC, new Callback[]{cbA, cbB, cbD, cbE});
internalTestMultipleAttributeUpdate(cbD, new Callback[]{cbA, cbB, cbC, cbE});
internalTestMultipleAttributeUpdate(cbE, new Callback[]{cbA, cbB, cbC, cbD});
}
protected void internalTestSingleAttributeUpdate(Callback cb) throws Exception {
ServerConfigImpl sc = newServerConfigImpl();
sc.create();
assertTrue(sc.isModifiable());
cb.setAttribute(sc);
sc.incrementWSDeploymentCount();
assertFalse(sc.isModifiable());
try {
cb.setAttribute(sc);
fail();
} catch (DisabledOperationException e) {
//check the error message says the operation can't be done because there's an active deployment
assertTrue("Expected WFLYWS0064 message, but got " + e.getMessage(), e.getMessage().contains("WFLYWS0064"));
}
sc.decrementWSDeploymentCount();
assertTrue(sc.isModifiable());
try {
cb.setAttribute(sc);
fail();
} catch (DisabledOperationException e) {
//check the error message says the operation can't be done because of pending former model update(s) requiring reload
assertTrue("Expected WFLYWS0063 message, but got " + e.getMessage(), e.getMessage().contains("WFLYWS0063"));
}
sc.create();
assertTrue(sc.isModifiable());
cb.setAttribute(sc);
}
protected void internalTestMultipleAttributeUpdate(Callback cb1, Callback[] otherCbs) throws Exception {
ServerConfigImpl sc = newServerConfigImpl();
sc.create();
assertTrue(sc.isModifiable());
cb1.setAttribute(sc);
sc.incrementWSDeploymentCount();
assertFalse(sc.isModifiable());
try {
cb1.setAttribute(sc);
fail();
} catch (DisabledOperationException e) {
//check the error message says the operation can't be done because there's an active deployment
assertTrue("Expected WFLYWS0064 message, but got " + e.getMessage(), e.getMessage().contains("WFLYWS0064"));
}
sc.decrementWSDeploymentCount();
assertTrue(sc.isModifiable());
try {
cb1.setAttribute(sc);
fail();
} catch (DisabledOperationException e) {
//check the error message says the operation can't be done because of pending former model update(s) requiring reload
assertTrue("Expected WFLYWS0063 message, but got " + e.getMessage(), e.getMessage().contains("WFLYWS0063"));
}
//other attributes are still modified properly as they're still in synch
for (Callback cb : otherCbs) {
cb.setAttribute(sc);
}
}
private static ServerConfigImpl newServerConfigImpl() {
return ServerConfigImpl.newInstance();
}
@BeforeClass
public static void setStackConfigFactory() throws Exception {
URL url = ServerConfigImplTestCase.class.getResource("util/");
origTCCL = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[]{url}));
}
@AfterClass
public static void restoreStackConfigFactory() {
Thread.currentThread().setContextClassLoader(origTCCL);
origTCCL = null;
}
public interface Callback {
void setAttribute(ServerConfig sc) throws Exception;
}
public static class TestStackConfigFactory extends StackConfigFactory {
@Override
public StackConfig getStackConfig() {
return new TestStackConfig();
}
}
public static class TestStackConfig implements StackConfig {
@Override
public String getImplementationTitle() {
return null;
}
@Override
public String getImplementationVersion() {
return null;
}
public void validatePathRewriteRule(String rule) {
//NOOP
}
}
}
| 8,820 | 36.063025 | 129 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/verification/BrokenSampleWSImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.verification;
import jakarta.jws.WebService;
/**
* @author sfcoy
*
*/
@WebService(portName = "sample-ws-port", wsdlLocation = "/META-INF/wsdl/sample.wsdl", endpointInterface = "org.jboss.as.webservices.verification.SampleWS")
public class BrokenSampleWSImpl {
void performWork() {
}
public static String discoverNewLands() {
return "Wallaby Hill";
}
@Override
protected void finalize() throws Throwable {
super.finalize();
}
public final void triggerReport() {
}
// public boolean isWorking() {
// return false;
// }
}
| 1,653 | 29.072727 | 155 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/verification/AbstractSampleWSImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.verification;
/**
* @author sfcoy
*
*/
public class AbstractSampleWSImpl {
public void performWork() {
}
}
| 1,177 | 33.647059 | 70 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/verification/AnnotatedSampleWSImplWithExclusion.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.verification;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
/**
* @author sfcoy
*
*/
@WebService
public class AnnotatedSampleWSImplWithExclusion implements SampleWS {
@Override
@WebMethod
public void performWork() {
}
@Override
@WebMethod
public String discoverNewLands() {
return null;
}
@Override
@WebMethod
public boolean isWorking() {
return false;
}
@Override
@WebMethod(exclude=true)
public void triggerReport() {
}
}
| 1,587 | 25.915254 | 70 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/verification/SimpleWSImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.verification;
import jakarta.jws.WebService;
/**
* @author sfcoy
*
*/
@WebService
public class SimpleWSImpl {
public void hello() {
}
}
| 1,208 | 30.815789 | 70 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/verification/JwsWebServiceEndpointVerifierTestCase.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.verification;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex;
import org.jboss.as.webservices.verification.JwsWebServiceEndpointVerifier.ImplementationHasFinalize;
import org.jboss.as.webservices.verification.JwsWebServiceEndpointVerifier.WebMethodIsNotPublic;
import org.jboss.as.webservices.verification.JwsWebServiceEndpointVerifier.WebMethodIsStaticOrFinal;
import org.junit.Before;
import org.junit.Test;
/**
* @author sfcoy
*
*/
public class JwsWebServiceEndpointVerifierTestCase {
private DeploymentReflectionIndex deploymentReflectionIndex;
@Before
public void setup() {
deploymentReflectionIndex = DeploymentReflectionIndex.create();
}
@Test
public void testVerifySucceeds() throws DeploymentUnitProcessingException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(GoodSampleWSImpl.class, SampleWS.class,
deploymentReflectionIndex);
sut.verify();
assertFalse(sut.failed());
}
@Test
public void testVerifySimpleWSSucceeds() throws DeploymentUnitProcessingException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(SimpleWSImpl.class, null,
deploymentReflectionIndex);
sut.verify();
assertFalse(sut.failed());
}
@Test
public void testVerifyAnnotatedSampleWSSucceeds() throws DeploymentUnitProcessingException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(AnnotatedSampleWSImpl.class, SampleWS.class,
deploymentReflectionIndex);
sut.verify();
assertFalse(sut.failed());
}
@Test
public void testVerifyAnnotatedSampleWSWithExclusionSucceeds() throws DeploymentUnitProcessingException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(AnnotatedSampleWSImplWithExclusion.class, null,
deploymentReflectionIndex);
sut.verify();
assertFalse(sut.failed());
}
@Test
public void testVerifyExtendedSampleWSSucceeds() throws DeploymentUnitProcessingException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(ConcreteSampleWSImpl.class, null,
deploymentReflectionIndex);
sut.verify();
assertFalse(sut.failed());
}
@Test
public void testVerifyFails() throws DeploymentUnitProcessingException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(BrokenSampleWSImpl.class, SampleWS.class,
deploymentReflectionIndex);
sut.verify();
assertTrue(sut.failed());
assertEquals(5, sut.verificationFailures.size());
}
@Test
public void testLogFailures() throws DeploymentUnitProcessingException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(BrokenSampleWSImpl.class, SampleWS.class,
deploymentReflectionIndex);
sut.verify();
sut.logFailures();
}
@Test
public void testVerifyWebMethodSucceeds() throws NoSuchMethodException, SecurityException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(GoodSampleWSImpl.class, SampleWS.class,
deploymentReflectionIndex);
sut.verifyWebMethod(SampleWS.class.getMethod("performWork"));
assertFalse(sut.failed());
assertEquals(0, sut.verificationFailures.size());
}
@Test
public void testVerifyNonPublicWebMethodFails() throws NoSuchMethodException, SecurityException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(BrokenSampleWSImpl.class, SampleWS.class,
deploymentReflectionIndex);
sut.verifyWebMethod(SampleWS.class.getMethod("performWork"));
assertTrue(sut.failed());
assertEquals(1, sut.verificationFailures.size());
assertTrue(sut.verificationFailures.get(0) instanceof WebMethodIsNotPublic);
}
@Test
public void testVerifyStaticWebMethodFails() throws NoSuchMethodException, SecurityException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(BrokenSampleWSImpl.class, SampleWS.class,
deploymentReflectionIndex);
sut.verifyWebMethod(SampleWS.class.getMethod("discoverNewLands"));
assertTrue(sut.failed());
assertEquals(1, sut.verificationFailures.size());
assertTrue(sut.verificationFailures.get(0) instanceof WebMethodIsStaticOrFinal);
}
@Test
public void testVerifyFinalWebMethodFails() throws NoSuchMethodException, SecurityException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(BrokenSampleWSImpl.class, SampleWS.class,
deploymentReflectionIndex);
sut.verifyWebMethod(SampleWS.class.getMethod("triggerReport"));
assertTrue(sut.failed());
assertEquals(1, sut.verificationFailures.size());
assertTrue(sut.verificationFailures.get(0) instanceof WebMethodIsStaticOrFinal);
}
@Test
public void testVerifyFinalizeMethod() {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(BrokenSampleWSImpl.class, SampleWS.class,
deploymentReflectionIndex);
sut.verifyFinalizeMethod();
assertTrue(sut.failed());
assertEquals(1, sut.verificationFailures.size());
assertTrue(sut.verificationFailures.get(0) instanceof ImplementationHasFinalize);
}
@Test
public void testLoadEndpointInterfaceDefinedWebMethods() throws DeploymentUnitProcessingException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(GoodSampleWSImpl.class, SampleWS.class,
deploymentReflectionIndex);
Collection<Method> endpointInterfaceMethods = sut.endpointInterfaceDefinedWebMethods();
Set<String> methodNames = new HashSet<>();
for (Method endpointInterfaceMethod : endpointInterfaceMethods)
methodNames.add(endpointInterfaceMethod.getName());
assertTrue(methodNames.contains("performWork"));
assertTrue(methodNames.contains("discoverNewLands"));
assertTrue(methodNames.contains("isWorking"));
assertTrue(methodNames.contains("triggerReport"));
}
@Test
public void testFindEndpointImplMethodMatching() throws NoSuchMethodException, SecurityException {
JwsWebServiceEndpointVerifier sut = new JwsWebServiceEndpointVerifier(GoodSampleWSImpl.class, SampleWS.class,
deploymentReflectionIndex);
Method endpointInterfaceMethod = SampleWS.class.getMethod("performWork");
Method seiMethod = sut.findEndpointImplMethodMatching(endpointInterfaceMethod);
assertNotNull(seiMethod);
assertEquals("performWork", seiMethod.getName());
}
}
| 8,269 | 43.462366 | 125 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/verification/ConcreteSampleWSImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.verification;
import jakarta.jws.WebService;
/**
* @author sfcoy
*
*/
@WebService(portName = "sample-ws-port", wsdlLocation = "/META-INF/wsdl/sample.wsdl", endpointInterface = "org.jboss.as.webservices.verification.SampleWS")
public class ConcreteSampleWSImpl extends AbstractSampleWSImpl implements SampleWS {
@Override
public String discoverNewLands() {
return null;
}
@Override
public boolean isWorking() {
return false;
}
@Override
public void triggerReport() {
}
}
| 1,587 | 32.083333 | 155 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/verification/GoodSampleWSImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.verification;
import jakarta.jws.WebService;
/**
* @author sfcoy
*
*/
@WebService(portName = "sample-ws-port", wsdlLocation = "/META-INF/wsdl/sample.wsdl", endpointInterface = "org.jboss.as.webservices.verification.SampleWS")
public class GoodSampleWSImpl {
public void performWork() {
}
public String discoverNewLands() {
return "Wallaby Hill";
}
public boolean isWorking() {
return true;
}
public void triggerReport() {
}
}
| 1,540 | 31.104167 | 155 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/verification/SampleWS.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.verification;
import jakarta.jws.WebService;
/**
* @author sfcoy
*
*/
@WebService(name="SampleWS", targetNamespace="urn:sample")
public interface SampleWS {
void performWork();
String discoverNewLands();
boolean isWorking();
void triggerReport();
}
| 1,332 | 30 | 70 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/verification/AnnotatedSampleWSImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.verification;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
/**
* @author sfcoy
*
*/
@WebService
public class AnnotatedSampleWSImpl implements SampleWS {
@Override
@WebMethod
public void performWork() {
}
@Override
@WebMethod
public String discoverNewLands() {
return null;
}
@Override
@WebMethod
public boolean isWorking() {
return false;
}
@Override
@WebMethod
public void triggerReport() {
}
}
| 1,560 | 25.457627 | 70 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/dmr/WebservicesSubsystemRuntimeTestCase.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.dmr;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.jboss.as.controller.RunningMode;
import org.jboss.as.server.Services;
import org.jboss.as.server.moduleservice.ServiceModuleLoader;
import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest;
import org.jboss.as.subsystem.test.AdditionalInitialization;
import org.jboss.as.subsystem.test.KernelServices;
import org.jboss.as.subsystem.test.KernelServicesBuilder;
import org.jboss.as.webservices.config.ServerConfigFactoryImpl;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.spi.metadata.config.ClientConfig;
import org.jboss.wsf.spi.metadata.config.EndpointConfig;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
/**
* A test for checking the services that are created by the subsystem after boot.
*
* @author <a href="mailto:[email protected]>Alessio Soldano</a>
* @author <a href="mailto:[email protected]>Richard Opalka</a>
*/
public class WebservicesSubsystemRuntimeTestCase extends AbstractSubsystemBaseTest {
public WebservicesSubsystemRuntimeTestCase() {
super(WSExtension.SUBSYSTEM_NAME, new WSExtension());
}
@Override
protected String getSubsystemXml() throws IOException {
return readResource("ws-subsystem20-rt.xml");
}
protected AdditionalInitialization createAdditionalInitialization() {
return new AdditionalInitialization() {
@Override
protected RunningMode getRunningMode() {
return RunningMode.NORMAL;
}
@Override
protected void addExtraServices(ServiceTarget target) {
super.addExtraServices(target);
target.addService(Services.JBOSS_SERVICE_MODULE_LOADER).setInstance(new ServiceModuleLoader(null)).install();
}
};
}
@AfterClass
public static void resetClassLoaderProvider() {
//HACK: another hack required because we're not running in a valid modular environment, hence at the of the test
//the WS ClassLoaderProvider is still configured to use a ModularClassLoaderProvider backed by the fake
//module loader installed by this testcase. As a consequence other tests running after this might fail.
//The issue can be prevented in various ways, but given this whole test is a hack as we're not running in a
//proper environment, I prefer to do as below for now (after all, this is a testsuite issue only, WFLY-4122)
ClassLoaderProvider.setDefaultProvider(new ClassLoaderProvider() {
@Override
public ClassLoader getWebServiceSubsystemClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
@Override
public ClassLoader getServerJAXRPCIntegrationClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
@Override
public ClassLoader getServerIntegrationClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
});
}
@Test
public void testSubsystem() throws Exception {
KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(getSubsystemXml());
KernelServices mainServices = builder.build();
if (!mainServices.isSuccessfulBoot()) {
Assert.fail(mainServices.getBootError().toString());
}
//WSDL soap:address rewrite engine options test
ServerConfig serverConfig = ServerConfigFactoryImpl.getConfig();
Assert.assertTrue(serverConfig.isModifySOAPAddress());
Assert.assertEquals("localhost", serverConfig.getWebServiceHost());
Assert.assertEquals(9895, serverConfig.getWebServicePort());
Assert.assertEquals(9944, serverConfig.getWebServiceSecurePort());
Assert.assertEquals("https", serverConfig.getWebServiceUriScheme());
//Client & Endpoint predefined configuration tests
//HACK: we need to manually reload the client/endpoint configs as the ServerConfigService is actually not starting in this test;
//the reason is that it requires services which are not installed here and even if those were available it would fail to start
//because we're not running in a modular environment and hence it won't be able to detect the proper ws stack implementation.
//Even if we made the subsystem work with a flat classloader (which would not make sense except for the tests here), we'd have
//to deal a hell of ws specific maven dependencies here... so really not worth the effort.
serverConfig.reloadClientConfigs();
ClientConfig clCfg = serverConfig.getClientConfig("My-Client-Config");
Assert.assertNotNull(clCfg);
Assert.assertEquals(1, clCfg.getProperties().size());
Assert.assertEquals("bar3", clCfg.getProperties().get("foo3"));
Assert.assertEquals(2, clCfg.getPreHandlerChains().size());
Map<String, UnifiedHandlerChainMetaData> map = new HashMap<String, UnifiedHandlerChainMetaData>();
for (UnifiedHandlerChainMetaData uhc : clCfg.getPreHandlerChains()) {
map.put(uhc.getId(), uhc);
}
Assert.assertTrue(map.get("my-handlers").getHandlers().isEmpty());
Assert.assertEquals("##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM", map.get("my-handlers").getProtocolBindings());
Assert.assertEquals(1, map.get("my-handlers2").getHandlers().size());
Assert.assertEquals("MyHandler", map.get("my-handlers2").getHandlers().get(0).getHandlerName());
Assert.assertEquals("org.jboss.ws.common.invocation.MyHandler", map.get("my-handlers2").getHandlers().get(0).getHandlerClass());
Assert.assertEquals("##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM", map.get("my-handlers").getProtocolBindings());
Assert.assertEquals(1, clCfg.getPostHandlerChains().size());
Assert.assertEquals("my-handlers2", clCfg.getPostHandlerChains().get(0).getId());
Assert.assertEquals(1, clCfg.getPostHandlerChains().get(0).getHandlers().size());
Assert.assertEquals("MyHandler2", clCfg.getPostHandlerChains().get(0).getHandlers().get(0).getHandlerName());
Assert.assertEquals("org.jboss.ws.common.invocation.MyHandler2", clCfg.getPostHandlerChains().get(0).getHandlers().get(0).getHandlerClass());
Assert.assertEquals("##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM", clCfg.getPostHandlerChains().get(0).getProtocolBindings());
serverConfig.reloadEndpointConfigs();
EndpointConfig epCfg = serverConfig.getEndpointConfig("Standard-Endpoint-Config");
Assert.assertNotNull(epCfg);
Assert.assertTrue(epCfg.getProperties().isEmpty());
Assert.assertTrue(epCfg.getPreHandlerChains().isEmpty());
Assert.assertTrue(epCfg.getPostHandlerChains().isEmpty());
epCfg = serverConfig.getEndpointConfig("Recording-Endpoint-Config");
Assert.assertNotNull(epCfg);
Assert.assertEquals(2, epCfg.getProperties().size());
Assert.assertEquals("bar", epCfg.getProperties().get("foo"));
Assert.assertEquals("bar2", epCfg.getProperties().get("foo2"));
Assert.assertEquals(1, epCfg.getPreHandlerChains().size());
Assert.assertEquals("recording-handlers", epCfg.getPreHandlerChains().get(0).getId());
Assert.assertEquals(2, epCfg.getPreHandlerChains().get(0).getHandlers().size());
Assert.assertEquals("RecordingHandler", epCfg.getPreHandlerChains().get(0).getHandlers().get(0).getHandlerName());
Assert.assertEquals("org.jboss.ws.common.invocation.RecordingServerHandler", epCfg.getPreHandlerChains().get(0).getHandlers().get(0).getHandlerClass());
Assert.assertEquals("AnotherRecordingHandler", epCfg.getPreHandlerChains().get(0).getHandlers().get(1).getHandlerName());
Assert.assertEquals("org.jboss.ws.common.invocation.RecordingServerHandler", epCfg.getPreHandlerChains().get(0).getHandlers().get(1).getHandlerClass());
Assert.assertEquals("##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM", epCfg.getPreHandlerChains().get(0).getProtocolBindings());
Assert.assertEquals(1, epCfg.getPostHandlerChains().size());
Assert.assertEquals("recording-handlers2", epCfg.getPostHandlerChains().get(0).getId());
Assert.assertEquals(2, epCfg.getPostHandlerChains().get(0).getHandlers().size());
Assert.assertEquals("RecordingHandler2", epCfg.getPostHandlerChains().get(0).getHandlers().get(0).getHandlerName());
Assert.assertEquals("org.jboss.ws.common.invocation.RecordingServerHandler", epCfg.getPostHandlerChains().get(0).getHandlers().get(0).getHandlerClass());
Assert.assertEquals("AnotherRecordingHandler2", epCfg.getPostHandlerChains().get(0).getHandlers().get(1).getHandlerName());
Assert.assertEquals("org.jboss.ws.common.invocation.RecordingServerHandler", epCfg.getPostHandlerChains().get(0).getHandlers().get(1).getHandlerClass());
Assert.assertEquals("##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM", epCfg.getPostHandlerChains().get(0).getProtocolBindings());
}
}
| 10,596 | 58.533708 | 161 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/dmr/WebservicesSubsystemParserTestCase.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.dmr;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.List;
import org.jboss.as.controller.ExpressionResolver;
import org.jboss.as.controller.RunningMode;
import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest;
import org.jboss.as.subsystem.test.AdditionalInitialization;
import org.jboss.as.subsystem.test.KernelServices;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.junit.Test;
/**
* Checks the current parser can parse any webservices subsystem version of the model
*
* @author <a href="mailto:[email protected]>Jim Ma</a>
* @author <a href="mailto:[email protected]>Alessio Soldano</a>
*/
public class WebservicesSubsystemParserTestCase extends AbstractSubsystemBaseTest {
public WebservicesSubsystemParserTestCase() {
super(WSExtension.SUBSYSTEM_NAME, new WSExtension());
}
@Override
protected String getSubsystemXml() throws IOException {
return readResource("ws-subsystem20.xml"); //for default test
}
@Override
protected String getSubsystemXsdPath() throws Exception {
return "schema/jboss-as-webservices_2_0.xsd";
}
protected AdditionalInitialization createAdditionalInitialization() {
return new AdditionalInitialization() {
@Override
protected RunningMode getRunningMode() {
return RunningMode.ADMIN_ONLY;
}
};
}
@Override
protected String getSubsystemXml(String configId) throws IOException {
return readResource(configId);
}
@Test
public void testParseV10() throws Exception {
KernelServices services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
.setSubsystemXmlResource("ws-subsystem.xml")
.build();
ModelNode model = services.readWholeModel().get("subsystem", getMainSubsystemName());
standardSubsystemTest("ws-subsystem.xml", false);
checkSubsystemBasics(model);
}
@Test
public void testParseV11() throws Exception {
KernelServices services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
.setSubsystemXmlResource("ws-subsystem11.xml")
.build();
ModelNode model = services.readWholeModel().get("subsystem", getMainSubsystemName());
standardSubsystemTest("ws-subsystem11.xml", false);
checkSubsystemBasics(model);
checkEndpointConfigs(model);
}
@Test
public void testParseV12() throws Exception {
KernelServices services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
.setSubsystemXmlResource("ws-subsystem12.xml")
.build();
ModelNode model = services.readWholeModel().get("subsystem", getMainSubsystemName());
standardSubsystemTest("ws-subsystem12.xml", false);
checkSubsystemBasics(model);
checkEndpointConfigs(model);
checkClientConfigs(model);
}
@Test
public void testParseV20() throws Exception {
// no need to do extra standardSubsystemTest("ws-subsystem20.xml") as that is default!
KernelServices services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
.setSubsystemXmlResource("ws-subsystem20.xml")
.build();
ModelNode model = services.readWholeModel().get("subsystem", getMainSubsystemName());
checkSubsystemBasics(model);
checkEndpointConfigs(model);
checkClientConfigs(model);
checkExtraCongfigs(model);
}
private void checkSubsystemBasics(ModelNode model) throws Exception {
assertEquals(9090, Attributes.WSDL_PORT.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, model).asInt());
assertEquals(9443, Attributes.WSDL_SECURE_PORT.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, model).asInt());
assertEquals("localhost", Attributes.WSDL_HOST.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, model).asString());
assertTrue(Attributes.MODIFY_WSDL_ADDRESS.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, model).asBoolean());
assertFalse(Attributes.STATISTICS_ENABLED.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, model).asBoolean());
}
private void checkEndpointConfigs(ModelNode model) throws Exception {
List<Property> endpoints = model.get(Constants.ENDPOINT_CONFIG).asPropertyList();
assertEquals("Standard-Endpoint-Config", endpoints.get(0).getName());
assertEquals("Recording-Endpoint-Config", endpoints.get(1).getName());
ModelNode recordingEndpoint = endpoints.get(1).getValue();
assertEquals("bar", Attributes.VALUE.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, recordingEndpoint.get(Constants.PROPERTY).get("foo")).asString());
List<Property> chain = recordingEndpoint.get(Constants.PRE_HANDLER_CHAIN).asPropertyList();
assertEquals("recording-handlers", chain.get(0).getName());
ModelNode recordingHandler = chain.get(0).getValue();
assertEquals("##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM", Attributes.PROTOCOL_BINDINGS.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, recordingHandler).asString());
assertEquals("org.jboss.ws.common.invocation.RecordingServerHandler", recordingHandler.get(Constants.HANDLER, "RecordingHandler", Constants.CLASS).asString());
}
private void checkClientConfigs(ModelNode model) throws Exception {
List<Property> clientConfigs = model.get(Constants.CLIENT_CONFIG).asPropertyList();
assertEquals("My-Client-Config", clientConfigs.get(0).getName());
List<Property> preHandlers = clientConfigs.get(0).getValue().get(Constants.PRE_HANDLER_CHAIN).asPropertyList();
List<Property> postHandlers = clientConfigs.get(0).getValue().get(Constants.POST_HANDLER_CHAIN).asPropertyList();
assertEquals("my-handlers", preHandlers.get(0).getName());
assertEquals("org.jboss.ws.common.invocation.MyHandler", preHandlers.get(1).getValue().get(Constants.HANDLER).asPropertyList().get(0).getValue().get(Constants.CLASS).asString());
assertEquals("my-handlers2", postHandlers.get(0).getName());
}
private void checkExtraCongfigs(ModelNode model) throws Exception {
assertEquals("https", Attributes.WSDL_URI_SCHEME.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, model).asString());
}
}
| 7,676 | 47.283019 | 205 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/parser/TestDA1.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.parser;
import java.util.Set;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
public class TestDA1 implements DeploymentAspect {
@Override
public void setLast(boolean isLast) {
}
@Override
public boolean isLast() {
return false;
}
@Override
public String getProvides() {
return null;
}
@Override
public void setProvides(String provides) {
}
@Override
public String getRequires() {
return null;
}
@Override
public void setRequires(String requires) {
}
@Override
public void setRelativeOrder(int relativeOrder) {
}
@Override
public int getRelativeOrder() {
return 0;
}
@Override
public void start(Deployment dep) {
}
@Override
public void stop(Deployment dep) {
}
@Override
public Set<String> getProvidesAsSet() {
return null;
}
@Override
public Set<String> getRequiresAsSet() {
return null;
}
@Override
public ClassLoader getLoader() {
return null;
}
}
| 2,206 | 21.752577 | 70 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/parser/TestDA2.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.parser;
public class TestDA2 extends TestDA1 {
private String two;
public String getTwo() {
return two;
}
public void setTwo(String two) {
this.two = two;
}
}
| 1,263 | 35.114286 | 70 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/parser/TestDA4.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.parser;
import java.util.Map;
public class TestDA4 extends TestDA1 {
private Map<String, Integer> map;
private boolean bool;
public Map<String, Integer> getMap() {
return map;
}
public void setMap(Map<String, Integer> map) {
this.map = map;
}
public boolean isBool() {
return bool;
}
public void setBool(Boolean bool) {
this.bool = bool;
}
} | 1,484 | 32 | 70 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/parser/TestDA3.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.parser;
import java.util.List;
public class TestDA3 extends TestDA1 {
private List<String> list;
public List<String> getList() {
return list;
}
public void setList(List<String> list) {
this.list = list;
}
}
| 1,312 | 34.486486 | 70 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/parser/WSDeploymentAspectParserTestCase.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
import org.junit.Test;
/**
* @author [email protected]
* @since 18-Jan-2011
*/
public class WSDeploymentAspectParserTestCase {
@Test
public void test() throws Exception {
InputStream is = getXmlUrl("jbossws-deployment-aspects-example.xml").openStream();
try {
List<DeploymentAspect> das = WSDeploymentAspectParser.parse(is, this.getClass().getClassLoader());
assertEquals(4, das.size());
boolean da1Found = false;
boolean da2Found = false;
boolean da3Found = false;
boolean da4Found = false;
for (DeploymentAspect da : das) {
if (da instanceof TestDA2) {
da2Found = true;
TestDA2 da2 = (TestDA2) da;
assertEquals("myString", da2.getTwo());
} else if (da instanceof TestDA3) {
da3Found = true;
TestDA3 da3 = (TestDA3) da;
assertNotNull(da3.getList());
assertTrue(da3.getList().contains("One"));
assertTrue(da3.getList().contains("Two"));
} else if (da instanceof TestDA4) {
da4Found = true;
TestDA4 da4 = (TestDA4) da;
assertEquals(true, da4.isBool());
assertNotNull(da4.getMap());
assertEquals(1, (int) da4.getMap().get("One"));
assertEquals(3, (int) da4.getMap().get("Three"));
} else if (da instanceof TestDA1) {
da1Found = true;
}
}
assertTrue(da1Found);
assertTrue(da2Found);
assertTrue(da3Found);
assertTrue(da4Found);
} finally {
if (is != null) {
is.close();
}
}
}
URL getXmlUrl(String xmlName) {
return getResourceUrl("parser/" + xmlName);
}
URL getResourceUrl(String resourceName) {
URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
assertNotNull("URL not null for: " + resourceName, url);
return url;
}
}
| 3,556 | 36.840426 | 110 | java |
null | wildfly-main/webservices/server-integration/src/test/java/org/jboss/as/webservices/deployers/WSClassVerificationProcessorTestCase.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2020, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.deployers;
import org.jboss.as.server.deployment.AttachmentList;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.module.ModuleDependency;
import org.jboss.as.server.deployment.module.ModuleSpecification;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
public class WSClassVerificationProcessorTestCase {
private final DeploymentUnit unit = Mockito.mock(DeploymentUnit.class);
private final DeploymentUnit rootUnit = Mockito.mock(DeploymentUnit.class);
private final DeploymentUnit siblingUnit = Mockito.mock(DeploymentUnit.class);
private final ModuleSpecification spec = new ModuleSpecification();
private final ModuleSpecification rootSpec = new ModuleSpecification();
private final ModuleSpecification siblingSpec = new ModuleSpecification();
@Before
public void setup() {
Mockito.when(unit.getName()).thenReturn("sample.jar");
Mockito.when(unit.getParent()).thenReturn(rootUnit);
Mockito.when(unit.getAttachment(Attachments.MODULE_SPECIFICATION)).thenReturn(spec);
Mockito.when(siblingUnit.getName()).thenReturn("sample-sibling.jar");
Mockito.when(siblingUnit.getParent()).thenReturn(rootUnit);
Mockito.when(siblingUnit.getAttachment(Attachments.MODULE_SPECIFICATION)).thenReturn(siblingSpec);
AttachmentList<DeploymentUnit> subdeployments = new AttachmentList<>(DeploymentUnit.class);
subdeployments.add(unit);
subdeployments.add(siblingUnit);
Mockito.when(rootUnit.getName()).thenReturn("sample.ear");
Mockito.when(rootUnit.getParent()).thenReturn(null);
Mockito.when(rootUnit.getAttachment(Attachments.MODULE_SPECIFICATION)).thenReturn(rootSpec);
Mockito.when(rootUnit.getAttachment(Attachments.SUB_DEPLOYMENTS)).thenReturn(subdeployments);
}
@Test
public void testCxfModuleDependencyPresent() {
spec.addUserDependency(new ModuleDependency(null, "org.apache.cxf", false, false, false, false));
Assert.assertTrue(WSClassVerificationProcessor.hasCxfModuleDependency(unit));
}
@Test
public void testRootExportedCxfModuleDependencyPresent() {
rootSpec.addUserDependency(new ModuleDependency(null, "org.apache.cxf", false, true, false, false));
Assert.assertTrue(WSClassVerificationProcessor.hasCxfModuleDependency(unit));
}
@Test
public void testRootNonExportedCxfModuleDependencyPresent() {
rootSpec.addUserDependency(new ModuleDependency(null, "org.apache.cxf", false, false, false, false));
Assert.assertFalse(WSClassVerificationProcessor.hasCxfModuleDependency(unit)); // parent dep not exported, should return false
}
@Test
public void testSiblingExportedCxfModuleDependencyPresent() {
setSubDeploymentsIsolated(false);
siblingSpec.addUserDependency(new ModuleDependency(null, "org.apache.cxf", false, true, false, false));
Assert.assertTrue(WSClassVerificationProcessor.hasCxfModuleDependency(unit));
}
@Test
public void testSiblingNonExportedCxfModuleDependencyPresent() {
setSubDeploymentsIsolated(false);
siblingSpec.addUserDependency(new ModuleDependency(null, "org.apache.cxf", false, false, false, false));
Assert.assertFalse(WSClassVerificationProcessor.hasCxfModuleDependency(unit)); // parent dep not exported, should return false
}
@Test
public void testSiblingCxfModuleDependencyPresentIsolatedDeploymentsTrue() {
setSubDeploymentsIsolated(true);
siblingSpec.addUserDependency(new ModuleDependency(null, "org.apache.cxf", false, true, false, false));
Assert.assertFalse(WSClassVerificationProcessor.hasCxfModuleDependency(unit));
}
@Test
public void testCxfModuleDependencyMissing() {
Assert.assertFalse(WSClassVerificationProcessor.hasCxfModuleDependency(unit));
}
private void setSubDeploymentsIsolated(boolean value) {
rootSpec.setSubDeploymentModulesIsolated(value);
}
}
| 5,189 | 42.983051 | 134 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/security/EJBMethodSecurityAttributesAdaptor.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.security;
import java.lang.reflect.Method;
import java.util.Set;
import org.jboss.as.ejb3.security.service.EJBViewMethodSecurityAttributesService;
import org.jboss.wsf.spi.security.EJBMethodSecurityAttribute;
/**
* Adaptor of Enterprise Beans 3 EJBViewMethodSecurityAttributesService to JBossWS SPI EJBMethodSecurityAttributeProvider
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
*
*/
public class EJBMethodSecurityAttributesAdaptor implements org.jboss.wsf.spi.security.EJBMethodSecurityAttributeProvider {
private final EJBViewMethodSecurityAttributesService attributeService;
public EJBMethodSecurityAttributesAdaptor(EJBViewMethodSecurityAttributesService attributeService) {
this.attributeService = attributeService;
}
@Override
public EJBMethodSecurityAttribute getSecurityAttributes(final Method viewMethod) {
if (attributeService == null) {
return null;
}
final org.jboss.as.ejb3.security.EJBMethodSecurityAttribute att = attributeService.getSecurityAttributes(viewMethod);
return att == null ? null : new org.jboss.wsf.spi.security.EJBMethodSecurityAttribute() {
@Override
public boolean isPermitAll() {
return att.isPermitAll();
}
@Override
public boolean isDenyAll() {
return att.isDenyAll();
}
@Override
public Set<String> getRolesAllowed() {
return att.getRolesAllowed();
}
};
}
}
| 2,633 | 37.173913 | 125 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/security/ElytronSecurityDomainContextImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.security;
import java.security.AccessController;
import java.security.Principal;
import java.security.PrivilegedAction;
import java.util.Set;
import java.util.concurrent.Callable;
import javax.security.auth.Subject;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.util.SubjectUtil;
import org.jboss.wsf.spi.security.SecurityDomainContext;
import org.wildfly.security.auth.server.RealmUnavailableException;
import org.wildfly.security.auth.server.SecurityDomain;
import org.wildfly.security.auth.server.SecurityIdentity;
import org.wildfly.security.auth.server.ServerAuthenticationContext;
import org.wildfly.security.evidence.PasswordGuessEvidence;
public class ElytronSecurityDomainContextImpl implements SecurityDomainContext {
private final SecurityDomain securityDomain;
private final ThreadLocal<SecurityIdentity> currentIdentity = new ThreadLocal<SecurityIdentity>();
public ElytronSecurityDomainContextImpl(SecurityDomain securityDomain) {
this.securityDomain = securityDomain;
}
//TODO:deprecate this after elytron
@Override
public boolean doesUserHaveRole(Principal principal, Set<Principal> principals) {
return true;
}
//TODO:refactor/deprecate this after elytron
@Override
public String getSecurityDomain() {
return this.securityDomain.toString();
}
@Override
public SecurityDomain getElytronSecurityDomain() {
return this.securityDomain;
}
//TODO:refactor/deprecate this after elytron?
@Override
public Set<Principal> getUserRoles(Principal principal) {
return null;
}
@Override
public boolean isValid(Principal principal, Object password, Subject subject) {
if (subject == null) {
subject = new Subject();
}
String username = principal.getName();
if (!(password instanceof String)) {
throw new java.lang.IllegalArgumentException("only string password accepted");
}
SecurityIdentity identity = authenticate(username, (String) password);
if (identity == null) {
return false;
}
this.currentIdentity.set(identity);
SubjectUtil.fromSecurityIdentity(identity, subject);
return true;
}
public void runAs(Callable<Void> action) throws Exception {
final SecurityIdentity ci = currentIdentity.get();
if (ci != null) {
//there is no security constrains in servlet and directly with jaas
try {
ci.runAs(action);
} finally {
currentIdentity.remove();
}
} else {
//undertow's ElytronRunAsHandler will propagate the SecurityIndentity to SecurityDomain and directly run this action
action.call();
}
}
@Override
public void pushSubjectContext(Subject subject, Principal pincipal, Object credential) {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
if (credential != null) {
subject.getPrivateCredentials().add(credential);
}
SecurityIdentity securityIdentity = SubjectUtil.convertToSecurityIdentity(subject, pincipal, securityDomain,
"ejb");
currentIdentity.set(securityIdentity);
return null;
}
});
}
private SecurityIdentity authenticate(final String username, final String password) {
ServerAuthenticationContext context = this.securityDomain.createNewAuthenticationContext();
PasswordGuessEvidence evidence = new PasswordGuessEvidence(password != null ? password.toCharArray() : null);
try {
context.setAuthenticationName(username);
if (context.verifyEvidence(evidence)) {
if (context.authorize()) {
context.succeed();
return context.getAuthorizedIdentity();
} else {
context.fail();
WSLogger.ROOT_LOGGER.failedAuthorization(username);
}
} else {
context.fail();
WSLogger.ROOT_LOGGER.failedAuthentication(username);
}
} catch (IllegalArgumentException | IllegalStateException | RealmUnavailableException e) {
context.fail();
WSLogger.ROOT_LOGGER.failedAuthenticationWithException(e, username, e.getMessage());
} finally {
if (!context.isDone()) context.fail(); //prevent leaks of RealmIdentity instances
evidence.destroy();
}
return null;
}
@Override
public void cleanupSubjectContext() {
currentIdentity.remove();
}
}
| 5,881 | 37.444444 | 128 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/service/PropertyService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.service;
import org.jboss.msc.Service;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StopContext;
import java.util.function.Consumer;
/**
* A service for getting a property to be stored in endpoint / client config.
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class PropertyService implements Service {
private final String propName;
private final String propValue;
private final Consumer<PropertyService> propertyServiceConsumer;
public PropertyService(final String propName, final String propValue, final Consumer<PropertyService> propertyServiceConsumer) {
this.propValue = propValue;
this.propName = propName;
this.propertyServiceConsumer = propertyServiceConsumer;
}
public String getPropName() {
return propName;
}
public String getPropValue() {
return propValue;
}
@Override
public void start(final StartContext context) {
propertyServiceConsumer.accept(this);
}
@Override
public void stop(final StopContext context) {
propertyServiceConsumer.accept(null);
}
}
| 2,292 | 33.223881 | 132 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointPublishService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.service;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.web.host.WebHost;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.publish.EndpointPublisherHelper;
import org.jboss.as.webservices.util.WSServices;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.msc.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
import org.jboss.wsf.spi.publish.Context;
/**
* WS endpoint publish service, allows for publishing a WS endpoint on AS 7
*
* @author [email protected]
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class EndpointPublishService implements Service {
private final ServiceName name;
private volatile Context wsctx;
private final DeploymentUnit deploymentUnit;
private final Consumer<Context> wsctxConsumer;
private final Supplier<WebHost> hostSupplier;
private EndpointPublishService(final ServiceName name, final DeploymentUnit deploymentUnit,
final Consumer<Context> wsctxConsumer, final Supplier<WebHost> hostSupplier) {
this.name = name;
this.deploymentUnit = deploymentUnit;
this.wsctxConsumer = wsctxConsumer;
this.hostSupplier = hostSupplier;
}
@Override
public void start(final StartContext ctx) throws StartException {
WSLogger.ROOT_LOGGER.starting(name);
try {
wsctxConsumer.accept(wsctx = EndpointPublisherHelper.doPublishStep(hostSupplier.get(), ctx.getChildTarget(), deploymentUnit));
} catch (Exception e) {
throw new StartException(e);
}
}
@Override
public void stop(final StopContext ctx) {
WSLogger.ROOT_LOGGER.stopping(name);
wsctxConsumer.accept(null);
List<Endpoint> eps = wsctx.getEndpoints();
if (eps == null || eps.isEmpty()) {
return;
}
try {
EndpointPublisherHelper.undoPublishStep(hostSupplier.get(), wsctx);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
static ServiceBuilder createServiceBuilder(final ServiceTarget serviceTarget, final String context,
final ClassLoader loader, final String hostName, final Map<String, String> urlPatternToClassName,
JBossWebMetaData jbwmd, WebservicesMetaData wsmd, JBossWebservicesMetaData jbwsmd) {
return createServiceBuilder(serviceTarget, context, loader, hostName, urlPatternToClassName, jbwmd, wsmd, jbwsmd, null, null);
}
public static ServiceBuilder createServiceBuilder(final ServiceTarget serviceTarget, final String context,
final ClassLoader loader, final String hostName, final Map<String, String> urlPatternToClassName,
JBossWebMetaData jbwmd, WebservicesMetaData wsmd, JBossWebservicesMetaData jbwsmd, Map<Class<?>, Object> deploymentAttachments,
CapabilityServiceSupport capabilityServiceSupport) {
final DeploymentUnit unit = EndpointDeployService.install(serviceTarget, context, loader, hostName, urlPatternToClassName, jbwmd, wsmd,
jbwsmd, deploymentAttachments, capabilityServiceSupport);
final ServiceName serviceName = WSServices.ENDPOINT_PUBLISH_SERVICE.append(context);
final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
builder.requires(WSServices.CONFIG_SERVICE);
for (ServiceName epServiceName : EndpointService.getServiceNamesFromDeploymentUnit(unit)) {
builder.requires(epServiceName);
}
final Consumer<Context> contextConsumer = builder.provides(serviceName);
final Supplier<WebHost> hostSupplier = builder.requires(WebHost.SERVICE_NAME.append(hostName));
builder.setInstance(new EndpointPublishService(serviceName, unit, contextConsumer, hostSupplier));
return builder;
}
public static void install(final ServiceTarget serviceTarget, final String context, final ClassLoader loader,
final String hostName, final Map<String,String> urlPatternToClassName) {
install(serviceTarget, context, loader, hostName, urlPatternToClassName, null, null, null);
}
public static void install(final ServiceTarget serviceTarget, final String context, final ClassLoader loader,
final String hostName, final Map<String,String> urlPatternToClassName, JBossWebMetaData jbwmd, WebservicesMetaData wsmd, JBossWebservicesMetaData jbwsmd) {
ServiceBuilder builder = createServiceBuilder(serviceTarget, context, loader, hostName, urlPatternToClassName, jbwmd, wsmd, jbwsmd);
builder.install();
}
}
| 6,374 | 47.664122 | 167 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/service/XTSClientIntegrationService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.service;
import java.util.List;
import java.util.ArrayList;
import java.util.function.Supplier;
import org.jboss.as.webservices.config.ServerConfigImpl;
import org.jboss.as.webservices.util.WSServices;
import org.jboss.msc.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StopContext;
import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.spi.metadata.config.ClientConfig;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
/**
* A service for triggering the XTS client config integration
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class XTSClientIntegrationService implements Service {
private final Supplier<ServerConfig> serverConfig;
private final Supplier<UnifiedHandlerChainMetaData> postHandlerChains;
private XTSClientIntegrationService(final Supplier<ServerConfig> serverConfig, final Supplier<UnifiedHandlerChainMetaData> postHandlerChains) {
this.serverConfig = serverConfig;
this.postHandlerChains = postHandlerChains;
}
@Override
public void start(final StartContext context) {
final List<UnifiedHandlerChainMetaData> postHandlerChainsList = new ArrayList<>();
postHandlerChainsList.add(postHandlerChains.get());
ClientConfig wrapper = new ClientConfig(null, null, postHandlerChainsList, null, null);
((ServerConfigImpl)(serverConfig.get())).setClientConfigWrapper(wrapper, true);
}
@Override
public void stop(final StopContext context) {
((ServerConfigImpl)(serverConfig.get())).setClientConfigWrapper(null, false);
}
public static ServiceController<?> install(final ServiceTarget serviceTarget) {
final ServiceBuilder<?> builder = serviceTarget.addService(WSServices.XTS_CLIENT_INTEGRATION_SERVICE);
final Supplier<ServerConfig> serverConfig = builder.requires(WSServices.CONFIG_SERVICE);
final Supplier<UnifiedHandlerChainMetaData> postHandlerChains = builder.requires(ServiceName.JBOSS.append("xts").append("handlers"));
builder.setInstance(new XTSClientIntegrationService(serverConfig, postHandlerChains));
//set passive initial mode, as this has to start only *if* the XTS service above is actually installed and started
return builder.setInitialMode(ServiceController.Mode.PASSIVE).install();
}
}
| 3,708 | 45.3625 | 147 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/service/ConfigService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.jboss.as.webservices.config.ServerConfigFactoryImpl;
import org.jboss.msc.Service;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StopContext;
import org.jboss.wsf.spi.metadata.config.AbstractCommonConfig;
import org.jboss.wsf.spi.metadata.config.ClientConfig;
import org.jboss.wsf.spi.metadata.config.EndpointConfig;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
/**
* A service for setting a ws client / endpoint config.
*
* @author [email protected]
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class ConfigService implements Service {
private final String configName;
private final boolean client;
private volatile AbstractCommonConfig config;
private final Consumer<AbstractCommonConfig> configConsumer;
private final List<Supplier<UnifiedHandlerChainMetaData>> preHandlerChainSuppliers;
private final List<Supplier<UnifiedHandlerChainMetaData>> postHandlerChainSuppliers;
private final List<Supplier<PropertyService>> propertySuppliers;
public ConfigService(final String configName, final boolean client,
final Consumer<AbstractCommonConfig> configConsumer,
final List<Supplier<PropertyService>> propertySuppliers,
final List<Supplier<UnifiedHandlerChainMetaData>> preHandlerChainSuppliers,
final List<Supplier<UnifiedHandlerChainMetaData>> postHandlerChainSuppliers
) {
this.configName = configName;
this.client = client;
this.configConsumer = configConsumer;
this.propertySuppliers = propertySuppliers;
this.preHandlerChainSuppliers = preHandlerChainSuppliers;
this.postHandlerChainSuppliers = postHandlerChainSuppliers;
}
@Override
public void start(final StartContext context) {
Map<String, String> props = null;
if (!propertySuppliers.isEmpty()) {
props = new HashMap<>(propertySuppliers.size(), 1);
for (final Supplier<PropertyService> propertySupplier : propertySuppliers) {
props.put(propertySupplier.get().getPropName(), propertySupplier.get().getPropValue());
}
}
List<UnifiedHandlerChainMetaData> preHandlerChains = new ArrayList<>();
for (final Supplier<UnifiedHandlerChainMetaData> preHandlerChainSupplier : preHandlerChainSuppliers) {
preHandlerChains.add(preHandlerChainSupplier.get());
}
List<UnifiedHandlerChainMetaData> postHandlerChains = new ArrayList<>();
for (final Supplier<UnifiedHandlerChainMetaData> postHandlerChainSupplier : postHandlerChainSuppliers) {
postHandlerChains.add(postHandlerChainSupplier.get());
}
if (client) {
ClientConfig clientConfig = new ClientConfig(configName, preHandlerChains, postHandlerChains, props, null);
ServerConfigFactoryImpl.getConfig().registerClientConfig(clientConfig);
configConsumer.accept(config = clientConfig);
} else {
EndpointConfig endpointConfig = new EndpointConfig(configName, preHandlerChains, postHandlerChains, props, null);
ServerConfigFactoryImpl.getConfig().registerEndpointConfig(endpointConfig);
configConsumer.accept(config = endpointConfig);
}
}
@Override
public void stop(final StopContext context) {
configConsumer.accept(null);
if (client) {
ServerConfigFactoryImpl.getConfig().unregisterClientConfig((ClientConfig)config);
} else {
ServerConfigFactoryImpl.getConfig().unregisterEndpointConfig((EndpointConfig)config);
}
config = null;
}
}
| 5,086 | 45.245455 | 125 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.service;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import javax.management.MBeanServer;
import org.jboss.as.server.ServerEnvironment;
import org.jboss.as.server.ServerEnvironmentService;
import org.jboss.as.webservices.config.ServerConfigImpl;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.util.WSServices;
import org.jboss.msc.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.wsf.spi.management.ServerConfig;
import org.wildfly.extension.undertow.UndertowService;
/**
* WS server config service.
*
* @author <a href="[email protected]">Alessio Soldano</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Jim Ma</a>
*/
public final class ServerConfigService implements Service {
private static final ServiceName MBEAN_SERVER_NAME = ServiceName.JBOSS.append("mbean", "server");
private final ServerConfigImpl serverConfig;
private final Consumer<ServerConfig> serverConfigConsumer;
private final Supplier<MBeanServer> mBeanServerSupplier;
private final Supplier<UndertowService> undertowServiceSupplier;
private final Supplier<ServerEnvironment> serverEnvironmentSupplier;
private ServerConfigService(final ServerConfigImpl serverConfig,
final Consumer<ServerConfig> serverConfigConsumer,
final Supplier<MBeanServer> mBeanServerSupplier,
final Supplier<UndertowService> undertowServiceSupplier,
final Supplier<ServerEnvironment> serverEnvironmentSupplier) {
this.serverConfig = serverConfig;
this.serverConfigConsumer = serverConfigConsumer;
this.mBeanServerSupplier = mBeanServerSupplier;
this.undertowServiceSupplier = undertowServiceSupplier;
this.serverEnvironmentSupplier = serverEnvironmentSupplier;
}
@Override
public void start(final StartContext context) throws StartException {
try {
if (mBeanServerSupplier != null) serverConfig.setMbeanServer(mBeanServerSupplier.get());
if (undertowServiceSupplier != null) serverConfig.setUndertowService(undertowServiceSupplier.get());
serverConfig.setServerEnvironment(serverEnvironmentSupplier.get());
serverConfig.create();
serverConfigConsumer.accept(serverConfig);
} catch (final Exception e) {
WSLogger.ROOT_LOGGER.configServiceCreationFailed();
throw new StartException(e);
}
}
@Override
public void stop(final StopContext context) {
try {
serverConfig.destroy();
if (mBeanServerSupplier != null) serverConfig.setMbeanServer(null);
if (undertowServiceSupplier != null) serverConfig.setUndertowService(null);
} catch (final Exception e) {
WSLogger.ROOT_LOGGER.configServiceDestroyFailed();
}
}
public static ServiceController<?> install(final ServiceTarget serviceTarget, final ServerConfigImpl serverConfig,
final List<ServiceName> dependencies, final boolean jmxSubsystemAvailable, final boolean requireUndertow) {
final ServiceBuilder<?> builder = serviceTarget.addService(WSServices.CONFIG_SERVICE);
final Consumer<ServerConfig> serverConfigConsumer = builder.provides(WSServices.CONFIG_SERVICE);
final Supplier<MBeanServer> mBeanServerSupplier = jmxSubsystemAvailable ? builder.requires(MBEAN_SERVER_NAME) : null;
final Supplier<UndertowService> undertowServiceSupplier = requireUndertow ? builder.requires(UndertowService.UNDERTOW) : null;
final Supplier<ServerEnvironment> serverEnvironmentSupplier = builder.requires(ServerEnvironmentService.SERVICE_NAME);
for (final ServiceName dep : dependencies) {
builder.requires(dep);
}
builder.setInstance(new ServerConfigService(serverConfig, serverConfigConsumer, mBeanServerSupplier, undertowServiceSupplier, serverEnvironmentSupplier));
return builder.install();
}
}
| 5,494 | 47.628319 | 162 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.service;
import static org.jboss.as.webservices.logging.WSLogger.ROOT_LOGGER;
import java.security.AccessController;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import javax.management.JMException;
import javax.management.MBeanServer;
import org.jboss.as.controller.ServiceNameFactory;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.ejb3.security.service.EJBViewMethodSecurityAttributesService;
import org.jboss.as.ejb3.subsystem.ApplicationSecurityDomainService;
import org.jboss.as.ejb3.subsystem.ApplicationSecurityDomainService.ApplicationSecurityDomain;
import org.jboss.as.server.CurrentServiceContainer;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.metadata.model.EJBEndpoint;
import org.jboss.as.webservices.security.EJBMethodSecurityAttributesAdaptor;
import org.jboss.as.webservices.security.ElytronSecurityDomainContextImpl;
import org.jboss.as.webservices.util.ASHelper;
import org.jboss.as.webservices.util.ServiceContainerEndpointRegistry;
import org.jboss.as.webservices.util.WSAttachmentKeys;
import org.jboss.as.webservices.util.WSServices;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.msc.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceController.Mode;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StopContext;
import org.jboss.ws.api.monitoring.RecordProcessor;
import org.jboss.ws.common.ObjectNameFactory;
import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.ws.common.management.ManagedEndpoint;
import org.jboss.ws.common.monitoring.ManagedRecordProcessor;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.EndpointType;
import org.jboss.wsf.spi.management.EndpointMetricsFactory;
import org.jboss.wsf.spi.security.EJBMethodSecurityAttributeProvider;
import org.wildfly.extension.undertow.Capabilities;
import org.wildfly.extension.undertow.Constants;
import org.wildfly.extension.undertow.deployment.UndertowAttachments;
import org.wildfly.security.auth.server.SecurityDomain;
/**
* WS endpoint service; this is meant for setting the lazy deployment time info into the Endpoint (stuff coming from
* dependencies upon other AS services that are started during the deployment)
*
* @author [email protected]
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Jim Ma</a>
*/
public final class EndpointService implements Service {
private static final ServiceName SECURITY_DOMAIN_SERVICE = ServiceName.JBOSS.append("security", "security-domain");
private static final String LEGACY_SECURITY_CAPABILITY = "org.wildfly.legacy-security";
private static final String ELYTRON_SECURITY_CAPABILITY = "org.wildfly.security.elytron";
private static final String WEB_APPLICATION_SECURITY_DOMAIN = "org.wildfly.undertow.application-security-domain";
private static final String EJB_APPLICATION_SECURITY_DOMAIN = "org.wildfly.ejb3.application-security-domain";
private static final RuntimeCapability<Void> EJB_APPLICATION_SECURITY_DOMAIN_RUNTIME_CAPABILITY = RuntimeCapability
.Builder.of(EJB_APPLICATION_SECURITY_DOMAIN, true, ApplicationSecurityDomain.class)
.build();
private static final String SECURITY_DOMAIN_NAME = "securityDomainName";
private static final String ELYTRON_SECURITY_DOMAIN = "elytronSecurityDomain";
private final Endpoint endpoint;
private final ServiceName name;
private final ServiceName aliasName;
private final Consumer<Endpoint> endpointConsumer;
private final Supplier<AbstractServerConfig> serverConfigService;
private final Supplier<ApplicationSecurityDomainService.ApplicationSecurityDomain> ejbApplicationSecurityDomain;
private final Supplier<EJBViewMethodSecurityAttributesService> ejbMethodSecurityAttributeService;
private final Supplier<SecurityDomain> elytronSecurityDomain;
private static final String DEFAULT_SECURITY_NAME = "other";
private static final String JAAS_CONTEXT_ROOT = "java:/jaas/";
private EndpointService(final Endpoint endpoint, final ServiceName name, final ServiceName aliasName, final Consumer<Endpoint> endpointConsumer,
Supplier<AbstractServerConfig> serverConfigService,
Supplier<ApplicationSecurityDomainService.ApplicationSecurityDomain> ejbApplicationSecurityDomain,
Supplier<EJBViewMethodSecurityAttributesService> ejbMethodSecurityAttributeService,
final Supplier<SecurityDomain> elytronSecurityDomain
) {
this.endpoint = endpoint;
this.name = name;
this.aliasName = aliasName;
this.endpointConsumer = endpointConsumer;
this.serverConfigService = serverConfigService;
this.ejbApplicationSecurityDomain = ejbApplicationSecurityDomain;
this.ejbMethodSecurityAttributeService = ejbMethodSecurityAttributeService;
this.elytronSecurityDomain = elytronSecurityDomain;
}
public static ServiceName getServiceName(final DeploymentUnit unit, final String endpointName) {
if (unit.getParent() != null) {
return WSServices.ENDPOINT_SERVICE.append(unit.getParent().getName()).append(unit.getName()).append(endpointName);
} else {
return WSServices.ENDPOINT_SERVICE.append(unit.getName()).append(endpointName);
}
}
@Override
public void start(final StartContext context) {
WSLogger.ROOT_LOGGER.starting(name);
if (endpoint.getProperty(ELYTRON_SECURITY_DOMAIN) != null && Boolean.parseBoolean(endpoint.getProperty(ELYTRON_SECURITY_DOMAIN).toString())) {
if (EndpointType.JAXWS_EJB3.equals(endpoint.getType())) {
endpoint.setSecurityDomainContext(new ElytronSecurityDomainContextImpl(this.ejbApplicationSecurityDomain.get().getSecurityDomain()));
} else {
endpoint.setSecurityDomainContext(new ElytronSecurityDomainContextImpl(this.elytronSecurityDomain.get()));
}
}
if (EndpointType.JAXWS_EJB3.equals(endpoint.getType())) {
final EJBViewMethodSecurityAttributesService ejbMethodSecurityAttributeService = this.ejbMethodSecurityAttributeService.get();
endpoint.addAttachment(EJBMethodSecurityAttributeProvider.class, new EJBMethodSecurityAttributesAdaptor(ejbMethodSecurityAttributeService));
}
final List<RecordProcessor> processors = endpoint.getRecordProcessors();
for (final RecordProcessor processor : processors) {
registerRecordProcessor(processor, endpoint);
}
final EndpointMetricsFactory endpointMetricsFactory = SPIProvider.getInstance().getSPI(EndpointMetricsFactory.class);
endpoint.setEndpointMetrics(endpointMetricsFactory.newEndpointMetrics());
registerEndpoint(endpoint);
endpoint.getLifecycleHandler().start(endpoint);
ServiceContainerEndpointRegistry.register(aliasName, endpoint);
endpointConsumer.accept(endpoint);
}
@Override
public void stop(final StopContext context) {
WSLogger.ROOT_LOGGER.stopping(name);
ServiceContainerEndpointRegistry.unregister(aliasName, endpoint);
endpoint.getLifecycleHandler().stop(endpoint);
endpoint.setSecurityDomainContext(null);
unregisterEndpoint(endpoint);
final List<RecordProcessor> processors = endpoint.getRecordProcessors();
for (final RecordProcessor processor : processors) {
unregisterRecordProcessor(processor, endpoint);
}
}
private void registerEndpoint(final Endpoint endpoint) {
MBeanServer mbeanServer = serverConfigService.get().getMbeanServer();
if (mbeanServer != null) {
try {
ManagedEndpoint jmxEndpoint = new ManagedEndpoint(endpoint, mbeanServer);
mbeanServer.registerMBean(jmxEndpoint, endpoint.getName());
} catch (final JMException ex) {
WSLogger.ROOT_LOGGER.trace("Cannot register endpoint in JMX server", ex);
WSLogger.ROOT_LOGGER.cannotRegisterEndpoint(endpoint.getShortName());
}
} else {
WSLogger.ROOT_LOGGER.mBeanServerNotAvailable(endpoint.getShortName());
}
}
private void unregisterEndpoint(final Endpoint endpoint) {
MBeanServer mbeanServer = serverConfigService.get().getMbeanServer();
if (mbeanServer != null) {
try {
mbeanServer.unregisterMBean(endpoint.getName());
} catch (final JMException ex) {
WSLogger.ROOT_LOGGER.trace("Cannot unregister endpoint from JMX server", ex);
WSLogger.ROOT_LOGGER.cannotUnregisterEndpoint(endpoint.getShortName());
}
} else {
WSLogger.ROOT_LOGGER.mBeanServerNotAvailable(endpoint.getShortName());
}
}
private void registerRecordProcessor(final RecordProcessor processor, final Endpoint ep) {
MBeanServer mbeanServer = serverConfigService.get().getMbeanServer();
if (mbeanServer != null) {
try {
mbeanServer.registerMBean(processor,
ObjectNameFactory.create(ep.getName() + ",recordProcessor=" + processor.getName()));
} catch (final JMException ex) {
WSLogger.ROOT_LOGGER.trace("Cannot register endpoint in JMX server, trying with the default ManagedRecordProcessor", ex);
try {
mbeanServer.registerMBean(new ManagedRecordProcessor(processor),
ObjectNameFactory.create(ep.getName() + ",recordProcessor=" + processor.getName()));
} catch (final JMException e) {
WSLogger.ROOT_LOGGER.cannotRegisterRecordProcessor();
}
}
} else {
WSLogger.ROOT_LOGGER.mBeanServerNotAvailable(processor);
}
}
private void unregisterRecordProcessor(final RecordProcessor processor, final Endpoint ep) {
MBeanServer mbeanServer = serverConfigService.get().getMbeanServer();
if (mbeanServer != null) {
try {
mbeanServer.unregisterMBean(ObjectNameFactory.create(ep.getName() + ",recordProcessor=" + processor.getName()));
} catch (final JMException e) {
WSLogger.ROOT_LOGGER.cannotUnregisterRecordProcessor();
}
} else {
WSLogger.ROOT_LOGGER.mBeanServerNotAvailable(processor);
}
}
public static void install(final ServiceTarget serviceTarget, final Endpoint endpoint, final DeploymentUnit unit) {
final ServiceName serviceName = getServiceName(unit, endpoint.getShortName());
final String propContext = endpoint.getName().getKeyProperty(Endpoint.SEPID_PROPERTY_CONTEXT);
final String propEndpoint = endpoint.getName().getKeyProperty(Endpoint.SEPID_PROPERTY_ENDPOINT);
final StringBuilder context = new StringBuilder(Endpoint.SEPID_PROPERTY_CONTEXT).append("=").append(propContext);
final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
Supplier<ApplicationSecurityDomainService.ApplicationSecurityDomain> ejbApplicationSecurityDomain = null;
Supplier<EJBViewMethodSecurityAttributesService> ejbMethodSecurityAttributeService = null;
Supplier<SecurityDomain> elytronSecurityDomain = null;
final ServiceName alias = WSServices.ENDPOINT_SERVICE.append(context.toString()).append(propEndpoint);
final Consumer<Endpoint> endpointConsumer = builder.provides(serviceName, alias);
//builder.addAliases(alias);
final String domainName = getDeploymentSecurityDomainName(endpoint, unit);
endpoint.setProperty(SECURITY_DOMAIN_NAME, domainName);
if (isElytronSecurityDomain(unit, endpoint, domainName)) {
if (EndpointType.JAXWS_EJB3.equals(endpoint.getType())) {
ServiceName ejbSecurityDomainServiceName = EJB_APPLICATION_SECURITY_DOMAIN_RUNTIME_CAPABILITY
.getCapabilityServiceName(domainName, ApplicationSecurityDomainService.ApplicationSecurityDomain.class);
ejbApplicationSecurityDomain = builder.requires(ejbSecurityDomainServiceName);
} else {
CapabilityServiceSupport capabilityServiceSupport = unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
if (capabilityServiceSupport != null) {
ServiceName securityDomainName = capabilityServiceSupport.getCapabilityServiceName(
Capabilities.CAPABILITY_APPLICATION_SECURITY_DOMAIN,
domainName).append(Constants.SECURITY_DOMAIN);
elytronSecurityDomain = builder.requires(securityDomainName);
} else {
//There is no CAPABILITY_SERVICE_SUPPORT attachment in the DeploymentUnit created by org.jboss.as.webservices.service.EndpointPublisherImpl
ServiceName publishEndpointSecurityDomainName = ServiceNameFactory.parseServiceName(WEB_APPLICATION_SECURITY_DOMAIN).append(domainName)
.append(Constants.SECURITY_DOMAIN);
elytronSecurityDomain = builder.requires(publishEndpointSecurityDomainName);
}
}
endpoint.setProperty(ELYTRON_SECURITY_DOMAIN, true);
}
else if (isLegacySecurityDomain(unit, endpoint, domainName)) {
throw ROOT_LOGGER.legacySecurityUnsupported();
}
final Supplier<AbstractServerConfig> serverConfigService = builder.requires(WSServices.CONFIG_SERVICE);
if (EndpointType.JAXWS_EJB3.equals(endpoint.getType())) {
ejbMethodSecurityAttributeService = builder.requires(getEJBViewMethodSecurityAttributesServiceName(unit, endpoint));
}
builder.setInstance(new EndpointService(endpoint, serviceName, alias, endpointConsumer,
serverConfigService, ejbApplicationSecurityDomain, ejbMethodSecurityAttributeService, elytronSecurityDomain));
builder.install();
//add a dependency on the endpoint service to web deployments, so that the
//endpoint servlet is not started before the endpoint is actually available
unit.addToAttachmentList(Attachments.WEB_DEPENDENCIES, serviceName);
}
public static void uninstall(final Endpoint endpoint, final DeploymentUnit unit) {
final ServiceName serviceName = getServiceName(unit, endpoint.getShortName());
final ServiceController<?> endpointService = currentServiceContainer().getService(serviceName);
if (endpointService != null) {
endpointService.setMode(Mode.REMOVE);
}
}
private static String getDeploymentSecurityDomainName(final Endpoint ep, final DeploymentUnit unit) {
JBossWebMetaData metadata = ep.getService().getDeployment().getAttachment(JBossWebMetaData.class);
String metaDataSecurityDomain = metadata != null ? metadata.getSecurityDomain() : null;
if (metaDataSecurityDomain == null) {
if (unit.hasAttachment(UndertowAttachments.DEFAULT_SECURITY_DOMAIN)) {
metaDataSecurityDomain = unit.getAttachment(UndertowAttachments.DEFAULT_SECURITY_DOMAIN);
} else {
metaDataSecurityDomain = DEFAULT_SECURITY_NAME;
}
} else {
metaDataSecurityDomain = unprefixSecurityDomain(metaDataSecurityDomain.trim());
}
return metaDataSecurityDomain;
}
private static ServiceName getEJBViewMethodSecurityAttributesServiceName(final DeploymentUnit unit, final Endpoint endpoint) {
for (EJBEndpoint ep : ASHelper.getJaxwsEjbs(unit)) {
if (ep.getClassName().equals(endpoint.getTargetBeanName())) {
return ep.getEJBViewMethodSecurityAttributesService();
}
}
return null;
}
static List<ServiceName> getServiceNamesFromDeploymentUnit(final DeploymentUnit unit) {
final List<ServiceName> endpointServiceNames = new ArrayList<>();
Deployment deployment = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
for (Endpoint ep : deployment.getService().getEndpoints()) {
endpointServiceNames.add(EndpointService.getServiceName(unit, ep.getShortName()));
}
return endpointServiceNames;
}
private static ServiceContainer currentServiceContainer() {
if(System.getSecurityManager() == null) {
return CurrentServiceContainer.getServiceContainer();
}
return AccessController.doPrivileged(CurrentServiceContainer.GET_ACTION);
}
private static boolean isElytronSecurityDomain(DeploymentUnit unit, Endpoint endpoint, String domainName) {
CapabilityServiceSupport capabilitySupport = unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
if (capabilitySupport != null && !capabilitySupport.hasCapability(ELYTRON_SECURITY_CAPABILITY)) {
return false;
}
final ServiceName serviceName;
if (EndpointType.JAXWS_EJB3.equals(endpoint.getType())) {
serviceName = EJB_APPLICATION_SECURITY_DOMAIN_RUNTIME_CAPABILITY.getCapabilityServiceName(domainName,
ApplicationSecurityDomainService.ApplicationSecurityDomain.class);
} else {
serviceName = ServiceNameFactory.parseServiceName(WEB_APPLICATION_SECURITY_DOMAIN).append(domainName)
.append(Constants.SECURITY_DOMAIN);
}
return currentServiceContainer().getService(serviceName) != null;
}
private static boolean isLegacySecurityDomain(DeploymentUnit unit, Endpoint endpoint, String domainName) {
CapabilityServiceSupport capabilitySupport = unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
if (capabilitySupport != null && !capabilitySupport.hasCapability(LEGACY_SECURITY_CAPABILITY)) {
return false;
}
final ServiceName serviceName = SECURITY_DOMAIN_SERVICE.append(domainName);
return currentServiceContainer().getService(serviceName) != null;
}
public static String unprefixSecurityDomain(String securityDomain) {
String result = null;
if (securityDomain != null) {
if (securityDomain.startsWith("java:jboss/jaas/")) {
result = securityDomain.substring("java:jboss/jaas/".length());
} else if (securityDomain.startsWith("java:jboss/jbsx/")) {
result = securityDomain.substring("java:jboss/jbsx/".length());
} else if (securityDomain.startsWith(JAAS_CONTEXT_ROOT)) {
result = securityDomain.substring(JAAS_CONTEXT_ROOT.length());
} else {
result = securityDomain;
}
}
return result;
}
}
| 20,635 | 54.176471 | 159 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/service/HandlerChainService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.msc.Service;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StopContext;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData;
/**
* A service for creating handler chain metadata.
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class HandlerChainService implements Service {
private final String handlerChainId;
private final String protocolBindings;
private final List<Supplier<UnifiedHandlerMetaData>> handlerSuppliers;
private final Consumer<UnifiedHandlerChainMetaData> handlerChainConsumer;
public HandlerChainService(final String handlerChainType, final String handlerChainId, final String protocolBindings,
final Consumer<UnifiedHandlerChainMetaData> handlerChainConsumer,
final List<Supplier<UnifiedHandlerMetaData>> handlerSuppliers) {
if (!handlerChainType.equalsIgnoreCase("pre-handler-chain") && !handlerChainType.equals("post-handler-chain")) {
throw new RuntimeException(
WSLogger.ROOT_LOGGER.wrongHandlerChainType(handlerChainType, "pre-handler-chain", "post-handler-chain"));
}
this.handlerChainId = handlerChainId;
this.protocolBindings = protocolBindings;
this.handlerChainConsumer = handlerChainConsumer;
this.handlerSuppliers = handlerSuppliers;
}
@Override
public void start(final StartContext context) {
final List<UnifiedHandlerMetaData> handlers = new ArrayList<>();
for (final Supplier<UnifiedHandlerMetaData> handlerSupplier : handlerSuppliers) {
handlers.add(handlerSupplier.get());
}
Collections.sort(handlers, HandlersComparator.INSTANCE);
handlerChainConsumer.accept(new UnifiedHandlerChainMetaData(null, null, protocolBindings, handlers, false, handlerChainId));
}
@Override
public void stop(final StopContext context) {
handlerChainConsumer.accept(null);
}
private static final class HandlersComparator implements Comparator<UnifiedHandlerMetaData> {
private static final Comparator<UnifiedHandlerMetaData> INSTANCE = new HandlersComparator();
@Override
public int compare(final UnifiedHandlerMetaData o1, final UnifiedHandlerMetaData o2) {
return o1.getId().compareTo(o2.getId());
}
}
}
| 3,884 | 42.166667 | 132 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/service/HandlerService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.service;
import java.util.function.Consumer;
import org.jboss.msc.Service;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StopContext;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData;
/**
* A service for creating handler metadata.
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class HandlerService implements Service {
private final String handlerName;
private final String handlerClass;
private final int counter;
private final Consumer<UnifiedHandlerMetaData> handlerConsumer;
public HandlerService(final String handlerName, final String handlerClass, final int counter, final Consumer<UnifiedHandlerMetaData> handlerConsumer) {
this.handlerName = handlerName;
this.handlerClass = handlerClass;
this.counter = counter;
this.handlerConsumer = handlerConsumer;
}
@Override
public void start(final StartContext context) {
handlerConsumer.accept(new UnifiedHandlerMetaData(handlerClass, handlerName, null, null, null, null, String.valueOf(counter)));
}
@Override
public void stop(final StopContext context) {
handlerConsumer.accept(null);
}
}
| 2,365 | 37.786885 | 155 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointDeployService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.service;
import java.util.Map;
import java.util.Map.Entry;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.publish.EndpointPublisherHelper;
import org.jboss.as.webservices.util.WSAttachmentKeys;
import org.jboss.as.webservices.util.WSServices;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.msc.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
/**
* WS endpoint deploy service, triggers the deployment unit processing for
* the EndpointPublishService
*
* @author [email protected]
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class EndpointDeployService implements Service {
private final ServiceName name;
private final DeploymentUnit unit;
private EndpointDeployService(final String context, final DeploymentUnit unit) {
this.name = WSServices.ENDPOINT_DEPLOY_SERVICE.append(context);
this.unit = unit;
}
public ServiceName getName() {
return name;
}
@Override
public void start(final StartContext ctx) throws StartException {
WSLogger.ROOT_LOGGER.starting(name);
try {
EndpointPublisherHelper.doDeployStep(ctx.getChildTarget(), unit);
} catch (Exception e) {
throw new StartException(e);
}
}
@Override
public void stop(final StopContext ctx) {
WSLogger.ROOT_LOGGER.stopping(name);
try {
EndpointPublisherHelper.undoDeployStep(unit);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static DeploymentUnit install(final ServiceTarget serviceTarget, final String context, final ClassLoader loader,
final String hostName, final Map<String,String> urlPatternToClassName, JBossWebMetaData jbwmd, WebservicesMetaData wsmd, JBossWebservicesMetaData jbwsmd) {
return install(serviceTarget, context, loader, hostName, urlPatternToClassName, jbwmd, wsmd, jbwsmd, null, null);
}
public static DeploymentUnit install(final ServiceTarget serviceTarget, final String context, final ClassLoader loader,
final String hostName, final Map<String, String> urlPatternToClassName, JBossWebMetaData jbwmd,
WebservicesMetaData wsmd, JBossWebservicesMetaData jbwsmd, Map<Class<?>, Object> deploymentAttachments,
CapabilityServiceSupport capabilityServiceSupport) {
final DeploymentUnit unit = EndpointPublisherHelper.doPrepareStep(context, loader, urlPatternToClassName, jbwmd, wsmd,
jbwsmd, capabilityServiceSupport);
if (deploymentAttachments != null) {
Deployment dep = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
for (Entry<Class<?>, Object> e : deploymentAttachments.entrySet()) {
dep.addAttachment(e.getKey(), e.getValue());
}
}
final EndpointDeployService service = new EndpointDeployService(context, unit);
final ServiceBuilder builder = serviceTarget.addService(service.getName());
builder.requires(WSServices.CONFIG_SERVICE);
builder.setInstance(service);
builder.install();
return unit;
}
}
| 4,865 | 42.446429 | 167 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/config/WebServerInfoImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.config;
import org.jboss.as.web.host.CommonWebServer;
import org.jboss.wsf.spi.management.WebServerInfo;
public class WebServerInfoImpl implements WebServerInfo {
private final CommonWebServer webServer;
public WebServerInfoImpl(CommonWebServer webServer) {
this.webServer = webServer;
}
public int getPort(String protocol, boolean secure) {
return webServer.getPort(protocol, secure);
}
}
| 1,487 | 37.153846 | 70 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/config/DisabledOperationException.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.config;
/**
* Exception indicating the required operation is disabled (temporarly or pemanently) and hence coudn't be performed.
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
*/
public final class DisabledOperationException extends RuntimeException {
private static final long serialVersionUID = 1773053642986195568L;
public DisabledOperationException() {
super();
}
public DisabledOperationException(String message) {
super(message);
}
public DisabledOperationException(String message, Throwable cause) {
super(message, cause);
}
}
| 1,689 | 35.73913 | 117 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/config/WebServerInfoFactoryImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.config;
import org.jboss.as.web.host.CommonWebServer;
import org.jboss.as.webservices.util.ASHelper;
import org.jboss.wsf.spi.management.WebServerInfo;
import org.jboss.wsf.spi.management.WebServerInfoFactory;
public class WebServerInfoFactoryImpl extends WebServerInfoFactory {
public WebServerInfo newWebServerInfo() {
return new WebServerInfoImpl(ASHelper.getMSCService(CommonWebServer.SERVICE_NAME, CommonWebServer.class));
}
}
| 1,507 | 42.085714 | 114 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/config/ServerConfigImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.config;
import java.io.File;
import java.net.UnknownHostException;
import java.util.concurrent.atomic.AtomicInteger;
import javax.management.MBeanServer;
import org.jboss.as.server.ServerEnvironment;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.ws.common.management.AbstractServerConfigMBean;
import org.jboss.wsf.spi.metadata.config.ClientConfig;
import org.wildfly.extension.undertow.Host;
import org.wildfly.extension.undertow.Server;
import org.wildfly.extension.undertow.UndertowListener;
import org.wildfly.extension.undertow.UndertowService;
/**
* WFLY specific ServerConfig, extending AbstractServerConfig with management
* related functionalities.
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Thomas Diesler</a>
* @author <a href="mailto:[email protected]">Jim Ma</a>
*/
public final class ServerConfigImpl extends AbstractServerConfig implements AbstractServerConfigMBean {
private volatile MBeanServer mBeanServer;
private volatile ServerEnvironment serverEnvironment;
private volatile UndertowService undertowService;
private final AtomicInteger wsDeploymentCount = new AtomicInteger(0);
private final DMRSynchCheckHandler webServiceHostUCH = new DMRSynchCheckHandler();
private final DMRSynchCheckHandler webServicePortUCH = new DMRSynchCheckHandler();
private final DMRSynchCheckHandler webServiceSecurePortUCH = new DMRSynchCheckHandler();
private final DMRSynchCheckHandler webServiceUriSchemeUCH = new DMRSynchCheckHandler();
private final DMRSynchCheckHandler modifySOAPAddressUCH = new DMRSynchCheckHandler();
private final DMRSynchCheckHandler webServicePathRewriteRuleUCH = new DMRSynchCheckHandler();
private ServerConfigImpl() {
// forbidden inheritance
}
@Override
public void create() throws Exception {
super.create();
wsDeploymentCount.set(0);
webServiceHostUCH.reset();
webServicePortUCH.reset();
webServiceSecurePortUCH.reset();
modifySOAPAddressUCH.reset();
webServicePathRewriteRuleUCH.reset();
}
public void incrementWSDeploymentCount() {
wsDeploymentCount.incrementAndGet();
}
public void decrementWSDeploymentCount() {
wsDeploymentCount.decrementAndGet();
}
protected boolean isModifiable() {
return (wsDeploymentCount.get() == 0);
}
public void setWebServiceHost(String host, boolean forceUpdate) throws UnknownHostException {
setWebServiceHost(host, forceUpdate ? null : webServiceHostUCH);
}
@Override
public void setWebServiceHost(String host) throws UnknownHostException {
//prevent any change if the DMR configuration is not in synch anymore with the runtime
setWebServiceHost(host, webServiceHostUCH);
}
public void setWebServicePathRewriteRule(String path, boolean forceUpdate) {
setWebServicePathRewriteRule(path, forceUpdate ? null : webServicePathRewriteRuleUCH);
}
@Override
public void setWebServicePathRewriteRule(String path) {
setWebServicePathRewriteRule(path, webServicePathRewriteRuleUCH);
}
public void setWebServicePort(int port, boolean forceUpdate) {
setWebServicePort(port, forceUpdate ? null : webServicePortUCH);
}
@Override
public void setWebServicePort(int port) {
//prevent any change if the DMR configuration is not in synch anymore with the runtime
setWebServicePort(port, webServicePortUCH);
}
public void setWebServiceSecurePort(int port, boolean forceUpdate) {
setWebServiceSecurePort(port, forceUpdate ? null : webServiceSecurePortUCH);
}
public void setWebServiceUriScheme(String scheme, boolean forceUpdate) {
setWebServiceUriScheme(scheme, forceUpdate ? null : webServiceUriSchemeUCH);
}
@Override
public void setWebServiceSecurePort(int port) {
//prevent any change if the DMR configuration is not in synch anymore with the runtime
setWebServiceSecurePort(port, webServiceSecurePortUCH);
}
public void setModifySOAPAddress(boolean flag, boolean forceUpdate) {
setModifySOAPAddress(flag, forceUpdate ? null : modifySOAPAddressUCH);
}
@Override
public void setModifySOAPAddress(boolean flag) {
//prevent any change if the DMR configuration is not in synch anymore with the runtime
setModifySOAPAddress(flag, modifySOAPAddressUCH);
}
public File getServerTempDir() {
return getServerEnvironment().getServerTempDir();
}
public File getHomeDir() {
return getServerEnvironment().getHomeDir();
}
public File getServerDataDir() {
return getServerEnvironment().getServerDataDir();
}
@Override
public MBeanServer getMbeanServer() {
return mBeanServer;
}
@Override
public void setMbeanServer(final MBeanServer mBeanServer) {
this.mBeanServer = mBeanServer;
}
public void setServerEnvironment(final ServerEnvironment serverEnvironment) {
this.serverEnvironment = serverEnvironment;
}
public void setUndertowService(final UndertowService undertowService) {
this.undertowService = undertowService;
}
private ServerEnvironment getServerEnvironment() {
return serverEnvironment;
}
private UndertowService getUndertowService() {
return undertowService;
}
public static ServerConfigImpl newInstance() {
return new ServerConfigImpl();
}
public void setClientConfigWrapper(ClientConfig config, boolean reload) {
clientConfigStore.setWrapperConfig(config, reload);
}
@Override
public Integer getVirtualHostPort(String hostname, boolean securePort) {
ServerHostInfo hostInfo = new ServerHostInfo(hostname);
Host undertowHost = getUndertowHost(hostInfo);
if (undertowHost != null && !undertowHost.getServer().getListeners().isEmpty()) {
for(UndertowListener listener : undertowHost.getServer().getListeners()) {
if (listener.isSecure() == securePort) {
return listener.getSocketBinding().getAbsolutePort();
}
}
}
return null;
}
@Override
public String getHostAlias(String hostname) {
ServerHostInfo hostInfo = new ServerHostInfo(hostname);
Host undertowHost = getUndertowHost(hostInfo);
if (undertowHost!= null && !undertowHost.getAllAliases().isEmpty()) {
for (String alias : undertowHost.getAllAliases()) {
if (undertowHost.getAllAliases().size() == 1 || !alias.equals(undertowHost.getName())) {
return alias;
}
}
}
return null;
}
private class DMRSynchCheckHandler implements UpdateCallbackHandler {
private volatile boolean dmrSynched = true;
@Override
public void onBeforeUpdate() {
if (!dmrSynched) {
throw WSLogger.ROOT_LOGGER.couldNotUpdateServerConfigBecauseOfReloadRequired();
}
//prevent any modification to the AbstractServerConfig members
//when there's at least a WS endpoint deployment on the server
if (!isModifiable()) {
dmrSynched = false;
throw WSLogger.ROOT_LOGGER.couldNotUpdateServerConfigBecauseOfExistingWSDeployment();
}
}
public void reset() {
dmrSynched = true;
}
}
private Host getUndertowHost(final ServerHostInfo info) {
UndertowService us = getUndertowService();
if (us != null) {
for (Server server : getUndertowService().getServers()) {
if (info.getServerInstanceName() != null && !server.getName().equals(info.getServerInstanceName())) {
continue;
}
for (Host undertowHost : server.getHosts()) {
if (undertowHost.getName().equals(info.getHost())) {
return undertowHost;
}
}
}
}
return null;
}
}
| 9,444 | 36.332016 | 117 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/config/ServerHostInfo.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.config;
/**
* Class to parse the virtualHost name with server instance info like "host@server"
* @author <a herf="mailto:[email protected]>Jim Ma</a>
*
*/
public class ServerHostInfo {
private String host = null;
private String serverInstanceName = null;
public ServerHostInfo(final String hostAtServer) {
host = hostAtServer;
serverInstanceName = null;
if (hostAtServer != null) {
int tokenLoc = hostAtServer.lastIndexOf("@");
if (tokenLoc > 0 && tokenLoc != hostAtServer.length() - 1) {
host = hostAtServer.substring(0, tokenLoc);
serverInstanceName = hostAtServer.substring(tokenLoc + 1);
}
}
}
/**
* @return host parsed part "host" from passed in virtualHost string like "host@server"
*/
public String getHost() {
return host;
}
/**
* @return return parsed server instance part "sever" from passed in virtualHost string like "host@server"
*/
public String getServerInstanceName() {
return serverInstanceName;
}
}
| 2,160 | 37.589286 | 110 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/config/ServerConfigFactoryImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.config;
import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.spi.management.ServerConfigFactory;
/**
* Retrieves webservices stack specific config.
*
* @author <a href="mailto:[email protected]">Heiko Braun</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class ServerConfigFactoryImpl extends ServerConfigFactory {
private static volatile ServerConfig config;
public ServerConfig getServerConfig() {
return config;
}
public static void setConfig(final ServerConfig config) {
ServerConfigFactoryImpl.config = config;
}
public static ServerConfig getConfig() {
return ServerConfigFactoryImpl.config;
}
}
| 1,786 | 34.74 | 72 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/invocation/NamespaceCtxSelectorWrapperFactory.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.invocation;
import org.jboss.wsf.spi.invocation.NamespaceContextSelectorWrapper;
/**
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
*
*/
public class NamespaceCtxSelectorWrapperFactory implements org.jboss.wsf.spi.invocation.NamespaceContextSelectorWrapperFactory {
private static NamespaceContextSelectorWrapper instance = new NamespaceCtxSelectorWrapper();
@Override
public NamespaceContextSelectorWrapper getWrapper() {
return instance;
}
}
| 1,570 | 37.317073 | 128 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/invocation/NamespaceCtxSelectorWrapper.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.invocation;
import java.util.Map;
import org.jboss.as.naming.context.NamespaceContextSelector;
/**
* A wrapper of the NamespaceContextSelector for copying/reading it to/from
* a provided map (usually message context / exchange from ws stack)
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
*
*/
public class NamespaceCtxSelectorWrapper implements org.jboss.wsf.spi.invocation.NamespaceContextSelectorWrapper {
private static final String KEY = org.jboss.wsf.spi.invocation.NamespaceContextSelectorWrapper.class.getName();
@Override
public void storeCurrentThreadSelector(Map<String, Object> map) {
map.put(KEY, NamespaceContextSelector.getCurrentSelector());
}
@Override
public void setCurrentThreadSelector(Map<String, Object> map) {
NamespaceContextSelector.pushCurrentSelector((NamespaceContextSelector)map.get(KEY));
}
@Override
public void clearCurrentThreadSelector(Map<String, Object> map) {
if (map.containsKey(KEY)) {
map.remove(KEY);
NamespaceContextSelector.popCurrentSelector();
}
}
}
| 2,199 | 36.931034 | 115 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/invocation/AbstractInvocationHandler.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.invocation;
import static org.jboss.as.webservices.metadata.model.AbstractEndpoint.COMPONENT_VIEW_NAME;
import static org.jboss.as.webservices.metadata.model.AbstractEndpoint.WELD_DEPLOYMENT;
import static org.jboss.as.webservices.util.ASHelper.getMSCService;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.UndeclaredThrowableException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collection;
import java.util.concurrent.Callable;
import javax.management.MBeanException;
import jakarta.xml.ws.soap.SOAPFaultException;
import org.jboss.as.ee.component.Component;
import org.jboss.as.ee.component.ComponentView;
import org.jboss.as.naming.ManagedReference;
import org.jboss.as.webservices.injection.WSComponent;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.invocation.InterceptorContext;
import org.jboss.msc.service.ServiceName;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.EndpointState;
import org.jboss.wsf.spi.deployment.EndpointType;
import org.jboss.wsf.spi.invocation.Invocation;
import org.jboss.wsf.spi.security.SecurityDomainContext;
import org.wildfly.transaction.client.ContextTransactionManager;
import org.wildfly.transaction.client.LocalTransactionContext;
/**
* Invocation abstraction for all endpoint types
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Jim Ma</a>
*/
abstract class AbstractInvocationHandler extends org.jboss.ws.common.invocation.AbstractInvocationHandler {
private volatile ServiceName componentViewName;
private volatile ComponentView componentView;
protected volatile ManagedReference reference;
/**
* Initializes component view name.
*
* @param endpoint web service endpoint
*/
public void init(final Endpoint endpoint) {
componentViewName = (ServiceName) endpoint.getProperty(COMPONENT_VIEW_NAME);
}
/**
* Gets endpoint container lazily.
*
* @return endpoint container
*/
protected ComponentView getComponentView() {
ComponentView cv = componentView;
// we need to check both, otherwise it is possible for
// componentView to be initialized before reference
if (cv == null) {
synchronized (this) {
cv = componentView;
if (cv == null) {
SecurityManager sm = System.getSecurityManager();
if (sm == null) {
cv = getMSCService(componentViewName, ComponentView.class);
} else {
cv = AccessController.doPrivileged(
(PrivilegedAction<ComponentView>) () -> getMSCService(componentViewName, ComponentView.class));
}
if (cv == null) {
throw WSLogger.ROOT_LOGGER.cannotFindComponentView(componentViewName);
}
componentView = cv;
}
}
}
return cv;
}
/**
* Invokes WS endpoint.
*
* @param endpoint WS endpoint
* @param wsInvocation web service invocation
* @throws Exception if any error occurs
*/
public void invoke(final Endpoint endpoint, final Invocation wsInvocation) throws Exception {
try {
if (!EndpointState.STARTED.equals(endpoint.getState())) {
throw WSLogger.ROOT_LOGGER.endpointAlreadyStopped(endpoint.getShortName());
}
SecurityDomainContext securityDomainContext = endpoint.getSecurityDomainContext();
if (securityDomainContext != null) {
securityDomainContext.runAs((Callable<Void>) () -> {
invokeInternal(endpoint, wsInvocation);
return null;
});
} else {
invokeInternal(endpoint, wsInvocation);
}
} catch (Throwable t) {
handleInvocationException(t);
} finally {
onAfterInvocation(wsInvocation);
}
}
public void invokeInternal(final Endpoint endpoint, final Invocation wsInvocation) throws Exception {
// prepare for invocation
onBeforeInvocation(wsInvocation);
// prepare invocation data
final ComponentView componentView = getComponentView();
Component component = componentView.getComponent();
final boolean forceTargetBean = (wsInvocation.getInvocationContext().getProperty("forceTargetBean") != null);
boolean isWeldDeployment = endpoint.getProperty(WELD_DEPLOYMENT) == null ? false : (Boolean) endpoint.getProperty(WELD_DEPLOYMENT);
if (forceTargetBean || !isWeldDeployment && endpoint.getType() == EndpointType.JAXWS_JSE) {
this.reference = new ManagedReference() {
public void release() {
}
public Object getInstance() {
return wsInvocation.getInvocationContext().getTargetBean();
}
};
if (component instanceof WSComponent) {
((WSComponent) component).setReference(reference);
}
}
final Method method = getComponentViewMethod(wsInvocation.getJavaMethod(), componentView.getViewMethods());
final InterceptorContext context = new InterceptorContext();
prepareForInvocation(context, wsInvocation);
context.setMethod(method);
context.setParameters(wsInvocation.getArgs());
context.putPrivateData(Component.class, component);
context.putPrivateData(ComponentView.class, componentView);
// pull in any XTS transaction
LocalTransactionContext.getCurrent().importProviderTransaction();
context.setTransaction(ContextTransactionManager.getInstance().getTransaction());
if (forceTargetBean) {
context.putPrivateData(ManagedReference.class, reference);
}
// invoke method
final Object retObj = componentView.invoke(context);
// set return value
wsInvocation.setReturnValue(retObj);
}
protected void prepareForInvocation(final InterceptorContext context, final Invocation wsInvocation) {
// does nothing
}
/**
* Translates SEI method to component view method.
*
* @param seiMethod SEI method
* @param viewMethods component view methods
* @return matching component view method
*/
protected Method getComponentViewMethod(final Method seiMethod, final Collection<Method> viewMethods) {
for (final Method viewMethod : viewMethods) {
if (matches(seiMethod, viewMethod)) {
return viewMethod;
}
}
throw new IllegalStateException();
}
protected void handleInvocationException(final Throwable t) throws Exception {
if (t instanceof MBeanException) {
throw ((MBeanException) t).getTargetException();
}
if (t instanceof Exception) {
if (t instanceof InvocationTargetException) {
throw (Exception) t;
} else {
SOAPFaultException ex = findSoapFaultException(t);
if (ex != null) {
throw new InvocationTargetException(ex);
}
throw new InvocationTargetException(t);
}
}
if (t instanceof Error) {
throw (Error) t;
}
throw new UndeclaredThrowableException(t);
}
protected SOAPFaultException findSoapFaultException(Throwable ex) {
if (ex instanceof SOAPFaultException) {
return (SOAPFaultException) ex;
}
if (ex.getCause() != null) {
return findSoapFaultException(ex.getCause());
}
return null;
}
/**
* Compares two methods if they are identical.
*
* @param seiMethod reference method
* @param viewMethod target method
* @return true if they match, false otherwise
*/
private boolean matches(final Method seiMethod, final Method viewMethod) {
if (!seiMethod.getName().equals(viewMethod.getName())) return false;
final Class<?>[] sourceParams = seiMethod.getParameterTypes();
final Class<?>[] targetParams = viewMethod.getParameterTypes();
if (sourceParams.length != targetParams.length) return false;
for (int i = 0; i < sourceParams.length; i++) {
if (!sourceParams[i].equals(targetParams[i])) return false;
}
return true;
}
}
| 9,717 | 38.827869 | 140 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/invocation/InvocationHandlerJAXWS.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.invocation;
import jakarta.xml.ws.WebServiceContext;
import org.jboss.invocation.InterceptorContext;
import org.jboss.ws.common.injection.ThreadLocalAwareWebServiceContext;
import org.jboss.wsf.spi.invocation.Invocation;
import org.jboss.wsf.spi.invocation.InvocationContext;
/**
* Handles invocations on Enterprise Beans 3 endpoints.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
final class InvocationHandlerJAXWS extends AbstractInvocationHandler {
@Override
public void onBeforeInvocation(final Invocation invocation) {
final WebServiceContext wsContext = getWebServiceContext(invocation);
ThreadLocalAwareWebServiceContext.getInstance().setMessageContext(wsContext);
}
@Override
public void onAfterInvocation(final Invocation invocation) {
ThreadLocalAwareWebServiceContext.getInstance().setMessageContext(null);
}
@Override
protected void prepareForInvocation(final InterceptorContext context, final Invocation wsInvocation) {
context.setContextData(getWebServiceContext(wsInvocation).getMessageContext());
}
private static WebServiceContext getWebServiceContext(final Invocation invocation) {
final InvocationContext invocationContext = invocation.getInvocationContext();
return invocationContext.getAttachment(WebServiceContext.class);
}
}
| 2,410 | 39.183333 | 105 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/invocation/InvocationHandlerFactoryImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.invocation;
import org.jboss.wsf.spi.invocation.InvocationHandler;
import org.jboss.wsf.spi.invocation.InvocationHandlerFactory;
import org.jboss.wsf.spi.invocation.InvocationType;
/**
* The default invocation model factory for JBoss AS.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class InvocationHandlerFactoryImpl extends InvocationHandlerFactory {
public InvocationHandler newInvocationHandler(final InvocationType type) {
InvocationHandler handler = null;
switch (type) {
case JAXWS_JSE:
handler = new InvocationHandlerJAXWS();
break;
case JAXWS_EJB3:
handler = new InvocationHandlerJAXWS();
break;
default:
throw new IllegalArgumentException();
}
return handler;
}
}
| 1,943 | 35.679245 | 82 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/logging/WSLogger.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2020, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.logging;
import static org.jboss.logging.Logger.Level.DEBUG;
import static org.jboss.logging.Logger.Level.ERROR;
import static org.jboss.logging.Logger.Level.FATAL;
import static org.jboss.logging.Logger.Level.INFO;
import static org.jboss.logging.Logger.Level.WARN;
import java.io.IOException;
import java.lang.reflect.Method;
import jakarta.xml.ws.WebServiceException;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.module.ResourceRoot;
import org.jboss.as.webservices.config.DisabledOperationException;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.LogMessage;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartException;
import org.jboss.vfs.VirtualFile;
import org.jboss.wsf.spi.WSFException;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
*/
@MessageLogger(projectCode = "WFLYWS", length = 4)
public interface WSLogger extends BasicLogger {
WSLogger ROOT_LOGGER = Logger.getMessageLogger(WSLogger.class, "org.jboss.as.webservices");
@LogMessage(level = WARN)
@Message(id = 1, value = "Cannot load WS deployment aspects from %s")
void cannotLoadDeploymentAspectsDefinitionFile(String resourcePath);
RuntimeException cannotLoadDeploymentAspectsDefinitionFile(@Cause Throwable cause, String resourcePath);
@LogMessage(level = INFO)
@Message(id = 2, value = "Activating WebServices Extension")
void activatingWebservicesExtension();
@LogMessage(level = INFO)
@Message(id = 3, value = "Starting %s")
void starting(Object object);
@LogMessage(level = INFO)
@Message(id = 4, value = "Stopping %s")
void stopping(Object object);
@LogMessage(level = FATAL)
@Message(id = 5, value = "Error while creating configuration service")
void configServiceCreationFailed();
@LogMessage(level = ERROR)
@Message(id = 6, value = "Error while destroying configuration service")
void configServiceDestroyFailed();
@LogMessage(level = WARN)
@Message(id = 7, value = "Could not read WSDL from: %s")
void cannotReadWsdl(String wsdlLocation);
@LogMessage(level = WARN)
@Message(id = 8, value = "[JAXWS 2.2 spec, section 7.7] The @WebService and @WebServiceProvider annotations are mutually exclusive - %s won't be considered as a webservice endpoint, since it doesn't meet that requirement")
void mutuallyExclusiveAnnotations(String className);
@LogMessage(level = WARN)
@Message(id = 9, value = "WebService endpoint class cannot be final - %s won't be considered as a webservice endpoint")
void finalEndpointClassDetected(String className);
@LogMessage(level = WARN)
@Message(id = 10, value = "Ignoring <port-component-ref> without <service-endpoint-interface> and <port-qname>: %s")
void ignoringPortComponentRef(Object o);
@LogMessage(level = ERROR)
@Message(id = 11, value = "Cannot register record processor in JMX server")
void cannotRegisterRecordProcessor();
@LogMessage(level = ERROR)
@Message(id = 12, value = "Cannot unregister record processor from JMX server")
void cannotUnregisterRecordProcessor();
@LogMessage(level = INFO)
@Message(id = 13, value = "MBeanServer not available, skipping registration/unregistration of %s")
void mBeanServerNotAvailable(Object bean);
@LogMessage(level = WARN)
@Message(id = 14, value = "Multiple Enterprise Beans 3 endpoints in the same deployment with different declared security roles; be aware this might be a security risk if you're not controlling allowed roles (@RolesAllowed) on each ws endpoint method.")
void multipleEndpointsWithDifferentDeclaredSecurityRoles();
@LogMessage(level = ERROR)
@Message(id = 15, value = "Cannot register endpoint: %s in JMX server")
void cannotRegisterEndpoint(Object endpoint);
@LogMessage(level = ERROR)
@Message(id = 16, value = "Cannot unregister endpoint: %s from JMX server")
void cannotUnregisterEndpoint(Object endpoint);
@LogMessage(level = WARN)
@Message(id = 17, value = "Invalid handler chain file: %s")
void invalidHandlerChainFile(String fileName);
String WS_SPEC_REF_5_3_2_4_2 = ". See section 5.3.2.4.2 of \"Jakarta Enterprise Web Services 2.0\".";
@LogMessage(level = ERROR)
@Message(id = 18, value = "Web service method %s must not be static or final" + WS_SPEC_REF_5_3_2_4_2)
void webMethodMustNotBeStaticOrFinal(Method staticWebMethod);
@LogMessage(level = ERROR)
@Message(id = 19, value = "Web service method %s must be public" + WS_SPEC_REF_5_3_2_4_2)
void webMethodMustBePublic(Method staticWebMethod);
@LogMessage(level = ERROR)
@Message(id = 20, value = "Web service implementation class %s does not contain method %s")
void webServiceMethodNotFound(Class<?> endpointClass, Method potentialWebMethod);
@LogMessage(level = ERROR)
@Message(id = 21, value = "Web service implementation class %s does not contain an accessible method %s")
void accessibleWebServiceMethodNotFound(Class<?> endpointClass, Method potentialWebMethod, @Cause SecurityException e);
@LogMessage(level = ERROR)
@Message(id = 22, value = "Web service implementation class %s may not declare a finalize() method"
+ WS_SPEC_REF_5_3_2_4_2)
void finalizeMethodNotAllowed(Class<?> seiClass);
@Message(id = 23, value = "Null endpoint name")
NullPointerException nullEndpointName();
@Message(id = 24, value = "Null endpoint class")
NullPointerException nullEndpointClass();
@Message(id = 25, value = "Cannot resolve module or classloader for deployment %s")
IllegalStateException classLoaderResolutionFailed(Object o);
@Message(id = 26, value = "Handler chain config file %s not found in %s")
WebServiceException missingHandlerChainConfigFile(String filePath, ResourceRoot resourceRoot);
@Message(id = 27, value = "Unexpected element: %s")
IllegalStateException unexpectedElement(String elementName);
@Message(id = 28, value = "Unexpected end tag: %s")
IllegalStateException unexpectedEndTag(String tagName);
@Message(id = 29, value = "Reached end of xml document unexpectedly")
IllegalStateException unexpectedEndOfDocument();
@Message(id = 30, value = "Could not find class attribute for deployment aspect")
IllegalStateException missingDeploymentAspectClassAttribute();
@Message(id = 31, value = "Could not create a deployment aspect of class: %s")
IllegalStateException cannotInstantiateDeploymentAspect(@Cause Throwable cause, String className);
@Message(id = 32, value = "Could not find property name attribute for deployment aspect: %s")
IllegalStateException missingPropertyNameAttribute(DeploymentAspect deploymentAspect);
@Message(id = 33, value = "Could not find property class attribute for deployment aspect: %s")
IllegalStateException missingPropertyClassAttribute(DeploymentAspect deploymentAspect);
@Message(id = 34, value = "Unsupported property class: %s")
IllegalArgumentException unsupportedPropertyClass(String className);
@Message(id = 35, value = "Could not create list of type: %s")
IllegalStateException cannotInstantiateList(@Cause Throwable cause, String className);
@Message(id = 36, value = "Could not create map of type: %s")
IllegalStateException cannotInstantiateMap(@Cause Throwable cause, String className);
@Message(id = 37, value = "No metrics available")
String noMetricsAvailable();
@Message(id = 38, value = "Cannot find component view: %s")
IllegalStateException cannotFindComponentView(ServiceName viewName);
@Message(id = 39, value = "Child '%s' not found for VirtualFile: %s")
IOException missingChild(String child, VirtualFile file);
@Message(id = 40, value = "Failed to create context")
Exception createContextPhaseFailed(@Cause Throwable cause);
@Message(id = 41, value = "Failed to start context")
Exception startContextPhaseFailed(@Cause Throwable cause);
@Message(id = 42, value = "Failed to stop context")
Exception stopContextPhaseFailed(@Cause Throwable cause);
@Message(id = 43, value = "Failed to destroy context")
Exception destroyContextPhaseFailed(@Cause Throwable cause);
@Message(id = 44, value = "Cannot create servlet delegate: %s")
IllegalStateException cannotInstantiateServletDelegate(@Cause Throwable cause, String className);
@Message(id = 45, value = "Cannot obtain deployment property: %s")
IllegalStateException missingDeploymentProperty(String propertyName);
@Message(id = 46, value = "Multiple security domains not supported. First domain: '%s' second domain: '%s'")
IllegalStateException multipleSecurityDomainsDetected(String firstDomain, String secondDomain);
@Message(id = 47, value = "Web Service endpoint %s with URL pattern %s is already registered. Web service endpoint %s is requesting the same URL pattern.")
IllegalArgumentException sameUrlPatternRequested(String firstClass, String urlPattern, String secondClass);
@Message(id = 48, value = "@WebServiceRef injection target is invalid. Only setter methods are allowed: %s")
DeploymentUnitProcessingException invalidServiceRefSetterMethodName(Object o);
@Message(id = 49, value = "@WebServiceRef attribute 'name' is required for class level annotations.")
DeploymentUnitProcessingException requiredServiceRefName();
@Message(id = 50, value = "@WebServiceRef attribute 'type' is required for class level annotations.")
DeploymentUnitProcessingException requiredServiceRefType();
@Message(id = 51, value = "Config %s doesn't exist")
OperationFailedException missingConfig(String configName);
@Message(id = 52, value = "Unsupported handler chain type: %s. Supported types are either %s or %s")
StartException wrongHandlerChainType(String unknownChainType, String knownChainType1, String knownChainType2);
// @Message(id = 53, value = "Cannot add new handler chain of type %s with id %s. This id is already used in config %s for another chain.")
// StartException multipleHandlerChainsWithSameId(String chainType, String handlerChainId, String configId);
@Message(id = 54, value = "Config %s: %s handler chain with id %s doesn't exist")
OperationFailedException missingHandlerChain(String configName, String handlerChainType, String handlerChainId);
// @Message(id = 55, value = "Config %s, %s handler chain %s: doesn't contain handler with name %s")
// OperationFailedException missingHandler(String configName, String handlerChainType, String handlerChainId, String handlerName);
//@LogMessage(level = ERROR)
//@Message(id = 56, value = "Method invocation failed with exception: %s")
//void methodInvocationFailed(@Cause Throwable cause, String message);
@Message(id = 57, value = "Unable to get URL for: %s")
DeploymentUnitProcessingException cannotGetURLForDescriptor(@Cause Throwable cause, String resourcePath);
@Message(id = 58, value = "Jakarta XML RPC not supported")
DeploymentUnitProcessingException jaxRpcNotSupported();
@Message(id = 59, value = "%s library (%s) detected in ws endpoint deployment; either provide a proper deployment replacing embedded libraries with container module "
+ "dependencies or disable the webservices subsystem for the current deployment adding a proper jboss-deployment-structure.xml descriptor to it. "
+ "The former approach is recommended, as the latter approach causes most of the webservices Jakarta EE and any JBossWS specific functionality to be disabled.")
DeploymentUnitProcessingException invalidLibraryInDeployment(String libraryName, String jar);
@Message(id = 60, value = "Web service endpoint class %s not found")
DeploymentUnitProcessingException endpointClassNotFound(String endpointClassName);
@Message(id = 61, value = "The endpointInterface %s declared in the @WebService annotation on web service implementation bean %s was not found.")
DeploymentUnitProcessingException declaredEndpointInterfaceClassNotFound(String endpointInterface, Class<?> endpointClass);
@Message(id = 62, value = "Class verification of Java Web Service implementation class %s failed.")
DeploymentUnitProcessingException jwsWebServiceClassVerificationFailed(Class<?> seiClass);
@Message(id = 63, value = "Could not update WS server configuration because of pending former model update(s) requiring reload.")
DisabledOperationException couldNotUpdateServerConfigBecauseOfReloadRequired();
@Message(id = 64, value = "Could not update WS server configuration because of existing WS deployment on the server.")
DisabledOperationException couldNotUpdateServerConfigBecauseOfExistingWSDeployment();
@LogMessage(level = WARN)
@Message(id = 65, value = "Annotation '@%s' found on class '%s'. Perhaps you forgot to add a '%s' module dependency to your deployment?")
void missingModuleDependency(String annotation, String clazz, String module);
@Message(id = 66, value = "Servlet class %s declared in web.xml; either provide a proper deployment relying on JBossWS or disable the webservices subsystem for the "
+ "current deployment adding a proper jboss-deployment-structure.xml descriptor to it. "
+ "The former approach is recommended, as the latter approach causes most of the webservices Jakarta EE and any JBossWS specific functionality to be disabled.")
WSFException invalidWSServlet(String servletClass);
@LogMessage(level = ERROR)
@Message(id = 67, value = "Could not activate the webservices subsystem.")
void couldNotActivateSubsystem(@Cause Throwable cause);
// @Message(id = 68, value = "Service %s not available")
// OperationFailedException serviceNotAvailable(String serviceName);
// @Message(id = 69, value = "String format password is required")
// IllegalArgumentException invalidPasswordType();
@LogMessage(level = DEBUG)
@Message(id = 70, value = "Authorization failed for user: %s")
void failedAuthorization(String username);
@LogMessage(level = DEBUG)
@Message(id = 71, value = "Failed to authenticate username %s:, incorrect username/password")
void failedAuthentication(final String username);
@LogMessage(level = DEBUG)
@Message(id = 72, value = "Error occured when authenticate username %s. Exception message: %s")
void failedAuthenticationWithException(@Cause final Throwable cause, final String username, final String message);
@Message(id = 73, value = "The target endpoint %s is undeploying or stopped" )
IllegalStateException endpointAlreadyStopped(String endpointName);
@LogMessage(level = WARN)
@Message(id = 68, value = "A potentially problematic %s library (%s) detected in ws endpoint deployment; Check if this library can be replaced with container module")
void warningLibraryInDeployment(String libraryName, String jar);
@Message(id = 74, value = "The deployment is configured to use legacy security which is no longer supported." )
IllegalStateException legacySecurityUnsupported();
}
| 16,661 | 50.267692 | 256 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/tomcat/WebMetaDataCreator.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.tomcat;
import java.util.Arrays;
import java.util.List;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.web.common.WarMetaData;
import org.jboss.as.webservices.config.ServerHostInfo;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.util.ASHelper;
import org.jboss.as.webservices.util.WebMetaDataHelper;
import org.jboss.metadata.ear.spec.EarMetaData;
import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
import org.jboss.metadata.merge.javaee.spec.SecurityRolesMetaDataMerger;
import org.jboss.metadata.web.jboss.JBossServletsMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.spec.LoginConfigMetaData;
import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
import org.jboss.metadata.web.spec.ServletMappingMetaData;
import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
import org.jboss.ws.common.integration.WSHelper;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.HttpEndpoint;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
final class WebMetaDataCreator {
private static final String EJB_WEBSERVICE_REALM = "EJBWebServiceEndpointServlet Realm";
private final SecurityMetaDataAccessorEJB ejb3SecurityAccessor = new SecurityMetaDataAccessorEJB3();
WebMetaDataCreator() {
super();
}
/**
* Creates web meta data for Jakarta Enterprise Beans deployments.
*
* @param dep webservice deployment
*/
void create(final Deployment dep) {
final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
WarMetaData warMD = ASHelper.getOptionalAttachment(unit, WarMetaData.ATTACHMENT_KEY);
JBossWebMetaData jbossWebMD = warMD != null ? warMD.getMergedJBossWebMetaData() : null;
if (warMD == null) {
warMD = new WarMetaData();
}
if (jbossWebMD == null) {
jbossWebMD = new JBossWebMetaData();
warMD.setMergedJBossWebMetaData(jbossWebMD);
unit.putAttachment(WarMetaData.ATTACHMENT_KEY, warMD);
}
createWebAppDescriptor(dep, jbossWebMD);
createJBossWebAppDescriptor(dep, jbossWebMD);
dep.addAttachment(JBossWebMetaData.class, jbossWebMD);
}
/**
* Creates web.xml descriptor meta data.
*
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
*/
private void createWebAppDescriptor(final Deployment dep, final JBossWebMetaData jbossWebMD) {
WSLogger.ROOT_LOGGER.trace("Creating web.xml descriptor");
createServlets(dep, jbossWebMD);
createServletMappings(dep, jbossWebMD);
createSecurityConstraints(dep, jbossWebMD);
createLoginConfig(dep, jbossWebMD);
createSecurityRoles(dep, jbossWebMD);
}
/**
* Creates jboss-web.xml descriptor meta data.
* <p/>
* <pre>
* <jboss-web>
* <security-domain>java:/jaas/custom-security-domain</security-domain>
* <context-root>/custom-context-root</context-root>
* <virtual-host>host1</virtual-host>
* ...
* <virtual-host>hostN</virtual-host>
* </jboss-web>
* </pre>
*
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
*/
private void createJBossWebAppDescriptor(final Deployment dep, final JBossWebMetaData jbossWebMD) {
WSLogger.ROOT_LOGGER.trace("Creating jboss-web.xml descriptor");
// Set security domain
final String securityDomain = ejb3SecurityAccessor.getSecurityDomain(dep);
final boolean hasSecurityDomain = securityDomain != null;
if (hasSecurityDomain) {
WSLogger.ROOT_LOGGER.tracef("Setting security domain: %s", securityDomain);
jbossWebMD.setSecurityDomain(securityDomain);
}
// Set virtual host
final String virtualHost = dep.getService().getVirtualHost();
ServerHostInfo serverHostInfo = new ServerHostInfo(virtualHost);
if (serverHostInfo.getHost() != null) {
WSLogger.ROOT_LOGGER.tracef("Setting virtual host: %s", serverHostInfo.getHost());
jbossWebMD.setVirtualHosts(Arrays.asList(serverHostInfo.getHost()));
if (serverHostInfo.getServerInstanceName() != null) {
jbossWebMD.setServerInstanceName(serverHostInfo.getServerInstanceName());
}
}
}
/**
* Creates servlets part of web.xml descriptor.
* <p/>
* <pre>
* <servlet>
* <servlet-name>EJBEndpointShortName</servlet-name>
* <servlet-class>EJBEndpointTargetBeanName</servlet-class>
* </servlet>
* </pre>
*
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
*/
private void createServlets(final Deployment dep, final JBossWebMetaData jbossWebMD) {
WSLogger.ROOT_LOGGER.trace("Creating servlets");
final JBossServletsMetaData servlets = WebMetaDataHelper.getServlets(jbossWebMD);
for (final Endpoint endpoint : dep.getService().getEndpoints()) {
final String endpointName = endpoint.getShortName();
final String endpointClassName = endpoint.getTargetBeanName();
WSLogger.ROOT_LOGGER.tracef("Servlet name: %s, class: %s", endpointName, endpointClassName);
WebMetaDataHelper.newServlet(endpointName, endpointClassName, servlets);
}
}
/**
* Creates servlet-mapping part of web.xml descriptor.
* <p/>
* <pre>
* <servlet-mapping>
* <servlet-name>EJBEndpointShortName</servlet-name>
* <url-pattern>EJBEndpointURLPattern</url-pattern>
* </servlet-mapping>
* </pre>
*
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
*/
private void createServletMappings(final Deployment dep, final JBossWebMetaData jbossWebMD) {
WSLogger.ROOT_LOGGER.trace("Creating servlet mappings");
final List<ServletMappingMetaData> servletMappings = WebMetaDataHelper.getServletMappings(jbossWebMD);
for (final Endpoint ep : dep.getService().getEndpoints()) {
if (ep instanceof HttpEndpoint) {
final String endpointName = ep.getShortName();
final List<String> urlPatterns = WebMetaDataHelper.getUrlPatterns(((HttpEndpoint) ep).getURLPattern());
WSLogger.ROOT_LOGGER.tracef("Servlet name: %s, URL patterns: %s", endpointName, urlPatterns);
WebMetaDataHelper.newServletMapping(endpointName, urlPatterns, servletMappings);
}
}
}
/**
* Creates security constraints part of web.xml descriptor.
* <p/>
* <pre>
* <security-constraint>
* <web-resource-collection>
* <web-resource-name>EJBEndpointShortName</web-resource-name>
* <url-pattern>EJBEndpointURLPattern</url-pattern>
* <http-method>GET</http-method>
* <http-method>POST</http-method>
* </web-resource-collection>
* <auth-constraint>
* <role-name>*</role-name>
* </auth-constraint>
* <user-data-constraint>
* <transport-guarantee>EjbTransportGuarantee</transport-guarantee>
* </user-data-constraint>
* </security-constraint>
* </pre>
*
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
*/
private void createSecurityConstraints(final Deployment dep, final JBossWebMetaData jbossWebMD) {
WSLogger.ROOT_LOGGER.trace("Creating security constraints");
for (final Endpoint ejbEndpoint : dep.getService().getEndpoints()) {
final boolean secureWsdlAccess = ejb3SecurityAccessor.isSecureWsdlAccess(ejbEndpoint);
final String transportGuarantee = ejb3SecurityAccessor.getTransportGuarantee(ejbEndpoint);
final boolean hasTransportGuarantee = transportGuarantee != null;
final String authMethod = ejb3SecurityAccessor.getAuthMethod(ejbEndpoint);
final boolean hasAuthMethod = authMethod != null;
if (ejbEndpoint instanceof HttpEndpoint && (hasAuthMethod || hasTransportGuarantee)) {
final List<SecurityConstraintMetaData> securityConstraints = WebMetaDataHelper
.getSecurityConstraints(jbossWebMD);
// security-constraint
final SecurityConstraintMetaData securityConstraint = WebMetaDataHelper
.newSecurityConstraint(securityConstraints);
// web-resource-collection
final WebResourceCollectionsMetaData webResourceCollections = WebMetaDataHelper
.getWebResourceCollections(securityConstraint);
final String endpointName = ejbEndpoint.getShortName();
final String urlPattern = ((HttpEndpoint) ejbEndpoint).getURLPattern();
WSLogger.ROOT_LOGGER.tracef("Creating web resource collection for endpoint: %s, URL pattern: %s", endpointName, urlPattern);
WebMetaDataHelper.newWebResourceCollection(endpointName, urlPattern, secureWsdlAccess,
webResourceCollections);
// auth-constraint
if (hasAuthMethod) {
WSLogger.ROOT_LOGGER.tracef("Creating auth constraint for endpoint: %s", endpointName);
WebMetaDataHelper.newAuthConstraint(WebMetaDataHelper.getAllRoles(), securityConstraint);
}
// user-data-constraint
if (hasTransportGuarantee) {
WSLogger.ROOT_LOGGER.tracef("Creating new user data constraint for endpoint: %s, transport guarantee: %s", endpointName, transportGuarantee);
WebMetaDataHelper.newUserDataConstraint(transportGuarantee, securityConstraint);
}
}
}
}
/**
* Creates login-config part of web.xml descriptor.
* <p/>
* <pre>
* <login-config>
* <auth-method>EjbDeploymentAuthMethod</auth-method>
* <realm-name>EJBWebServiceEndpointServlet Realm</realm-name>
* </login-config>
* </pre>
*
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
*/
private void createLoginConfig(final Deployment dep, final JBossWebMetaData jbossWebMD) {
final String authMethod = getAuthMethod(dep);
final boolean hasAuthMethod = authMethod != null;
final String realmName = getRealmName(dep);
if (hasAuthMethod) {
WSLogger.ROOT_LOGGER.tracef("Creating new login config: %s, auth method: %s", EJB_WEBSERVICE_REALM, authMethod);
final LoginConfigMetaData loginConfig = WebMetaDataHelper.getLoginConfig(jbossWebMD);
if (realmName != null) {
loginConfig.setRealmName(realmName);
} else {
loginConfig.setRealmName(WebMetaDataCreator.EJB_WEBSERVICE_REALM);
}
loginConfig.setAuthMethod(authMethod);
}
}
/**
* Creates security roles part of web.xml descriptor.
* <p/>
* <pre>
* <security-role>
* <role-name>role1</role-name>
* ...
* <role-name>roleN</role-name>
* </security-role>
* </pre>
*
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
*/
private void createSecurityRoles(final Deployment dep, final JBossWebMetaData jbossWebMD) {
final String authMethod = getAuthMethod(dep);
final boolean hasAuthMethod = authMethod != null;
if (hasAuthMethod) {
final SecurityRolesMetaData securityRolesMD = ejb3SecurityAccessor.getSecurityRoles(dep);
final boolean hasSecurityRolesMD = securityRolesMD != null && !securityRolesMD.isEmpty();
if (hasSecurityRolesMD) {
WSLogger.ROOT_LOGGER.trace("Setting security roles");
jbossWebMD.setSecurityRoles(securityRolesMD);
}
}
//merge security roles from the ear
//TODO: is there somewhere better to put this?
final DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class);
DeploymentUnit parent = unit.getParent();
if (parent != null) {
final EarMetaData earMetaData = parent.getAttachment(org.jboss.as.ee.structure.Attachments.EAR_METADATA);
if (earMetaData != null) {
if (jbossWebMD.getSecurityRoles() == null) {
jbossWebMD.setSecurityRoles(new SecurityRolesMetaData());
}
SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles();
if (earSecurityRolesMetaData != null) {
SecurityRolesMetaDataMerger.merge(jbossWebMD.getSecurityRoles(), jbossWebMD.getSecurityRoles(), earSecurityRolesMetaData);
}
}
}
}
/**
* Returns deployment authentication method.
*
* @param dep webservice deployment
* @return deployment authentication method
*/
private String getAuthMethod(final Deployment dep) {
for (final Endpoint ejbEndpoint : dep.getService().getEndpoints()) {
final String beanAuthMethod = ejb3SecurityAccessor.getAuthMethod(ejbEndpoint);
final boolean hasBeanAuthMethod = beanAuthMethod != null;
if (hasBeanAuthMethod) {
// First found auth-method defines war
// login-config/auth-method
return beanAuthMethod;
}
}
return null;
}
private String getRealmName(final Deployment dep) {
for (final Endpoint ejbEndpoint : dep.getService().getEndpoints()) {
final String realmName = ejb3SecurityAccessor.getRealmName(ejbEndpoint);
final boolean hasRealmName = realmName != null;
if (hasRealmName) {
return realmName;
}
}
return null;
}
}
| 15,638 | 41.382114 | 162 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/tomcat/AbstractSecurityMetaDataAccessorEJB.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.tomcat;
import java.util.List;
import java.util.Set;
import org.jboss.as.ee.structure.Attachments;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.metadata.model.EJBEndpoint;
import org.jboss.metadata.ear.jboss.JBossAppMetaData;
import org.jboss.metadata.ear.spec.EarMetaData;
import org.jboss.metadata.javaee.spec.SecurityRoleMetaData;
import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
import org.jboss.ws.common.integration.WSHelper;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
import org.jboss.wsf.spi.metadata.j2ee.EJBSecurityMetaData;
/**
* Creates web app security meta data for Jakarta Enterprise Beans deployment.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Thomas Diesler</a>
*/
abstract class AbstractSecurityMetaDataAccessorEJB implements SecurityMetaDataAccessorEJB {
/**
* @see org.jboss.webservices.integration.tomcat.AbstractSecurityMetaDataAccessorEJB#getSecurityDomain(Deployment)
*
* @param dep webservice deployment
* @return security domain associated with Enterprise Beans 3 deployment
*/
public String getSecurityDomain(final Deployment dep) {
String securityDomain = null;
for (final EJBEndpoint ejbEndpoint : getEjbEndpoints(dep)) {
String nextSecurityDomain = ejbEndpoint.getSecurityDomain();
if (nextSecurityDomain == null || nextSecurityDomain.isEmpty()) {
nextSecurityDomain = null;
}
securityDomain = getDomain(securityDomain, nextSecurityDomain);
}
if (securityDomain == null) {
final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
if (unit.getParent() != null) {
final EarMetaData jbossAppMD = unit.getParent().getAttachment(Attachments.EAR_METADATA);
return jbossAppMD instanceof JBossAppMetaData ? ((JBossAppMetaData)jbossAppMD).getSecurityDomain() : null;
}
}
return securityDomain;
}
public SecurityRolesMetaData getSecurityRoles(final Deployment dep) {
final SecurityRolesMetaData securityRolesMD = new SecurityRolesMetaData();
Set<String> firstEndpointDeclaredSecurityRoles = null;
for (final EJBEndpoint ejbEndpoint : getEjbEndpoints(dep)) {
final Set<String> declaredSecurityRoles = ejbEndpoint.getDeclaredSecurityRoles();
if (firstEndpointDeclaredSecurityRoles == null) {
firstEndpointDeclaredSecurityRoles = declaredSecurityRoles;
} else if (!firstEndpointDeclaredSecurityRoles.equals(declaredSecurityRoles)) {
WSLogger.ROOT_LOGGER.multipleEndpointsWithDifferentDeclaredSecurityRoles();
}
//union of declared security roles from all endpoints...
for (final String roleName : declaredSecurityRoles) {
final SecurityRoleMetaData securityRoleMD = new SecurityRoleMetaData();
securityRoleMD.setRoleName(roleName);
securityRolesMD.add(securityRoleMD);
}
}
return securityRolesMD;
}
protected abstract List<EJBEndpoint> getEjbEndpoints(final Deployment dep);
/**
* @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#getAuthMethod(Endpoint)
*
* @param endpoint Jakarta Enterprise Beans webservice endpoint
* @return authentication method or null if not specified
*/
public String getAuthMethod(final Endpoint endpoint) {
final EJBSecurityMetaData ejbSecurityMD = this.getEjbSecurityMetaData(endpoint);
final boolean hasEjbSecurityMD = ejbSecurityMD != null;
return hasEjbSecurityMD ? ejbSecurityMD.getAuthMethod() : null;
}
/**
* @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#isSecureWsdlAccess(Endpoint)
*
* @param endpoint Jakarta Enterprise Beans webservice endpoint
* @return whether WSDL access have to be secured
*/
public boolean isSecureWsdlAccess(final Endpoint endpoint) {
final EJBSecurityMetaData ejbSecurityMD = this.getEjbSecurityMetaData(endpoint);
final boolean hasEjbSecurityMD = ejbSecurityMD != null;
return hasEjbSecurityMD ? ejbSecurityMD.getSecureWSDLAccess() : false;
}
/**
* @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#getTransportGuarantee(Endpoint)
*
* @param endpoint Jakarta Enterprise Beans webservice endpoint
* @return transport guarantee or null if not specified
*/
public String getTransportGuarantee(final Endpoint endpoint) {
final EJBSecurityMetaData ejbSecurityMD = this.getEjbSecurityMetaData(endpoint);
final boolean hasEjbSecurityMD = ejbSecurityMD != null;
return hasEjbSecurityMD ? ejbSecurityMD.getTransportGuarantee() : null;
}
public String getRealmName(final Endpoint endpoint) {
final EJBSecurityMetaData ejbSecurityMD = this.getEjbSecurityMetaData(endpoint);
final boolean hasEjbSecurityMD = ejbSecurityMD != null;
return hasEjbSecurityMD ? ejbSecurityMD.getRealmName() : null;
}
/**
* Gets Jakarta Enterprise Beans security meta data if associated with Jakarta Enterprise Beans endpoint.
*
* @param endpoint EJB webservice endpoint
* @return EJB security meta data or null
*/
private EJBSecurityMetaData getEjbSecurityMetaData(final Endpoint endpoint) {
final String ejbName = endpoint.getShortName();
final Deployment dep = endpoint.getService().getDeployment();
final EJBArchiveMetaData ejbArchiveMD = WSHelper.getOptionalAttachment(dep, EJBArchiveMetaData.class);
final EJBMetaData ejbMD = ejbArchiveMD != null ? ejbArchiveMD.getBeanByEjbName(ejbName) : null;
return ejbMD != null ? ejbMD.getSecurityMetaData() : null;
}
/**
* Returns security domain value. This method checks domain is the same for every Enterprise Beans 3 endpoint.
*
* @param oldSecurityDomain our security domain
* @param nextSecurityDomain next security domain
* @return security domain value
* @throws IllegalStateException if domains have different values
*/
private String getDomain(final String oldSecurityDomain, final String nextSecurityDomain) {
if (nextSecurityDomain == null) {
return oldSecurityDomain;
}
if (oldSecurityDomain == null) {
return nextSecurityDomain;
}
ensureSameDomains(oldSecurityDomain, nextSecurityDomain);
return oldSecurityDomain;
}
/**
* This method ensures both passed domains contain the same value.
*
* @param oldSecurityDomain our security domain
* @param newSecurityDomain next security domain
* @throws IllegalStateException if domains have different values
*/
private void ensureSameDomains(final String oldSecurityDomain, final String newSecurityDomain) {
final boolean domainsDiffer = !oldSecurityDomain.equals(newSecurityDomain);
if (domainsDiffer)
throw WSLogger.ROOT_LOGGER.multipleSecurityDomainsDetected(oldSecurityDomain, newSecurityDomain);
}
}
| 8,605 | 42.464646 | 122 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/tomcat/WebMetaDataModifier.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.tomcat;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.util.ASHelper;
import org.jboss.as.webservices.util.WebMetaDataHelper;
import org.jboss.metadata.javaee.spec.ParamValueMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.spec.ServletMetaData;
import org.jboss.ws.common.integration.WSConstants;
import org.jboss.ws.common.integration.WSHelper;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.WSFServlet;
/**
* The modifier of jboss web meta data. It configures WS transport for every webservice endpoint plus propagates WS stack
* specific context parameters if required.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Thomas Diesler</a>
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
*/
final class WebMetaDataModifier {
WebMetaDataModifier() {
super();
}
/**
* Modifies web meta data to configure webservice stack transport and properties.
*
* @param dep webservice deployment
*/
void modify(final Deployment dep) {
final JBossWebMetaData jbossWebMD = WSHelper.getOptionalAttachment(dep, JBossWebMetaData.class);
if (jbossWebMD != null) {
this.configureEndpoints(dep, jbossWebMD);
this.modifyContextRoot(dep, jbossWebMD);
}
}
/**
* Configures transport servlet class for every found webservice endpoint.
*
* @param dep webservice deployment
* @param jbossWebMD web meta data
*/
private void configureEndpoints(final Deployment dep, final JBossWebMetaData jbossWebMD) {
final String transportClassName = this.getTransportClassName(dep);
WSLogger.ROOT_LOGGER.trace("Modifying servlets");
// get a list of the endpoint bean class names
final Set<String> epNames = new HashSet<String>();
for (Endpoint ep : dep.getService().getEndpoints()) {
epNames.add(ep.getTargetBeanName());
}
// fix servlet class names for endpoints
for (final ServletMetaData servletMD : jbossWebMD.getServlets()) {
final String endpointClassName = ASHelper.getEndpointClassName(servletMD);
if (endpointClassName != null && endpointClassName.length() > 0) { // exclude Jakarta Server Pages
if (epNames.contains(endpointClassName)) {
// set transport servlet
servletMD.setServletClass(WSFServlet.class.getName());
WSLogger.ROOT_LOGGER.tracef("Setting transport class: %s for endpoint: %s", transportClassName, endpointClassName);
final List<ParamValueMetaData> initParams = WebMetaDataHelper.getServletInitParams(servletMD);
// configure transport class name
WebMetaDataHelper.newParamValue(WSFServlet.STACK_SERVLET_DELEGATE_CLASS, transportClassName, initParams);
// configure webservice endpoint
WebMetaDataHelper.newParamValue(Endpoint.SEPID_DOMAIN_ENDPOINT, endpointClassName, initParams);
} else if (endpointClassName.startsWith("org.apache.cxf")) {
throw WSLogger.ROOT_LOGGER.invalidWSServlet(endpointClassName);
}
}
}
}
/**
* Modifies context root.
*
* @param dep webservice deployment
* @param jbossWebMD web meta data
*/
private void modifyContextRoot(final Deployment dep, final JBossWebMetaData jbossWebMD) {
final String contextRoot = dep.getService().getContextRoot();
if (WSLogger.ROOT_LOGGER.isTraceEnabled()) {
WSLogger.ROOT_LOGGER.tracef("Setting context root: %s for deployment: %s", contextRoot, dep.getSimpleName());
}
jbossWebMD.setContextRoot(contextRoot);
}
/**
* Returns stack specific transport class name.
*
* @param dep webservice deployment
* @return stack specific transport class name
* @throws IllegalStateException if transport class name is not found in deployment properties map
*/
private String getTransportClassName(final Deployment dep) {
String transportClassName = (String) dep.getProperty(WSConstants.STACK_TRANSPORT_CLASS);
if (transportClassName == null) throw WSLogger.ROOT_LOGGER.missingDeploymentProperty(WSConstants.STACK_TRANSPORT_CLASS);
return transportClassName;
}
}
| 5,728 | 42.401515 | 135 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/tomcat/SecurityMetaDataAccessorEJB3.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.tomcat;
import java.util.List;
import org.jboss.as.webservices.metadata.model.EJBEndpoint;
import org.jboss.as.webservices.metadata.model.JAXWSDeployment;
import org.jboss.ws.common.integration.WSHelper;
import org.jboss.wsf.spi.deployment.Deployment;
/**
* Creates web app security meta data for EJB 3 deployment.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
final class SecurityMetaDataAccessorEJB3 extends AbstractSecurityMetaDataAccessorEJB {
@Override
protected List<EJBEndpoint> getEjbEndpoints(final Deployment dep) {
final JAXWSDeployment jaxwsDeployment = WSHelper.getRequiredAttachment(dep, JAXWSDeployment.class);
return jaxwsDeployment.getEjbEndpoints();
}
}
| 1,798 | 38.977778 | 107 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/tomcat/WebMetaDataModifyingDeploymentAspect.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.tomcat;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.ws.common.integration.AbstractDeploymentAspect;
import org.jboss.wsf.spi.deployment.Deployment;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class WebMetaDataModifyingDeploymentAspect extends AbstractDeploymentAspect {
private WebMetaDataModifier webMetaDataModifier = new WebMetaDataModifier();
@Override
public void start(final Deployment dep) {
if (WSLogger.ROOT_LOGGER.isTraceEnabled()) {
WSLogger.ROOT_LOGGER.tracef("Modifying web meta data for webservice deployment: %s", dep.getSimpleName());
}
webMetaDataModifier.modify(dep);
}
}
| 1,778 | 39.431818 | 118 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/tomcat/ServletDelegateFactoryImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.tomcat;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
import org.jboss.wsf.spi.deployment.ServletDelegate;
import org.jboss.wsf.spi.deployment.ServletDelegateFactory;
/**
* WildFly implementation of {@link org.jboss.wsf.spi.deployment.ServletDelegateFactory}
* that uses modular classloading for creating the delegate instance.
*
* @author [email protected]
* @since 06-Apr-2011
*
*/
public final class ServletDelegateFactoryImpl implements ServletDelegateFactory {
@Override
public ServletDelegate newServletDelegate(final String servletClassName) {
final ClassLoaderProvider provider = ClassLoaderProvider.getDefaultProvider();
try {
final Class<?> clazz = provider.getServerIntegrationClassLoader().loadClass(servletClassName);
return (ServletDelegate) clazz.newInstance();
} catch (final Exception e) {
throw WSLogger.ROOT_LOGGER.cannotInstantiateServletDelegate(e, servletClassName);
}
}
}
| 2,122 | 40.627451 | 106 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/tomcat/WebMetaDataCreatingDeploymentAspect.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.tomcat;
import static org.jboss.ws.common.integration.WSHelper.isEjbDeployment;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.ws.common.integration.AbstractDeploymentAspect;
import org.jboss.wsf.spi.deployment.Deployment;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class WebMetaDataCreatingDeploymentAspect extends AbstractDeploymentAspect {
private WebMetaDataCreator webMetaDataCreator = new WebMetaDataCreator();
@Override
public void start(final Deployment dep) {
if (isEjbDeployment(dep)) {
if (WSLogger.ROOT_LOGGER.isTraceEnabled()) {
WSLogger.ROOT_LOGGER.tracef("Creating web meta data for EJB webservice deployment: %s", dep.getSimpleName());
}
webMetaDataCreator.create(dep);
}
}
}
| 1,911 | 38.833333 | 125 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/tomcat/SecurityMetaDataAccessorEJB.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.tomcat;
import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
/**
* Creates web app security meta data for Jakarta Enterprise Beans deployments.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Thomas Diesler</a>
*/
interface SecurityMetaDataAccessorEJB {
/**
* Obtains security domain from Jakarta Enterprise Beans deployment.
*
* @param dep webservice deployment
* @return security domain associated with Jakarta Enterprise Beans deployment
*/
String getSecurityDomain(Deployment dep);
/**
* Obtains security roles from Jakarta Enterprise Beans deployment.
*
* @param dep webservice deployment
* @return security roles associated with Jakarta Enterprise Beans deployment
*/
SecurityRolesMetaData getSecurityRoles(Deployment dep);
/**
* Whether WSDL access have to be secured.
*
* @param endpoint webservice Jakarta Enterprise Beans endpoint
* @return authentication method or null if not specified
*/
boolean isSecureWsdlAccess(Endpoint endpoint);
/**
* Gets Jakarta Enterprise Beans authentication method.
*
* @param endpoint webservice Jakarta Enterprise Beans endpoint
* @return authentication method or null if not specified
*/
String getAuthMethod(Endpoint endpoint);
/**
* Gets Jakarta Enterprise Beans transport guarantee.
*
* @param endpoint webservice Jakarta Enterprise Beans endpoint
* @return transport guarantee or null if not specified
*/
String getTransportGuarantee(Endpoint endpoint);
/**
* Gets realm name for protect resource
*
* @param endpoint webservice Jakarta Enterprise Beans endpoint
* @return realm name or null if not specified
*/
String getRealmName(Endpoint endpoint);
}
| 3,043 | 36.121951 | 82 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/util/ServiceContainerEndpointRegistry.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.util;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import javax.management.ObjectName;
import org.jboss.msc.service.ServiceName;
import org.jboss.ws.common.ObjectNameFactory;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.management.EndpointRegistry;
import org.jboss.wsf.spi.management.EndpointResolver;
/**
* @author <a href="mailto:[email protected]">Jim Ma</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public class ServiceContainerEndpointRegistry implements EndpointRegistry {
private static final Map<ServiceName, Endpoint> endpoints = new ConcurrentHashMap<>();
@Override
public Set<ObjectName> getEndpoints() {
String contextPath;
String endpointName;
StringBuilder name;
final Set<ObjectName> retVal = new CopyOnWriteArraySet<>();
for (final ServiceName sname : endpoints.keySet()) {
contextPath = sname.getParent().getSimpleName().substring(8);
endpointName = sname.getSimpleName();
name = new StringBuilder(Endpoint.SEPID_DOMAIN + ":");
name.append(Endpoint.SEPID_PROPERTY_CONTEXT + "=").append(contextPath).append(",");
name.append(Endpoint.SEPID_PROPERTY_ENDPOINT + "=").append(endpointName);
retVal.add(ObjectNameFactory.create(name.toString()));
}
return retVal;
}
@Override
public Endpoint getEndpoint(final ObjectName epName) {
final String context = epName.getKeyProperty(Endpoint.SEPID_PROPERTY_CONTEXT);
final String name = epName.getKeyProperty(Endpoint.SEPID_PROPERTY_ENDPOINT);
final ServiceName endpointName = WSServices.ENDPOINT_SERVICE.append("context=" + context).append(name);
return getEndpoint(endpointName);
}
@Override
public Endpoint resolve(final EndpointResolver resolver) {
return resolver.query(new CopyOnWriteArraySet<>(endpoints.values()).iterator());
}
@Override
public boolean isRegistered(final ObjectName epName) {
return getEndpoint(epName) != null;
}
public static void register(final ServiceName endpointName, final Endpoint endpoint) {
endpoints.put(endpointName, endpoint);
}
public static void unregister(final ServiceName endpointName, final Endpoint endpoint) {
endpoints.remove(endpointName, endpoint);
}
public static Endpoint getEndpoint(final ServiceName endpointName) {
return endpoints.get(endpointName);
}
}
| 3,656 | 38.75 | 111 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/util/WebMetaDataHelper.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.util;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.jboss.metadata.javaee.spec.ParamValueMetaData;
import org.jboss.metadata.web.jboss.JBossServletMetaData;
import org.jboss.metadata.web.jboss.JBossServletsMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.spec.AuthConstraintMetaData;
import org.jboss.metadata.web.spec.LoginConfigMetaData;
import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
import org.jboss.metadata.web.spec.ServletMappingMetaData;
import org.jboss.metadata.web.spec.ServletMetaData;
import org.jboss.metadata.web.spec.TransportGuaranteeType;
import org.jboss.metadata.web.spec.UserDataConstraintMetaData;
import org.jboss.metadata.web.spec.WebResourceCollectionMetaData;
import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
/**
* Utility class that simplifies work with JBossWebMetaData object structure.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Thomas Diesler</a>
*/
public final class WebMetaDataHelper {
/** Star utility string. */
private static final String STAR_STRING = "*";
/** GET http method utility string. */
private static final String GET_STRING = "GET";
/** POST http method utility string. */
private static final String POST_STRING = "POST";
/** GET and POST methods utility list. */
private static List<String> getAndPostMethods;
/** POST method utility list. */
private static List<String> onlyPostMethod;
/** All roles utility list. */
private static List<String> allRoles;
static {
final List<String> getAndPostList = new LinkedList<String>();
getAndPostList.add(WebMetaDataHelper.GET_STRING);
getAndPostList.add(WebMetaDataHelper.POST_STRING);
WebMetaDataHelper.getAndPostMethods = Collections.unmodifiableList(getAndPostList);
final List<String> onlyPostList = new LinkedList<String>();
onlyPostList.add(WebMetaDataHelper.POST_STRING);
WebMetaDataHelper.onlyPostMethod = Collections.unmodifiableList(onlyPostList);
final List<String> roleNamesList = new LinkedList<String>();
roleNamesList.add(WebMetaDataHelper.STAR_STRING);
WebMetaDataHelper.allRoles = Collections.unmodifiableList(roleNamesList);
}
/**
* Constructor.
*/
private WebMetaDataHelper() {
super();
}
/**
* Creates URL pattern list from passed string.
*
* @param urlPattern URL pattern
* @return list wrapping passed parameter
*/
public static List<String> getUrlPatterns(final String urlPattern) {
final List<String> linkedList = new LinkedList<String>();
linkedList.add(urlPattern);
return linkedList;
}
/**
* If WSDL access is secured, it returns both POST and GET methods, otherwise only POST method.
*
* @param secureWsdlAccess whether WSDL is secured
* @return web access methods
*/
public static List<String> getHttpMethods(final boolean secureWsdlAccess) {
return secureWsdlAccess ? WebMetaDataHelper.getAndPostMethods : WebMetaDataHelper.onlyPostMethod;
}
/**
* Returns all role list.
*
* @return all role list
*/
public static List<String> getAllRoles() {
return WebMetaDataHelper.allRoles;
}
/**
* Gets servlets meta data from jboss web meta data. If not found it creates new servlets meta data and associates them
* with jboss web meta data.
*
* @param jbossWebMD jboss web meta data
* @return servlets meta data
*/
public static JBossServletsMetaData getServlets(final JBossWebMetaData jbossWebMD) {
JBossServletsMetaData servletsMD = jbossWebMD.getServlets();
if (servletsMD == null) {
servletsMD = new JBossServletsMetaData();
jbossWebMD.setServlets(servletsMD);
}
return servletsMD;
}
/**
* Gets servlet mappings meta data from jboss web meta data. If not found it creates new servlet mappings meta data and
* associates them with jboss web meta data.
*
* @param jbossWebMD jboss web meta data
* @return servlet mappings meta data
*/
public static List<ServletMappingMetaData> getServletMappings(final JBossWebMetaData jbossWebMD) {
List<ServletMappingMetaData> servletMappingsMD = jbossWebMD.getServletMappings();
if (servletMappingsMD == null) {
servletMappingsMD = new LinkedList<ServletMappingMetaData>();
jbossWebMD.setServletMappings(servletMappingsMD);
}
return servletMappingsMD;
}
/**
* Gets security constraints meta data from jboss web meta data. If not found it creates new security constraints meta data
* and associates them with jboss web meta data.
*
* @param jbossWebMD jboss web meta data
* @return security constraints meta data
*/
public static List<SecurityConstraintMetaData> getSecurityConstraints(final JBossWebMetaData jbossWebMD) {
List<SecurityConstraintMetaData> securityConstraintsMD = jbossWebMD.getSecurityConstraints();
if (securityConstraintsMD == null) {
securityConstraintsMD = new LinkedList<SecurityConstraintMetaData>();
jbossWebMD.setSecurityConstraints(securityConstraintsMD);
}
return securityConstraintsMD;
}
/**
* Gets login config meta data from jboss web meta data. If not found it creates new login config meta data and associates
* them with jboss web meta data.
*
* @param jbossWebMD jboss web meta data
* @return login config meta data
*/
public static LoginConfigMetaData getLoginConfig(final JBossWebMetaData jbossWebMD) {
LoginConfigMetaData loginConfigMD = jbossWebMD.getLoginConfig();
if (loginConfigMD == null) {
loginConfigMD = new LoginConfigMetaData();
jbossWebMD.setLoginConfig(loginConfigMD);
}
return loginConfigMD;
}
/**
* Gets context parameters meta data from jboss web meta data. If not found it creates new context parameters meta data and
* associates them with jboss web meta data.
*
* @param jbossWebMD jboss web meta data
* @return context parameters meta data
*/
public static List<ParamValueMetaData> getContextParams(final JBossWebMetaData jbossWebMD) {
List<ParamValueMetaData> contextParamsMD = jbossWebMD.getContextParams();
if (contextParamsMD == null) {
contextParamsMD = new LinkedList<ParamValueMetaData>();
jbossWebMD.setContextParams(contextParamsMD);
}
return contextParamsMD;
}
/**
* Gets web resource collections meta data from security constraint meta data. If not found it creates new web resource
* collections meta data and associates them with security constraint meta data.
*
* @param securityConstraintMD security constraint meta data
* @return web resource collections meta data
*/
public static WebResourceCollectionsMetaData getWebResourceCollections(final SecurityConstraintMetaData securityConstraintMD) {
WebResourceCollectionsMetaData webResourceCollectionsMD = securityConstraintMD.getResourceCollections();
if (webResourceCollectionsMD == null) {
webResourceCollectionsMD = new WebResourceCollectionsMetaData();
securityConstraintMD.setResourceCollections(webResourceCollectionsMD);
}
return webResourceCollectionsMD;
}
/**
* Gets init parameters meta data from servlet meta data. If not found it creates new init parameters meta data and
* associates them with servlet meta data.
*
* @param servletMD servlet meta data
* @return init parameters meta data
*/
public static List<ParamValueMetaData> getServletInitParams(final ServletMetaData servletMD) {
List<ParamValueMetaData> initParamsMD = servletMD.getInitParam();
if (initParamsMD == null) {
initParamsMD = new LinkedList<ParamValueMetaData>();
servletMD.setInitParam(initParamsMD);
}
return initParamsMD;
}
/**
* Creates new security constraint meta data and associates them with security constraints meta data.
*
* @param securityConstraintsMD security constraints meta data
* @return new security constraing meta data
*/
public static SecurityConstraintMetaData newSecurityConstraint(final List<SecurityConstraintMetaData> securityConstraintsMD) {
final SecurityConstraintMetaData securityConstraintMD = new SecurityConstraintMetaData();
securityConstraintsMD.add(securityConstraintMD);
return securityConstraintMD;
}
/**
* Creates new web resource collection meta data and associates them with web resource collections meta data.
*
* @param servletName servlet name
* @param urlPattern URL pattern
* @param securedWsdl whether WSDL access is secured
* @param webResourceCollectionsMD web resource collections meta data
* @return new web resource collection meta data
*/
public static WebResourceCollectionMetaData newWebResourceCollection(final String servletName, final String urlPattern,
final boolean securedWsdl, final WebResourceCollectionsMetaData webResourceCollectionsMD) {
final WebResourceCollectionMetaData webResourceCollectionMD = new WebResourceCollectionMetaData();
webResourceCollectionMD.setWebResourceName(servletName);
webResourceCollectionMD.setUrlPatterns(WebMetaDataHelper.getUrlPatterns(urlPattern));
webResourceCollectionMD.setHttpMethods(WebMetaDataHelper.getHttpMethods(securedWsdl));
webResourceCollectionsMD.add(webResourceCollectionMD);
return webResourceCollectionMD;
}
/**
* Creates new servlet meta data and associates them with servlets meta data.
*
* @param servletName servlet name
* @param servletClass servlet class name
* @param servletsMD servlets meta data
* @return new servlet meta data
*/
public static JBossServletMetaData newServlet(final String servletName, final String servletClass,
final JBossServletsMetaData servletsMD) {
final JBossServletMetaData servletMD = new JBossServletMetaData();
servletMD.setServletName(servletName);
servletMD.setServletClass(servletClass);
servletsMD.add(servletMD);
return servletMD;
}
/**
* Creates new servlet mapping meta data and associates them with servlet mappings meta data.
*
* @param servletName servlet name
* @param urlPatterns URL patterns
* @param servletMappingsMD servlet mapping meta data
* @return new servlet mapping meta data
*/
public static ServletMappingMetaData newServletMapping(final String servletName, final List<String> urlPatterns,
final List<ServletMappingMetaData> servletMappingsMD) {
final ServletMappingMetaData servletMappingMD = new ServletMappingMetaData();
servletMappingMD.setServletName(servletName);
servletMappingMD.setUrlPatterns(urlPatterns);
servletMappingsMD.add(servletMappingMD);
return servletMappingMD;
}
/**
* Creates new authentication constraint and associates it with security constraint meta data.
*
* @param roleNames roles
* @param securityConstraintMD security constraint meta data
* @return new authentication constraint meta data
*/
public static AuthConstraintMetaData newAuthConstraint(final List<String> roleNames,
final SecurityConstraintMetaData securityConstraintMD) {
final AuthConstraintMetaData authConstraintMD = new AuthConstraintMetaData();
authConstraintMD.setRoleNames(roleNames);
securityConstraintMD.setAuthConstraint(authConstraintMD);
return authConstraintMD;
}
/**
* Creates new user constraint meta data and associates it with security constraint meta data.
*
* @param transportGuarantee transport guarantee value
* @param securityConstraintMD security constraint meta data
* @return new user data constraint meta data
*/
public static UserDataConstraintMetaData newUserDataConstraint(final String transportGuarantee,
final SecurityConstraintMetaData securityConstraintMD) {
final UserDataConstraintMetaData userDataConstraintMD = new UserDataConstraintMetaData();
final TransportGuaranteeType transportGuaranteeValue = TransportGuaranteeType.valueOf(transportGuarantee);
userDataConstraintMD.setTransportGuarantee(transportGuaranteeValue);
securityConstraintMD.setUserDataConstraint(userDataConstraintMD);
return userDataConstraintMD;
}
/**
* Creates new parameter meta data and associates it with parameters meta data.
*
* @param key parameter key
* @param value parameter value
* @param paramsMD parameters meta data
* @return new parameter meta data
*/
public static ParamValueMetaData newParamValue(final String key, final String value, final List<ParamValueMetaData> paramsMD) {
final ParamValueMetaData paramValueMD = WebMetaDataHelper.newParamValue(key, value);
paramsMD.add(paramValueMD);
return paramValueMD;
}
/**
* Creates new parameter with specified key and value.
*
* @param key the key
* @param value the value
* @return new parameter
*/
private static ParamValueMetaData newParamValue(final String key, final String value) {
final ParamValueMetaData paramMD = new ParamValueMetaData();
paramMD.setParamName(key);
paramMD.setParamValue(value);
return paramMD;
}
}
| 15,042 | 37.770619 | 131 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/util/WSAttachmentKeys.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.util;
import org.jboss.as.server.deployment.AttachmentKey;
import org.jboss.as.webservices.deployers.WSEndpointConfigMapping;
import org.jboss.as.webservices.injection.WSEndpointHandlersMapping;
import org.jboss.as.webservices.metadata.model.JAXWSDeployment;
import org.jboss.as.webservices.webserviceref.WSRefRegistry;
import org.jboss.metadata.ear.jboss.JBossAppMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.invocation.RejectionRule;
import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.spi.metadata.jms.JMSEndpointsMetaData;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
/**
* Collection of attachment keys
*
* @author [email protected]
* @since 11-Nov-2010
*/
public final class WSAttachmentKeys {
public static final AttachmentKey<Deployment> DEPLOYMENT_KEY = AttachmentKey.create(Deployment.class);
public static final AttachmentKey<JBossAppMetaData> JBOSS_APP_METADATA_KEY = AttachmentKey.create(JBossAppMetaData.class);
public static final AttachmentKey<JMSEndpointsMetaData> JMS_ENDPOINT_METADATA_KEY = AttachmentKey.create(JMSEndpointsMetaData.class);
public static final AttachmentKey<JAXWSDeployment> JAXWS_ENDPOINTS_KEY = AttachmentKey.create(JAXWSDeployment.class);
public static final AttachmentKey<WebservicesMetaData> WEBSERVICES_METADATA_KEY = AttachmentKey.create(WebservicesMetaData.class);
public static final AttachmentKey<JBossWebservicesMetaData> JBOSS_WEBSERVICES_METADATA_KEY = AttachmentKey.create(JBossWebservicesMetaData.class);
public static final AttachmentKey<JBossWebMetaData> JBOSSWEB_METADATA_KEY = AttachmentKey.create(JBossWebMetaData.class);
public static final AttachmentKey<ClassLoader> CLASSLOADER_KEY = AttachmentKey.create(ClassLoader.class);
public static final AttachmentKey<WSRefRegistry> WS_REFREGISTRY = AttachmentKey.create(WSRefRegistry.class);
public static final AttachmentKey<WSEndpointHandlersMapping> WS_ENDPOINT_HANDLERS_MAPPING_KEY = AttachmentKey.create(WSEndpointHandlersMapping.class);
public static final AttachmentKey<WSEndpointConfigMapping> WS_ENDPOINT_CONFIG_MAPPING_KEY = AttachmentKey.create(WSEndpointConfigMapping.class);
public static final AttachmentKey<ServerConfig> SERVER_CONFIG_KEY = AttachmentKey.create(ServerConfig.class);
public static final AttachmentKey<RejectionRule> REJECTION_RULE_KEY = AttachmentKey.create(RejectionRule.class);
private WSAttachmentKeys() {
// forbidden inheritance
}
}
| 3,716 | 56.184615 | 154 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java | /*
* JBoss, Home of Professional Open Source
* Copyright 2012, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.util;
import java.io.IOException;
import java.net.URL;
import java.util.LinkedList;
import java.util.List;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.vfs.VirtualFile;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
/**
* A VirtualFile adaptor.
*
* @author [email protected]
* @author [email protected]
* @author [email protected]
*/
public final class VirtualFileAdaptor implements UnifiedVirtualFile {
private static final long serialVersionUID = -4509594124653184349L;
private final transient VirtualFile file;
public VirtualFileAdaptor(VirtualFile file) {
this.file = file;
}
private VirtualFile getFile() throws IOException {
return file;
}
private UnifiedVirtualFile findChild(String child, boolean throwExceptionIfNotFound) throws IOException {
final VirtualFile virtualFile = getFile();
final VirtualFile childFile = file.getChild(child);
if (!childFile.exists()) {
if (throwExceptionIfNotFound) {
throw WSLogger.ROOT_LOGGER.missingChild(child, virtualFile);
} else {
WSLogger.ROOT_LOGGER.tracef("Child '%s' not found for VirtualFile: %s", child, virtualFile);
return null;
}
}
return new VirtualFileAdaptor(childFile);
}
public UnifiedVirtualFile findChild(String child) throws IOException {
return findChild(child, true);
}
public UnifiedVirtualFile findChildFailSafe(String child) {
try {
return findChild(child, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public URL toURL() {
try {
return getFile().toURL();
} catch (Exception e) {
return null;
}
}
public List<UnifiedVirtualFile> getChildren() throws IOException {
List<VirtualFile> vfList = getFile().getChildren();
if (vfList == null)
return null;
List<UnifiedVirtualFile> uvfList = new LinkedList<UnifiedVirtualFile>();
for (VirtualFile vf : vfList) {
uvfList.add(new VirtualFileAdaptor(vf));
}
return uvfList;
}
public String getName() {
try {
return getFile().getName();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
| 3,478 | 31.514019 | 109 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/util/SubjectUtil.java | package org.jboss.as.webservices.util;
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.security.AccessController;
import java.security.KeyPair;
import java.security.Principal;
import java.security.PrivateKey;
import java.security.PrivilegedAction;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
import java.util.Set;
import javax.crypto.SecretKey;
import javax.security.auth.Subject;
import org.wildfly.security.auth.principal.NamePrincipal;
import org.wildfly.security.auth.server.IdentityCredentials;
import org.wildfly.security.auth.server.SecurityDomain;
import org.wildfly.security.auth.server.SecurityIdentity;
import org.wildfly.security.authz.Roles;
import org.wildfly.security.credential.Credential;
import org.wildfly.security.credential.KeyPairCredential;
import org.wildfly.security.credential.PasswordCredential;
import org.wildfly.security.credential.PublicKeyCredential;
import org.wildfly.security.credential.SecretKeyCredential;
import org.wildfly.security.credential.X509CertificateChainPrivateCredential;
import org.wildfly.security.credential.X509CertificateChainPublicCredential;
import org.wildfly.security.manager.WildFlySecurityManager;
import org.wildfly.security.password.Password;
/**
* Utilities for dealing with {@link Subject}.
*
* @author <a href="mailto:[email protected]">Stefan Guilhen</a>
*/
public final class SubjectUtil {
/**
* Converts the supplied {@link SecurityIdentity} into a {@link Subject}.
*
* @param securityIdentity the {@link SecurityIdentity} to be converted.
* @return the constructed {@link Subject} instance.
*/
public static Subject fromSecurityIdentity(final SecurityIdentity securityIdentity) {
return fromSecurityIdentity(securityIdentity, new Subject());
}
public static Subject fromSecurityIdentity(final SecurityIdentity securityIdentity, Subject subject) {
if (subject == null) {
subject = new Subject();
}
// The first principal added must be the security identity principal
// as logic in both CXF and JBoss WS look for the first non-Group principal
subject.getPrincipals().add(securityIdentity.getPrincipal());
Roles identityRoles = securityIdentity.getRoles();
// Just add a simple principal for each role instead of aggregating them in a Group.
// CXF can use such principals when identifying the subject's roles
String principalName = securityIdentity.getPrincipal().getName();
Set<Principal> principals = subject.getPrincipals();
for (String role : identityRoles) {
if (!principalName.equals(role)) {
principals.add(new NamePrincipal(role));
}
}
// Don't bother with the 'CallerPrincipal' group, since if there is no Group class,
// legacy security realms that use that Group to find the 'caller principal' cannot
// be in use
// process the identity's public and private credentials.
for (Credential credential : securityIdentity.getPublicCredentials()) {
if (credential instanceof PublicKeyCredential) {
subject.getPublicCredentials().add(credential.castAs(PublicKeyCredential.class).getPublicKey());
}
else if (credential instanceof X509CertificateChainPublicCredential) {
subject.getPublicCredentials().add(credential.castAs(X509CertificateChainPublicCredential.class).getCertificateChain());
}
else {
subject.getPublicCredentials().add(credential);
}
}
for (Credential credential : securityIdentity.getPrivateCredentials()) {
if (credential instanceof PasswordCredential) {
addPrivateCredential(subject, credential.castAs(PasswordCredential.class).getPassword());
}
else if (credential instanceof SecretKeyCredential) {
addPrivateCredential(subject, credential.castAs(SecretKeyCredential.class).getSecretKey());
}
else if (credential instanceof KeyPairCredential) {
addPrivateCredential(subject, credential.castAs(KeyPairCredential.class).getKeyPair());
}
else if (credential instanceof X509CertificateChainPrivateCredential) {
addPrivateCredential(subject, credential.castAs(X509CertificateChainPrivateCredential.class).getCertificateChain());
}
else {
addPrivateCredential(subject, credential);
}
}
// add the identity itself as a private credential - integration code can interact with the SI instead of the Subject if desired.
addPrivateCredential(subject, securityIdentity);
return subject;
}
private static void addPrivateCredential(final Subject subject, final Object credential) {
if (!WildFlySecurityManager.isChecking()) {
subject.getPrivateCredentials().add(credential);
}
else {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
subject.getPrivateCredentials().add(credential);
return null;
});
}
}
public static SecurityIdentity convertToSecurityIdentity(Subject subject, Principal principal, SecurityDomain domain,
String roleCategory) {
SecurityIdentity identity = null;
for (Object obj : subject.getPrivateCredentials()) {
if (obj instanceof SecurityIdentity) {
identity = (SecurityIdentity)obj;
break;
}
}
if (identity == null) {
identity = domain.createAdHocIdentity(principal);
}
// convert public credentials
IdentityCredentials publicCredentials = IdentityCredentials.NONE;
for (Object credential : subject.getPublicCredentials()) {
if (credential instanceof PublicKey) {
publicCredentials = publicCredentials.withCredential(new PublicKeyCredential((PublicKey) credential));
} else if (credential instanceof X509Certificate) {
publicCredentials = publicCredentials.withCredential(new X509CertificateChainPublicCredential(
(X509Certificate) credential));
} else if (credential instanceof Credential) {
publicCredentials = publicCredentials.withCredential((Credential) credential);
}
}
if (!publicCredentials.equals(IdentityCredentials.NONE)) {
identity = identity.withPublicCredentials(publicCredentials);
}
// convert private credentials
IdentityCredentials privateCredentials = IdentityCredentials.NONE;
for (Object credential : subject.getPrivateCredentials()) {
if (credential instanceof Password) {
privateCredentials = privateCredentials.withCredential(new PasswordCredential((Password) credential));
} else if (credential instanceof SecretKey) {
privateCredentials = privateCredentials.withCredential(new SecretKeyCredential((SecretKey) credential));
} else if (credential instanceof KeyPair) {
privateCredentials = privateCredentials.withCredential(new KeyPairCredential((KeyPair) credential));
} else if (credential instanceof PrivateKey) {
privateCredentials = privateCredentials.withCredential(new X509CertificateChainPrivateCredential(
(PrivateKey) credential));
} else if (credential instanceof Credential) {
privateCredentials = privateCredentials.withCredential((Credential) credential);
}
}
if (!privateCredentials.equals(IdentityCredentials.NONE)) {
identity = identity.withPrivateCredentials(privateCredentials);
}
return identity;
}
}
| 8,650 | 45.510753 | 137 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/util/ModuleClassLoaderProvider.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.util;
import java.lang.ref.WeakReference;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
/**
* AS7 version of {@link org.jboss.wsf.spi.classloading.ClassLoaderProvider}, relying on modular classloading.
*
* @author [email protected]
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public class ModuleClassLoaderProvider extends ClassLoaderProvider {
private static final ModuleIdentifier ASIL = ModuleIdentifier.create("org.jboss.as.webservices.server.integration");
private WeakReference<ClassLoader> integrationClassLoader;
@Override
public ClassLoader getWebServiceSubsystemClassLoader() {
return this.getClass().getClassLoader();
}
@Override
public ClassLoader getServerIntegrationClassLoader() {
if (integrationClassLoader == null || integrationClassLoader.get() == null) {
try {
Module module = Module.getBootModuleLoader().loadModule(ASIL);
integrationClassLoader = new WeakReference<ClassLoader>(module.getClassLoader());
} catch (ModuleLoadException e) {
throw new RuntimeException(e);
}
}
return integrationClassLoader.get();
}
@Override
public ClassLoader getServerJAXRPCIntegrationClassLoader() {
throw new UnsupportedOperationException();
}
public static void register() {
ClassLoaderProvider.setDefaultProvider(new ModuleClassLoaderProvider());
}
}
| 2,688 | 37.414286 | 120 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/util/WebAppController.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.util;
import java.io.File;
import jakarta.servlet.Servlet;
import org.jboss.as.web.host.ServletBuilder;
import org.jboss.as.web.host.WebDeploymentController;
import org.jboss.as.web.host.WebDeploymentBuilder;
import org.jboss.as.web.host.WebHost;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.msc.service.StartException;
/**
* WebAppController allows for automatically starting/stopping a webapp (servlet) depending on the actual need. This is useful
* for WS deployments needing a given utility servlet to be up (for instance the port component link servlet)
*
* @author [email protected]
* @since 02-Dec-2011
*/
public class WebAppController {
private WebHost host;
private String contextRoot;
private String urlPattern;
private String serverTempDir;
private String servletClass;
private ClassLoader classloader;
private volatile WebDeploymentController ctx;
private int count = 0;
public WebAppController(WebHost host, String servletClass, ClassLoader classloader, String contextRoot, String urlPattern,
String serverTempDir) {
this.host = host;
this.contextRoot = contextRoot;
this.urlPattern = urlPattern;
this.serverTempDir = serverTempDir;
this.classloader = classloader;
this.servletClass = servletClass;
}
public synchronized int incrementUsers() throws StartException {
if (count == 0) {
try {
ctx = startWebApp(host);
} catch (Exception e) {
throw new StartException(e);
}
}
return count++;
}
public synchronized int decrementUsers() {
if (count == 0) {
throw new IllegalStateException();
}
count--;
if (count == 0) {
try {
stopWebApp(ctx);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return count;
}
private WebDeploymentController startWebApp(WebHost host) throws Exception {
WebDeploymentBuilder builder = new WebDeploymentBuilder();
WebDeploymentController deployment;
try {
builder.setContextRoot(contextRoot);
File docBase = new File(serverTempDir, contextRoot);
if (!docBase.exists()) {
docBase.mkdirs();
}
builder.setDocumentRoot(docBase);
builder.setClassLoader(classloader);
final int j = servletClass.indexOf(".");
final String servletName = j < 0 ? servletClass : servletClass.substring(j + 1);
final Class<?> clazz = classloader.loadClass(servletClass);
ServletBuilder servlet = new ServletBuilder();
servlet.setServletName(servletName);
servlet.setServlet((Servlet) clazz.newInstance());
servlet.setServletClass(clazz);
servlet.addUrlMapping(urlPattern);
builder.addServlet(servlet);
deployment = host.addWebDeployment(builder);
deployment.create();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.createContextPhaseFailed(e);
}
try {
deployment.start();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.startContextPhaseFailed(e);
}
return deployment;
}
private void stopWebApp(WebDeploymentController context) throws Exception {
try {
context.stop();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.stopContextPhaseFailed(e);
}
try {
context.destroy();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.destroyContextPhaseFailed(e);
}
}
}
| 4,869 | 34.547445 | 126 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/util/EndpointRegistryFactory.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.util;
import org.jboss.wsf.spi.management.EndpointRegistry;
/**
* JBoss AS 7 WS Endpoint registry factory
*
* @author [email protected]
* @author <a href="mailto:[email protected]">Jim Ma</a>
* @since 25-Jan-2012
*
*/
public final class EndpointRegistryFactory extends org.jboss.wsf.spi.management.EndpointRegistryFactory {
private static final EndpointRegistry registry = new ServiceContainerEndpointRegistry();
public EndpointRegistryFactory() {
super();
}
/**
* Retrieves endpoint registry through the corresponding Service
*
* @return endpoint registry
*/
public EndpointRegistry getEndpointRegistry() {
return registry;
}
}
| 1,764 | 32.301887 | 105 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/util/DotNames.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.util;
import jakarta.annotation.security.DeclareRoles;
import jakarta.annotation.security.PermitAll;
import jakarta.annotation.security.RolesAllowed;
import jakarta.ejb.Singleton;
import jakarta.ejb.Stateless;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebService;
import jakarta.servlet.Servlet;
import jakarta.xml.ws.Service;
import jakarta.xml.ws.WebServiceProvider;
import jakarta.xml.ws.WebServiceRef;
import jakarta.xml.ws.WebServiceRefs;
import org.jboss.jandex.DotName;
import org.jboss.ws.api.annotation.WebContext;
/**
* Centralized DotNames relevant for WS integration.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class DotNames {
private DotNames() {
// forbidden instantiation
}
public static final DotName HANDLER_CHAIN_ANNOTATION = DotName.createSimple(HandlerChain.class.getName());
public static final DotName JAXWS_SERVICE_CLASS = DotName.createSimple(Service.class.getName());
public static final DotName OBJECT_CLASS = DotName.createSimple(Object.class.getName());
public static final DotName ROLES_ALLOWED_ANNOTATION = DotName.createSimple(RolesAllowed.class.getName());
public static final DotName DECLARE_ROLES_ANNOTATION = DotName.createSimple(DeclareRoles.class.getName());
public static final DotName PERMIT_ALL_ANNOTATION = DotName.createSimple(PermitAll.class.getName());
public static final DotName SERVLET_CLASS = DotName.createSimple(Servlet.class.getName());
public static final DotName SINGLETON_ANNOTATION = DotName.createSimple(Singleton.class.getName());
public static final DotName STATELESS_ANNOTATION = DotName.createSimple(Stateless.class.getName());
public static final DotName WEB_CONTEXT_ANNOTATION = DotName.createSimple(WebContext.class.getName());
public static final DotName WEB_SERVICE_ANNOTATION = DotName.createSimple(WebService.class.getName());
public static final DotName WEB_SERVICE_PROVIDER_ANNOTATION = DotName.createSimple(WebServiceProvider.class.getName());
public static final DotName WEB_SERVICE_REF_ANNOTATION = DotName.createSimple(WebServiceRef.class.getName());
public static final DotName WEB_SERVICE_REFS_ANNOTATION = DotName.createSimple(WebServiceRefs.class.getName());
}
| 3,328 | 47.955882 | 123 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/util/WSServices.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.util;
import org.jboss.msc.service.ServiceName;
/**
* WSServices
*
* @author [email protected]
* @since 09-Nov-2010
*
*/
public final class WSServices {
public static final ServiceName WS_SERVICE = ServiceName.JBOSS.append("ws");
public static final ServiceName CONFIG_SERVICE = WS_SERVICE.append("config");
public static final ServiceName CLIENT_CONFIG_SERVICE = WS_SERVICE.append("client-config");
public static final ServiceName ENDPOINT_CONFIG_SERVICE = WS_SERVICE.append("endpoint-config");
public static final ServiceName MODEL_SERVICE = WS_SERVICE.append("model");
public static final ServiceName ENDPOINT_SERVICE = WS_SERVICE.append("endpoint");
public static final ServiceName ENDPOINT_DEPLOY_SERVICE = WS_SERVICE.append("endpoint-deploy");
public static final ServiceName ENDPOINT_PUBLISH_SERVICE = WS_SERVICE.append("endpoint-publish");
public static final ServiceName XTS_CLIENT_INTEGRATION_SERVICE = WS_SERVICE.append("xts-integration");
//Elytron service
public static final ServiceName ElYTRON_APP_SECURITYDOMAIN = ServiceName.of("org").append(new String[]{"wildfly", "extension","undertow", "application-security-domain"});
private WSServices() {
// forbidden inheritance
}
}
| 2,329 | 42.148148 | 174 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/util/ASHelper.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.util;
import static org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT;
import static org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS;
import static org.jboss.as.webservices.util.DotNames.JAXWS_SERVICE_CLASS;
import static org.jboss.as.webservices.util.DotNames.WEB_SERVICE_ANNOTATION;
import static org.jboss.as.webservices.util.DotNames.WEB_SERVICE_PROVIDER_ANNOTATION;
import static org.jboss.as.webservices.util.WSAttachmentKeys.JAXWS_ENDPOINTS_KEY;
import static org.jboss.as.webservices.util.WSAttachmentKeys.JBOSS_WEBSERVICES_METADATA_KEY;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.List;
import jakarta.jws.WebService;
import jakarta.xml.ws.WebServiceProvider;
import org.jboss.as.ee.component.EEModuleClassDescription;
import org.jboss.as.ee.metadata.ClassAnnotationInformation;
import org.jboss.as.server.CurrentServiceContainer;
import org.jboss.as.server.deployment.AttachmentKey;
import org.jboss.as.server.deployment.AttachmentList;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.EjbDeploymentMarker;
import org.jboss.as.server.deployment.annotation.CompositeIndex;
import org.jboss.as.server.deployment.module.ResourceRoot;
import org.jboss.as.web.common.WarMetaData;
import org.jboss.as.webservices.deployers.WebServiceAnnotationInfo;
import org.jboss.as.webservices.deployers.WebServiceProviderAnnotationInfo;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.metadata.model.EJBEndpoint;
import org.jboss.as.webservices.metadata.model.JAXWSDeployment;
import org.jboss.as.webservices.metadata.model.POJOEndpoint;
import org.jboss.as.webservices.webserviceref.WSRefRegistry;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.jboss.metadata.ear.jboss.JBossAppMetaData;
import org.jboss.metadata.ear.spec.ModuleMetaData;
import org.jboss.metadata.ear.spec.WebModuleMetaData;
import org.jboss.metadata.web.jboss.JBossServletMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.spec.ServletMetaData;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.ws.common.integration.WSHelper;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.metadata.webservices.JBossPortComponentMetaData;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
/**
* JBoss AS integration helper class.
*
* @author <a href="[email protected]">Richard Opalka</a>
* @author <a href="[email protected]">Alessio Soldano</a>
*/
public final class ASHelper {
private ASHelper() {
}
/**
* Gets list of Jakarta XML Web Services Jakarta Enterprise Beans meta data.
*
* @param unit deployment unit
* @return list of Jakarta XML Web Services Jakarta Enterprise Beans meta data
*/
public static List<EJBEndpoint> getJaxwsEjbs(final DeploymentUnit unit) {
final JAXWSDeployment jaxwsDeployment = getOptionalAttachment(unit, WSAttachmentKeys.JAXWS_ENDPOINTS_KEY);
return jaxwsDeployment != null ? jaxwsDeployment.getEjbEndpoints() : Collections.<EJBEndpoint>emptyList();
}
/**
* Gets list of JAXWS POJOs meta data.
*
* @param unit deployment unit
* @return list of JAXWS POJOs meta data
*/
public static List<POJOEndpoint> getJaxwsPojos(final DeploymentUnit unit) {
final JAXWSDeployment jaxwsDeployment = unit.getAttachment(WSAttachmentKeys.JAXWS_ENDPOINTS_KEY);
return jaxwsDeployment != null ? jaxwsDeployment.getPojoEndpoints() : Collections.<POJOEndpoint>emptyList();
}
/**
* Returns endpoint name.
*
* @param servletMD servlet meta data
* @return endpoint name
*/
public static String getEndpointName(final ServletMetaData servletMD) {
final String endpointName = servletMD.getName();
return endpointName != null ? endpointName.trim() : null;
}
/**
* Returns endpoint class name.
*
* @param servletMD servlet meta data
* @return endpoint class name
*/
public static String getEndpointClassName(final ServletMetaData servletMD) {
final String endpointClass = servletMD.getServletClass();
return endpointClass != null ? endpointClass.trim() : null;
}
/**
* Returns servlet meta data for requested servlet name.
*
* @param jbossWebMD jboss web meta data
* @param servletName servlet name
* @return servlet meta data
*/
public static ServletMetaData getServletForName(final JBossWebMetaData jbossWebMD, final String servletName) {
for (JBossServletMetaData servlet : jbossWebMD.getServlets()) {
if (servlet.getName().equals(servletName)) {
return servlet;
}
}
return null;
}
/**
* Returns required attachment value from deployment unit.
*
* @param <A> expected value
* @param unit deployment unit
* @param key attachment key
* @return required attachment
* @throws IllegalStateException if attachment value is null
*/
public static <A> A getRequiredAttachment(final DeploymentUnit unit, final AttachmentKey<A> key) {
final A value = unit.getAttachment(key);
if (value == null) {
throw new IllegalStateException();
}
return value;
}
/**
* Returns optional attachment value from deployment unit or null if not bound.
*
* @param <A> expected value
* @param unit deployment unit
* @param key attachment key
* @return optional attachment value or null
*/
public static <A> A getOptionalAttachment(final DeploymentUnit unit, final AttachmentKey<A> key) {
return unit.getAttachment(key);
}
public static boolean isJaxwsService(final ClassInfo current, final CompositeIndex index) {
ClassInfo tmp = current;
while (tmp != null) {
final DotName superName = tmp.superName();
if (JAXWS_SERVICE_CLASS.equals(superName)) {
return true;
}
tmp = index.getClassByName(superName);
}
return false;
}
public static boolean isJaxwsService(final ClassInfo current, final Index index) {
ClassInfo tmp = current;
while (tmp != null) {
final DotName superName = tmp.superName();
if (JAXWS_SERVICE_CLASS.equals(superName)) {
return true;
}
tmp = index.getClassByName(superName);
}
return false;
}
public static boolean isJaxwsEndpointInterface(final ClassInfo clazz) {
final short flags = clazz.flags();
if (!Modifier.isInterface(flags)) return false;
if (!Modifier.isPublic(flags)) return false;
return clazz.annotationsMap().containsKey(WEB_SERVICE_ANNOTATION);
}
public static boolean hasClassesFromPackage(final Index index, final String pck) {
for (ClassInfo ci : index.getKnownClasses()) {
if (ci.name().toString().startsWith(pck)) {
return true;
}
}
return false;
}
public static boolean isJaxwsEndpoint(final ClassInfo clazz, final CompositeIndex index) {
return isJaxwsEndpoint(clazz, index, true);
}
public static boolean isJaxwsEndpoint(final ClassInfo clazz, final CompositeIndex index, boolean log) {
// assert JAXWS endpoint class flags
final short flags = clazz.flags();
if (Modifier.isInterface(flags)) return false;
if (Modifier.isAbstract(flags)) return false;
if (!Modifier.isPublic(flags)) return false;
if (isJaxwsService(clazz, index)) return false;
final boolean hasWebServiceAnnotation = clazz.annotationsMap().containsKey(WEB_SERVICE_ANNOTATION);
final boolean hasWebServiceProviderAnnotation = clazz.annotationsMap().containsKey(WEB_SERVICE_PROVIDER_ANNOTATION);
if (!hasWebServiceAnnotation && !hasWebServiceProviderAnnotation) {
return false;
}
if (hasWebServiceAnnotation && hasWebServiceProviderAnnotation) {
if (log) {
WSLogger.ROOT_LOGGER.mutuallyExclusiveAnnotations(clazz.name().toString());
}
return false;
}
if (Modifier.isFinal(flags)) {
if (log) {
WSLogger.ROOT_LOGGER.finalEndpointClassDetected(clazz.name().toString());
}
return false;
}
return true;
}
public static boolean isJaxwsEndpoint(final EEModuleClassDescription classDescription, final CompositeIndex index) {
ClassInfo classInfo = null;
WebServiceAnnotationInfo webserviceAnnoationInfo = null;
final ClassAnnotationInformation<WebService, WebServiceAnnotationInfo> classAnnotationInfo = classDescription.getAnnotationInformation(WebService.class);
if (classAnnotationInfo!= null && !classAnnotationInfo.getClassLevelAnnotations().isEmpty()) {
webserviceAnnoationInfo = classAnnotationInfo.getClassLevelAnnotations().get(0);
classInfo = (ClassInfo)webserviceAnnoationInfo.getTarget();
}
WebServiceProviderAnnotationInfo webserviceProviderAnnoationInfo = null;
final ClassAnnotationInformation<WebServiceProvider, WebServiceProviderAnnotationInfo> providerAnnotationInfo = classDescription.getAnnotationInformation(WebServiceProvider.class);
if (providerAnnotationInfo!= null && !providerAnnotationInfo.getClassLevelAnnotations().isEmpty()) {
webserviceProviderAnnoationInfo = providerAnnotationInfo.getClassLevelAnnotations().get(0);
classInfo = (ClassInfo)webserviceProviderAnnoationInfo.getTarget();
}
if (classInfo == null) {
return false;
}
// assert JAXWS endpoint class flags
final short flags = classInfo.flags();
if (Modifier.isInterface(flags)) return false;
if (Modifier.isAbstract(flags)) return false;
if (!Modifier.isPublic(flags)) return false;
if (isJaxwsService(classInfo, index)) return false;
if (webserviceAnnoationInfo !=null && webserviceProviderAnnoationInfo != null) {
WSLogger.ROOT_LOGGER.mutuallyExclusiveAnnotations(classInfo.name().toString());
return false;
}
if (Modifier.isFinal(flags)) {
WSLogger.ROOT_LOGGER.finalEndpointClassDetected(classInfo.name().toString());
return false;
}
return true;
}
/**
* Gets the JBossWebMetaData from the WarMetaData attached to the provided deployment unit, if any.
*
* @param unit
* @return the JBossWebMetaData or null if either that or the parent WarMetaData are not found.
*/
public static JBossWebMetaData getJBossWebMetaData(final DeploymentUnit unit) {
final WarMetaData warMetaData = getOptionalAttachment(unit, WarMetaData.ATTACHMENT_KEY);
JBossWebMetaData result = null;
if (warMetaData != null) {
result = warMetaData.getMergedJBossWebMetaData();
if (result == null) {
result = warMetaData.getJBossWebMetaData();
}
} else {
result = getOptionalAttachment(unit, WSAttachmentKeys.JBOSSWEB_METADATA_KEY);
}
return result;
}
public static List<AnnotationInstance> getAnnotations(final DeploymentUnit unit, final DotName annotation) {
final CompositeIndex compositeIndex = getRequiredAttachment(unit, Attachments.COMPOSITE_ANNOTATION_INDEX);
return compositeIndex.getAnnotations(annotation);
}
public static JAXWSDeployment getJaxwsDeployment(final DeploymentUnit unit) {
JAXWSDeployment wsDeployment = unit.getAttachment(JAXWS_ENDPOINTS_KEY);
if (wsDeployment == null) {
wsDeployment = new JAXWSDeployment();
unit.putAttachment(JAXWS_ENDPOINTS_KEY, wsDeployment);
}
return wsDeployment;
}
/**
* Return a named port-component from the jboss-webservices.xml
* @param unit
* @param name
* @return
*/
public static JBossPortComponentMetaData getJBossWebserviceMetaDataPortComponent(
final DeploymentUnit unit, final String name) {
if (name != null) {
final JBossWebservicesMetaData jbossWebserviceMetaData = unit.getAttachment(JBOSS_WEBSERVICES_METADATA_KEY);
if (jbossWebserviceMetaData != null) {
JBossPortComponentMetaData[] portComponent = jbossWebserviceMetaData.getPortComponents();
if (portComponent != null) {
for (JBossPortComponentMetaData component : portComponent) {
if (name.equals(component.getEjbName())) {
return component;
}
}
}
}
}
return null;
}
/**
* Returns an EJBEndpoint based upon fully qualified classname.
* @param jaxwsDeployment
* @param className
* @return
*/
public static EJBEndpoint getWebserviceMetadataEJBEndpoint(final JAXWSDeployment jaxwsDeployment,
final String className) {
java.util.List<EJBEndpoint> ejbEndpointList = jaxwsDeployment.getEjbEndpoints();
for (EJBEndpoint ejbEndpoint : ejbEndpointList) {
if (className.equals(ejbEndpoint.getClassName())) {
return ejbEndpoint;
}
}
return null;
}
/**
* Returns context root associated with webservice deployment.
*
* If there's application.xml descriptor provided defining nested web module, then context root defined there will be
* returned. Otherwise context root defined in jboss-web.xml will be returned.
*
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
* @return context root
*/
public static String getContextRoot(final Deployment dep, final JBossWebMetaData jbossWebMD) {
final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
final JBossAppMetaData jbossAppMD = unit.getParent() == null ? null : ASHelper.getOptionalAttachment(unit.getParent(),
WSAttachmentKeys.JBOSS_APP_METADATA_KEY);
String contextRoot = null;
// prefer context root defined in application.xml over one defined in jboss-web.xml
if (jbossAppMD != null) {
final ModuleMetaData moduleMD = jbossAppMD.getModules().get(dep.getSimpleName());
if (moduleMD != null) {
final WebModuleMetaData webModuleMD = (WebModuleMetaData) moduleMD.getValue();
contextRoot = webModuleMD.getContextRoot();
}
}
if (contextRoot == null) {
contextRoot = jbossWebMD != null ? jbossWebMD.getContextRoot() : null;
}
return contextRoot;
}
@SuppressWarnings("unchecked")
public static <T> T getMSCService(final ServiceName serviceName, final Class<T> clazz) {
ServiceController<T> service = (ServiceController<T>) CurrentServiceContainer.getServiceContainer().getService(serviceName);
return service != null ? service.getValue() : null;
}
public static WSRefRegistry getWSRefRegistry(final DeploymentUnit unit) {
WSRefRegistry refRegistry = unit.getAttachment(WSAttachmentKeys.WS_REFREGISTRY);
if (refRegistry == null) {
refRegistry = WSRefRegistry.newInstance();
unit.putAttachment(WSAttachmentKeys.WS_REFREGISTRY, refRegistry);
}
return refRegistry;
}
public static List<ResourceRoot> getResourceRoots(DeploymentUnit unit) {
// wars define resource roots
AttachmentList<ResourceRoot> resourceRoots = unit.getAttachment(RESOURCE_ROOTS);
if (!unit.getName().endsWith(".war") && EjbDeploymentMarker.isEjbDeployment(unit)) {
// Jakarta Enterprise Beans archives don't define resource roots, using root resource
resourceRoots = new AttachmentList<ResourceRoot>(ResourceRoot.class);
final ResourceRoot root = unit.getAttachment(DEPLOYMENT_ROOT);
resourceRoots.add(root);
}
return resourceRoots;
}
}
| 17,692 | 41.026128 | 188 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/injection/WebServiceContextInjectionSource.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.injection;
import org.jboss.as.ee.component.InjectionSource;
import org.jboss.as.naming.ManagedReference;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.msc.inject.Injector;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.ws.common.injection.ThreadLocalAwareWebServiceContext;
/**
* {@link InjectionSource} for {@link jakarta.xml.ws.WebServiceContext} resource.
*
* User: Jaikiran Pai
*/
public class WebServiceContextInjectionSource extends InjectionSource {
@Override
public void getResourceValue(ResolutionContext resolutionContext, ServiceBuilder<?> serviceBuilder, DeploymentPhaseContext phaseContext, Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
injector.inject(new WebServiceContextManagedReferenceFactory());
}
private class WebServiceContextManagedReferenceFactory implements ManagedReferenceFactory {
@Override
public ManagedReference getReference() {
return new WebServiceContextManagedReference();
}
}
private class WebServiceContextManagedReference implements ManagedReference {
@Override
public void release() {
}
@Override
public Object getInstance() {
// return the WebServiceContext
return ThreadLocalAwareWebServiceContext.getInstance();
}
}
// all context injection sources are equal since they are thread locals
public boolean equals(Object o) {
return o instanceof WebServiceContextInjectionSource;
}
public int hashCode() {
return 1;
}
}
| 2,823 | 36.653333 | 227 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/injection/WSEndpointHandlersMapping.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.injection;
import static org.wildfly.common.Assert.checkNotNullParam;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Defines mapping of Jaxws endpoints and their handlers.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class WSEndpointHandlersMapping {
private final Map<String, Set<String>> endpointHandlersMap = new HashMap<String, Set<String>>();
/**
* Registers endpoint and its associated WS handlers.
*
* @param endpointClass WS endpoint
* @param endpointHandlers WS handlers associated with endpoint
*/
public void registerEndpointHandlers(final String endpointClass, final Set<String> endpointHandlers) {
checkNotNullParam("endpointClass", endpointClass);
checkNotNullParam("endpointHandlers", endpointHandlers);
endpointHandlersMap.put(endpointClass, Collections.unmodifiableSet(endpointHandlers));
}
/**
* Returns handlers class names associated with WS endpoint.
*
* @param endpointClass to get associated handlers for
* @return associated handlers class names
*/
public Set<String> getHandlers(final String endpointClass) {
return endpointHandlersMap.get(endpointClass);
}
public boolean isEmpty() {
return endpointHandlersMap.size() == 0;
}
}
| 2,446 | 34.985294 | 106 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/injection/WSComponentCreateService.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.injection;
import org.jboss.as.ee.component.BasicComponent;
import org.jboss.as.ee.component.BasicComponentCreateService;
import org.jboss.as.ee.component.ComponentConfiguration;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class WSComponentCreateService extends BasicComponentCreateService {
public WSComponentCreateService( final ComponentConfiguration componentConfiguration ) {
super(componentConfiguration);
}
@Override
protected BasicComponent createComponent() {
return new WSComponent(this);
}
}
| 1,642 | 38.119048 | 92 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/injection/WSComponentCreateServiceFactory.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.injection;
import org.jboss.as.ee.component.BasicComponentCreateService;
import org.jboss.as.ee.component.ComponentConfiguration;
import org.jboss.as.ee.component.ComponentCreateServiceFactory;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
final class WSComponentCreateServiceFactory implements ComponentCreateServiceFactory {
static final WSComponentCreateServiceFactory INSTANCE = new WSComponentCreateServiceFactory();
private WSComponentCreateServiceFactory() {}
@Override
public BasicComponentCreateService constructService(final ComponentConfiguration configuration) {
return new WSComponentCreateService(configuration);
}
}
| 1,748 | 40.642857 | 101 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/injection/WSComponentDescription.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.injection;
import org.jboss.as.ee.component.ComponentConfiguration;
import org.jboss.as.ee.component.ComponentDescription;
import org.jboss.as.ee.component.EEModuleDescription;
import org.jboss.as.server.deployment.reflect.ClassReflectionIndex;
import org.jboss.modules.ModuleLoader;
import org.jboss.msc.service.ServiceName;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class WSComponentDescription extends ComponentDescription {
public WSComponentDescription(final String componentName, final String componentClassName,
final EEModuleDescription moduleDescription, final ServiceName deploymentUnitServiceName) {
super(componentName, componentClassName, moduleDescription, deploymentUnitServiceName);
setExcludeDefaultInterceptors(true);
}
@Override
public ComponentConfiguration createConfiguration(final ClassReflectionIndex classIndex, final ClassLoader moduleClassLoader,
final ModuleLoader moduleLoader) {
final ComponentConfiguration cc = super.createConfiguration(classIndex, moduleClassLoader, moduleLoader);
cc.setComponentCreateServiceFactory(WSComponentCreateServiceFactory.INSTANCE);
return cc;
}
@Override
public boolean isCDIInterceptorEnabled() {
return true;
}
}
| 2,388 | 41.660714 | 129 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/injection/WSComponent.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.injection;
import org.jboss.as.ee.component.BasicComponent;
import org.jboss.as.ee.component.BasicComponentInstance;
import org.jboss.as.naming.ManagedReference;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Jim Ma</a>
*/
public final class WSComponent extends BasicComponent {
private volatile BasicComponentInstance wsComponentInstance;
private volatile ManagedReference reference;
/**
* We can't lock on <code>this</code> because the
* {@link org.jboss.as.ee.component.BasicComponent#waitForComponentStart()}
* also synchronizes on it, and calls {@link #wait()}.
*/
private final Object lock = new Object();
public WSComponent(final WSComponentCreateService createService) {
super(createService);
}
public BasicComponentInstance getComponentInstance() {
BasicComponentInstance result = wsComponentInstance;
if (result == null) {
synchronized (lock) {
result = wsComponentInstance;
if (result == null) {
if (reference == null) {
wsComponentInstance = result = (BasicComponentInstance) createInstance();
} else {
wsComponentInstance = result = (BasicComponentInstance) this.createInstance(reference.getInstance());
}
}
}
}
return result;
}
public void setReference(ManagedReference reference) {
this.reference = reference;
}
@Override
public void stop() {
if (wsComponentInstance == null) return;
synchronized(lock) {
if (wsComponentInstance != null) {
wsComponentInstance.destroy();
wsComponentInstance = null;
}
}
}
}
| 2,935 | 35.246914 | 125 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/injection/WSHandlerChainAnnotationProcessor.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.injection;
import static org.jboss.as.server.deployment.Attachments.ANNOTATION_INDEX;
import static org.jboss.as.webservices.util.ASHelper.isJaxwsService;
import static org.jboss.as.webservices.util.DotNames.HANDLER_CHAIN_ANNOTATION;
import static org.jboss.as.webservices.util.DotNames.WEB_SERVICE_ANNOTATION;
import static org.jboss.as.webservices.util.DotNames.WEB_SERVICE_PROVIDER_ANNOTATION;
import static org.jboss.as.webservices.util.WSAttachmentKeys.WS_ENDPOINT_HANDLERS_MAPPING_KEY;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Modifier;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.jboss.as.ee.structure.DeploymentType;
import org.jboss.as.ee.structure.DeploymentTypeMarker;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.module.ResourceRoot;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.util.ASHelper;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.jboss.vfs.VirtualFile;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainsMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainsMetaDataParser;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData;
/**
* Scans @HandlerChain annotations in the deployment
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
*/
public final class WSHandlerChainAnnotationProcessor implements DeploymentUnitProcessor {
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
return;
}
List<ResourceRoot> resourceRoots = ASHelper.getResourceRoots(unit);
if (resourceRoots == null) {
return;
}
final WSEndpointHandlersMapping mapping = new WSEndpointHandlersMapping();
Index index = null;
for (final ResourceRoot resourceRoot : resourceRoots) {
index = resourceRoot.getAttachment(ANNOTATION_INDEX);
if (index != null) {
// process @HandlerChain annotations
processHandlerChainAnnotations(resourceRoot, resourceRoots, index, mapping);
}
}
if (!mapping.isEmpty()) {
unit.putAttachment(WS_ENDPOINT_HANDLERS_MAPPING_KEY, mapping);
}
}
private static void processHandlerChainAnnotations(final ResourceRoot currentResourceRoot,
final List<ResourceRoot> resourceRoots, final Index index, final WSEndpointHandlersMapping mapping)
throws DeploymentUnitProcessingException {
final List<AnnotationInstance> webServiceAnnotations = index.getAnnotations(WEB_SERVICE_ANNOTATION);
final List<AnnotationInstance> webServiceProviderAnnotations = index.getAnnotations(WEB_SERVICE_PROVIDER_ANNOTATION);
for (final AnnotationInstance annotationInstance : webServiceAnnotations) {
final AnnotationTarget annotationTarget = annotationInstance.target();
if (annotationTarget instanceof ClassInfo) {
final ClassInfo classInfo = (ClassInfo) annotationTarget;
if (isJaxwsEndpoint(classInfo, index)) {
AnnotationInstance handlerChainAnnotationInstance = getHandlerChainAnnotationInstance(classInfo);
//JSR-181, Section 4.6.1: "The @HandlerChain annotation MAY be present on the endpoint interface and service
//implementation bean. The service implementation bean’s @HandlerChain is used if @HandlerChain is present on both."
if (handlerChainAnnotationInstance == null) {
handlerChainAnnotationInstance = getEndpointInterfaceHandlerChainAnnotationInstance(classInfo, index);
}
if (handlerChainAnnotationInstance != null) {
final String endpointClass = classInfo.name().toString();
processHandlerChainAnnotation(currentResourceRoot, resourceRoots, handlerChainAnnotationInstance, endpointClass, mapping);
}
}
} else {
// We ignore fields & methods annotated with @HandlerChain.
// These are used always in combination with @WebServiceRef
// which are always referencing JAXWS client proxies only.
}
}
for (final AnnotationInstance annotationInstance : webServiceProviderAnnotations) {
final AnnotationTarget annotationTarget = annotationInstance.target();
if (annotationTarget instanceof ClassInfo) {
final ClassInfo classInfo = (ClassInfo) annotationTarget;
final AnnotationInstance handlerChainAnnotationInstance = getHandlerChainAnnotationInstance(classInfo);
if (handlerChainAnnotationInstance != null && isJaxwsEndpoint(classInfo, index)) {
final String endpointClass = classInfo.name().toString();
processHandlerChainAnnotation(currentResourceRoot, resourceRoots, handlerChainAnnotationInstance, endpointClass, mapping);
}
} else {
// We ignore fields & methods annotated with @HandlerChain.
// These are used always in combination with @WebServiceRef
// which are always referencing JAXWS client proxies only.
}
}
}
private static AnnotationInstance getHandlerChainAnnotationInstance(final ClassInfo classInfo) {
List<AnnotationInstance> list = classInfo.annotationsMap().get(HANDLER_CHAIN_ANNOTATION);
return list != null && !list.isEmpty() ? list.iterator().next() : null;
}
private static AnnotationInstance getEndpointInterfaceHandlerChainAnnotationInstance(final ClassInfo classInfo, final Index index) {
AnnotationValue av = classInfo.annotationsMap().get(WEB_SERVICE_ANNOTATION).iterator().next().value("endpointInterface");
if (av != null) {
String intf = av.asString();
if (intf != null && !intf.isEmpty()) {
ClassInfo intfClassInfo = index.getClassByName(DotName.createSimple(intf));
if (intfClassInfo != null && ASHelper.isJaxwsEndpointInterface(intfClassInfo)) {
return getHandlerChainAnnotationInstance(intfClassInfo);
}
}
}
return null;
}
private static void processHandlerChainAnnotation(final ResourceRoot currentResourceRoot,
final List<ResourceRoot> resourceRoots, final AnnotationInstance handlerChainAnnotation,
final String endpointClass, final WSEndpointHandlersMapping mapping) throws DeploymentUnitProcessingException {
final String handlerChainConfigFile = handlerChainAnnotation.value("file").asString();
InputStream is = null;
try {
is = getInputStream(currentResourceRoot, resourceRoots, handlerChainConfigFile, endpointClass);
final Set<String> endpointHandlers = getHandlers(is);
if (!endpointHandlers.isEmpty()) {
mapping.registerEndpointHandlers(endpointClass, endpointHandlers);
} else {
WSLogger.ROOT_LOGGER.invalidHandlerChainFile(handlerChainConfigFile);
}
} catch (final IOException|URISyntaxException e) {
throw new DeploymentUnitProcessingException(e);
} finally {
if (is != null) {
try { is.close(); } catch (final IOException ignore) {}
}
}
}
private static InputStream getInputStream(final ResourceRoot currentResourceRoot, final List<ResourceRoot> resourceRoots, final String handlerChainConfigFile, final String annotatedClassName) throws IOException, URISyntaxException {
if (handlerChainConfigFile.startsWith("file://") || handlerChainConfigFile.startsWith("http://")) {
return new URL(handlerChainConfigFile).openStream();
} else {
URI classURI = new URI(annotatedClassName.replace('.', '/'));
final String handlerChainConfigFileResourcePath = classURI.resolve(handlerChainConfigFile).toString();
VirtualFile config = currentResourceRoot.getRoot().getChild(handlerChainConfigFileResourcePath);
if (config.exists() && config.isFile()) {
return config.openStream();
} else {
for (ResourceRoot rr : resourceRoots) {
config = rr.getRoot().getChild(handlerChainConfigFileResourcePath);
if (config.exists() && config.isFile()) {
return config.openStream();
}
}
}
throw WSLogger.ROOT_LOGGER.missingHandlerChainConfigFile(handlerChainConfigFileResourcePath, currentResourceRoot);
}
}
private static Set<String> getHandlers(final InputStream is) throws IOException {
final Set<String> retVal = new HashSet<String>();
final UnifiedHandlerChainsMetaData handlerChainsUMDM = UnifiedHandlerChainsMetaDataParser.parse(is);
if (handlerChainsUMDM != null) {
for (final UnifiedHandlerChainMetaData handlerChainUMDM : handlerChainsUMDM.getHandlerChains()) {
for (final UnifiedHandlerMetaData handlerUMDM : handlerChainUMDM.getHandlers()) {
retVal.add(handlerUMDM.getHandlerClass());
}
}
}
return retVal;
}
private static boolean isJaxwsEndpoint(final ClassInfo clazz, final Index index) {
// assert JAXWS endpoint class flags
final short flags = clazz.flags();
if (Modifier.isInterface(flags)) return false;
if (Modifier.isAbstract(flags)) return false;
if (!Modifier.isPublic(flags)) return false;
if (isJaxwsService(clazz, index)) return false;
if (Modifier.isFinal(flags)) return false;
final boolean isWebService = clazz.annotationsMap().containsKey(WEB_SERVICE_ANNOTATION);
final boolean isWebServiceProvider = clazz.annotationsMap().containsKey(WEB_SERVICE_PROVIDER_ANNOTATION);
return isWebService || isWebServiceProvider;
}
} | 12,083 | 51.768559 | 236 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/injection/InjectionDeploymentAspect.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.injection;
import java.security.AccessController;
import java.util.HashMap;
import java.util.Map;
import org.jboss.as.ee.component.BasicComponent;
import org.jboss.as.ee.component.ComponentInstance;
import org.jboss.as.server.CurrentServiceContainer;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.ws.common.deployment.ReferenceFactory;
import org.jboss.ws.common.integration.AbstractDeploymentAspect;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.InstanceProvider;
import org.jboss.wsf.spi.deployment.Reference;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class InjectionDeploymentAspect extends AbstractDeploymentAspect {
@Override
public void start(final Deployment dep) {
for (final Endpoint ep : dep.getService().getEndpoints()) {
setInjectionAwareInstanceProvider(ep);
}
}
private void setInjectionAwareInstanceProvider(final Endpoint ep) {
final InstanceProvider stackInstanceProvider = ep.getInstanceProvider();
final DeploymentUnit unit = ep.getService().getDeployment().getAttachment(DeploymentUnit.class);
final InstanceProvider injectionAwareInstanceProvider = new InjectionAwareInstanceProvider(stackInstanceProvider, ep, unit);
ep.setInstanceProvider(injectionAwareInstanceProvider);
}
private static final class InjectionAwareInstanceProvider implements InstanceProvider {
private final InstanceProvider delegate;
private final String endpointName;
private final String endpointClass;
private final ServiceName componentPrefix;
private static final String componentSuffix = "START";
private final Map<String, Reference> cache = new HashMap<String, Reference>(8);
private InjectionAwareInstanceProvider(final InstanceProvider delegate, final Endpoint endpoint, final DeploymentUnit unit) {
this.delegate = delegate;
endpointName = endpoint.getShortName();
endpointClass = endpoint.getTargetBeanName();
componentPrefix = unit.getServiceName().append("component");
}
@Override
public synchronized Reference getInstance(final String className) {
Reference instance = cache.get(className);
if (instance != null) return instance;
if (!className.equals(endpointClass)) {
// handle JAXWS handler instantiation
final ServiceName handlerComponentName = getHandlerComponentServiceName(className);
final ServiceController<BasicComponent> handlerComponentController = getComponentController(handlerComponentName);
if (handlerComponentController != null) {
// we support initialization only on non system JAXWS handlers
final BasicComponent handlerComponent = handlerComponentController.getValue();
final ComponentInstance handlerComponentInstance = handlerComponent.createInstance(delegate.getInstance(className).getValue());
final Object handlerInstance = handlerComponentInstance.getInstance();
// mark reference as initialized because JBoss server initialized it
final Reference handlerReference = ReferenceFactory.newInitializedReference(handlerInstance);
return cacheAndGet(handlerReference);
}
}
// fallback for system JAXWS handlers
final Reference fallbackInstance = delegate.getInstance(className);
final Reference fallbackReference = ReferenceFactory.newUninitializedReference(fallbackInstance);
return cacheAndGet(fallbackReference);
}
private Reference cacheAndGet(final Reference instance) {
cache.put(instance.getValue().getClass().getName(), instance);
return instance;
}
private ServiceName getHandlerComponentServiceName(final String handlerClassName) {
return componentPrefix.append(endpointName + "-" + handlerClassName).append(componentSuffix);
}
@SuppressWarnings("unchecked")
private static ServiceController<BasicComponent> getComponentController(final ServiceName componentName) {
return (ServiceController<BasicComponent>) currentServiceContainer().getService(componentName);
}
}
private static ServiceContainer currentServiceContainer() {
if(System.getSecurityManager() == null) {
return CurrentServiceContainer.getServiceContainer();
}
return AccessController.doPrivileged(CurrentServiceContainer.GET_ACTION);
}
}
| 5,989 | 47.306452 | 147 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WebServiceReferences.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.webserviceref;
import static org.jboss.as.webservices.webserviceref.WSRefUtils.processAnnotatedElement;
import static org.wildfly.common.Assert.checkNotNullParam;
import java.lang.reflect.AnnotatedElement;
import jakarta.xml.ws.Service;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.module.ResourceRoot;
import org.jboss.as.webservices.util.ASHelper;
import org.jboss.as.webservices.util.VirtualFileAdaptor;
import org.jboss.modules.Module;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
import org.wildfly.security.manager.WildFlySecurityManager;
/**
* Utility class that encapsulates the creation of web service ref factories.
* <p/>
* This is also used by Weld to perform WS injection.
*
* @author Stuart Douglas
*/
public class WebServiceReferences {
public static ManagedReferenceFactory createWebServiceFactory(final DeploymentUnit deploymentUnit, final String targetType, final WSRefAnnotationWrapper wsRefDescription, final AnnotatedElement target, String bindingName) throws DeploymentUnitProcessingException {
checkNotNullParam("targetType", targetType);
final UnifiedServiceRefMetaData serviceRefUMDM = createServiceRef(deploymentUnit, targetType, wsRefDescription, target, bindingName, bindingName);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
return new WebServiceManagedReferenceFactory(serviceRefUMDM, module.getClassLoader());
}
public static ManagedReferenceFactory createWebServiceFactory(final DeploymentUnit deploymentUnit, final String targetType, final WSRefAnnotationWrapper wsRefDescription, final AnnotatedElement target, String bindingName, final String refKey) throws DeploymentUnitProcessingException {
checkNotNullParam("targetType", targetType);
final UnifiedServiceRefMetaData serviceRefUMDM = createServiceRef(deploymentUnit, targetType, wsRefDescription, target, bindingName, refKey);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
return new WebServiceManagedReferenceFactory(serviceRefUMDM, module.getClassLoader());
}
private static UnifiedServiceRefMetaData createServiceRef(final DeploymentUnit unit, final String type, final WSRefAnnotationWrapper annotation, final AnnotatedElement annotatedElement, final String bindingName, final String refKey) throws DeploymentUnitProcessingException {
final WSRefRegistry wsRefRegistry = ASHelper.getWSRefRegistry(unit);
UnifiedServiceRefMetaData serviceRefUMDM = wsRefRegistry.get(refKey);
if (serviceRefUMDM == null) {
serviceRefUMDM = new UnifiedServiceRefMetaData(getUnifiedVirtualFile(unit), bindingName);
wsRefRegistry.add(refKey, serviceRefUMDM);
}
initServiceRef(unit, serviceRefUMDM, type, annotation);
processWSFeatures(serviceRefUMDM, annotatedElement);
return serviceRefUMDM;
}
private static void processWSFeatures(final UnifiedServiceRefMetaData serviceRefUMDM, final AnnotatedElement annotatedElement) throws DeploymentUnitProcessingException {
processAnnotatedElement(annotatedElement, serviceRefUMDM);
}
private static UnifiedServiceRefMetaData initServiceRef(final DeploymentUnit unit, final UnifiedServiceRefMetaData serviceRefUMDM, final String type, final WSRefAnnotationWrapper annotation) throws DeploymentUnitProcessingException {
// wsdl location
if (!isEmpty(annotation.wsdlLocation())) {
serviceRefUMDM.setWsdlFile(annotation.wsdlLocation());
}
// ref class type
final Module module = unit.getAttachment(Attachments.MODULE);
final Class<?> typeClass = getClass(module, type);
serviceRefUMDM.setServiceRefType(typeClass.getName());
// ref service interface
if (!isEmpty(annotation.value())) {
serviceRefUMDM.setServiceInterface(annotation.value());
} else if (Service.class.isAssignableFrom(typeClass)) {
serviceRefUMDM.setServiceInterface(typeClass.getName());
} else {
serviceRefUMDM.setServiceInterface(Service.class.getName());
}
return serviceRefUMDM;
}
private static Class<?> getClass(final Module module, final String className) throws DeploymentUnitProcessingException { // TODO: refactor to common code
final ClassLoader oldCL = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
if (!isEmpty(className)) {
try {
return module.getClassLoader().loadClass(className);
} catch (ClassNotFoundException e) {
throw new DeploymentUnitProcessingException(e);
}
}
return null;
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldCL);
}
}
private static UnifiedVirtualFile getUnifiedVirtualFile(final DeploymentUnit unit) {
final ResourceRoot resourceRoot = unit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
return new VirtualFileAdaptor(resourceRoot.getRoot());
}
private static boolean isEmpty(final String string) {
return string == null || string.isEmpty();
}
private WebServiceReferences() {
}
}
| 6,799 | 49 | 289 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefDDProcessor.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.webserviceref;
import static org.jboss.as.ee.utils.InjectionUtils.getInjectionTarget;
import static org.jboss.as.webservices.webserviceref.WSRefUtils.processAnnotatedElement;
import static org.jboss.as.webservices.webserviceref.WSRefUtils.translate;
import java.lang.reflect.AccessibleObject;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.jboss.as.ee.component.BindingConfiguration;
import org.jboss.as.ee.component.ComponentDescription;
import org.jboss.as.ee.component.DeploymentDescriptorEnvironment;
import org.jboss.as.ee.component.EEApplicationClasses;
import org.jboss.as.ee.component.FixedInjectionSource;
import org.jboss.as.ee.component.ResourceInjectionTarget;
import org.jboss.as.ee.component.deployers.AbstractDeploymentDescriptorBindingsProcessor;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.module.ResourceRoot;
import org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.util.ASHelper;
import org.jboss.as.webservices.util.VirtualFileAdaptor;
import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
import org.jboss.modules.Module;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
/**
* WebServiceRef DD processor.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class WSRefDDProcessor extends AbstractDeploymentDescriptorBindingsProcessor {
@Override
protected List<BindingConfiguration> processDescriptorEntries(final DeploymentUnit unit, final DeploymentDescriptorEnvironment environment, final ResourceInjectionTarget resourceInjectionTarget, final ComponentDescription componentDescription, final ClassLoader classLoader, final DeploymentReflectionIndex deploymentReflectionIndex, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException {
final ServiceReferencesMetaData serviceRefsMD = environment.getEnvironment().getServiceReferences();
if (serviceRefsMD == null) {
return Collections.<BindingConfiguration> emptyList();
}
final List<BindingConfiguration> bindingDescriptions = new LinkedList<BindingConfiguration>();
for (final ServiceReferenceMetaData serviceRefMD : serviceRefsMD) {
final UnifiedServiceRefMetaData serviceRefUMDM = getServiceRef(unit, componentDescription, serviceRefMD);
final Module module = unit.getAttachment(Attachments.MODULE);
WebServiceManagedReferenceFactory factory = new WebServiceManagedReferenceFactory(serviceRefUMDM, module.getClassLoader());
final FixedInjectionSource valueSource = new FixedInjectionSource(factory, factory);
final BindingConfiguration bindingConfiguration = new BindingConfiguration(serviceRefUMDM.getServiceRefName(), valueSource);
bindingDescriptions.add(bindingConfiguration);
final String serviceRefTypeName = serviceRefUMDM.getServiceRefType();
final Class<?> serviceRefType = getClass(classLoader, serviceRefTypeName);
processInjectionTargets(resourceInjectionTarget, valueSource, classLoader, deploymentReflectionIndex, serviceRefMD, serviceRefType);
}
return bindingDescriptions;
}
private static UnifiedServiceRefMetaData getServiceRef(final DeploymentUnit unit, final ComponentDescription componentDescription, final ServiceReferenceMetaData serviceRefMD) throws DeploymentUnitProcessingException {
//check jaxrpc service refs
if (serviceRefMD.getJaxrpcMappingFile() != null || "javax.xml.rpc.Service".equals(serviceRefMD.getServiceInterface())) {
throw WSLogger.ROOT_LOGGER.jaxRpcNotSupported();
}
// construct service ref
final UnifiedServiceRefMetaData serviceRefUMDM = translate(serviceRefMD);
serviceRefUMDM.setVfsRoot(getUnifiedVirtualFile(unit));
processWSFeatures(unit, serviceRefMD.getInjectionTargets(), serviceRefUMDM);
final WSRefRegistry wsRefRegistry = ASHelper.getWSRefRegistry(unit);
wsRefRegistry.add(getCacheKey(componentDescription, serviceRefUMDM), serviceRefUMDM);
return serviceRefUMDM;
}
private static String getCacheKey(final ComponentDescription componentDescription, final UnifiedServiceRefMetaData serviceRefUMMD) {
if (componentDescription == null) {
return serviceRefUMMD.getServiceRefName();
} else {
return componentDescription.getComponentName() + "/" + serviceRefUMMD.getServiceRefName();
}
}
private static void processWSFeatures(final DeploymentUnit unit, final Set<ResourceInjectionTargetMetaData> injectionTargets, final UnifiedServiceRefMetaData serviceRefUMDM) throws DeploymentUnitProcessingException {
if (injectionTargets == null || injectionTargets.isEmpty()) return;
if (injectionTargets.size() > 1) {
// TODO: We should validate all the injection targets whether they're compatible.
// This means all the injection targets must be assignable or equivalent.
// If there are @Addressing, @RespectBinding or @MTOM annotations present on injection targets,
// these annotations must be equivalent for all the injection targets.
}
final Module module = unit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
final DeploymentReflectionIndex deploymentReflectionIndex = unit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
final ResourceInjectionTargetMetaData injectionTarget = injectionTargets.iterator().next();
final String injectionTargetClassName = injectionTarget.getInjectionTargetClass();
final String injectionTargetName = injectionTarget.getInjectionTargetName();
final AccessibleObject fieldOrMethod = getInjectionTarget(injectionTargetClassName, injectionTargetName, module.getClassLoader(), deploymentReflectionIndex);
processAnnotatedElement(fieldOrMethod, serviceRefUMDM);
}
private Class<?> getClass(final ClassLoader classLoader, final String className) throws DeploymentUnitProcessingException { // TODO: refactor to common code
if (!isEmpty(className)) {
try {
return classLoader.loadClass(className);
} catch (ClassNotFoundException e) {
throw new DeploymentUnitProcessingException(e);
}
}
return null;
}
private static UnifiedVirtualFile getUnifiedVirtualFile(final DeploymentUnit deploymentUnit) { // TODO: refactor to common code
final ResourceRoot resourceRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
return new VirtualFileAdaptor(resourceRoot.getRoot());
}
private static boolean isEmpty(final String string) { // TODO: some common class - StringUtils ?
return string == null || string.isEmpty();
}
}
| 8,474 | 56.263514 | 427 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefRegistry.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.webserviceref;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
/**
* WebServiceRef registry.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class WSRefRegistry {
private final Map<String, UnifiedServiceRefMetaData> references = new HashMap<String, UnifiedServiceRefMetaData>(8);
private WSRefRegistry() {
// forbidden inheritance
}
public static WSRefRegistry newInstance() {
return new WSRefRegistry();
}
public void add(final String refName, final UnifiedServiceRefMetaData serviceRefUMDM) {
if (references.containsKey(refName)) throw new UnsupportedOperationException();
references.put(refName, serviceRefUMDM);
}
public UnifiedServiceRefMetaData get(final String refName) {
return references.get(refName);
}
public Collection<UnifiedServiceRefMetaData> getUnifiedServiceRefMetaDatas() {
return Collections.unmodifiableCollection(references.values());
}
public void clear() {
references.clear();
}
}
| 2,257 | 31.724638 | 120 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WebServiceManagedReferenceFactory.java | package org.jboss.as.webservices.webserviceref;
import org.jboss.as.naming.ImmediateManagedReference;
import org.jboss.as.naming.ManagedReference;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.ws.common.utils.DelegateClassLoader;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
import org.jboss.wsf.spi.serviceref.ServiceRefFactory;
import org.jboss.wsf.spi.serviceref.ServiceRefFactoryFactory;
import org.wildfly.security.manager.WildFlySecurityManager;
/**
* A managed reference factory for web service refs
*
*
* @author Stuart Douglas
*/
public class WebServiceManagedReferenceFactory implements ManagedReferenceFactory {
private final UnifiedServiceRefMetaData serviceRef;
private final ClassLoader classLoader;
public WebServiceManagedReferenceFactory(final UnifiedServiceRefMetaData serviceRef, final ClassLoader classLoader) {
this.serviceRef = serviceRef;
this.classLoader = new DelegateClassLoader(ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader(), classLoader);
}
@Override
public ManagedReference getReference() {
final ClassLoader oldCL = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
final ServiceRefFactory serviceRefFactory = getServiceRefFactory();
return new ImmediateManagedReference(serviceRefFactory.newServiceRef(serviceRef));
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldCL);
}
}
private ServiceRefFactory getServiceRefFactory() {
final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
return spiProvider.getSPI(ServiceRefFactoryFactory.class).newServiceRefFactory();
}
}
| 2,033 | 41.375 | 140 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.webserviceref;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import javax.xml.namespace.QName;
import jakarta.xml.ws.Service;
import jakarta.xml.ws.WebServiceRef;
import jakarta.xml.ws.WebServiceRefs;
import jakarta.xml.ws.soap.MTOM;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.metadata.javaee.jboss.JBossPortComponentRef;
import org.jboss.metadata.javaee.jboss.JBossServiceReferenceMetaData;
import org.jboss.metadata.javaee.jboss.StubPropertyMetaData;
import org.jboss.metadata.javaee.spec.Addressing;
import org.jboss.metadata.javaee.spec.ParamValueMetaData;
import org.jboss.metadata.javaee.spec.PortComponentRef;
import org.jboss.metadata.javaee.spec.ServiceReferenceHandlerChainMetaData;
import org.jboss.metadata.javaee.spec.ServiceReferenceHandlerChainsMetaData;
import org.jboss.metadata.javaee.spec.ServiceReferenceHandlerMetaData;
import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.AddressingMetadata;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.MTOMMetadata;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.RespectBindingMetadata;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainsMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedInitParamMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaDataBuilder;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaDataBuilder;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedStubPropertyMetaData;
/**
* Translates WS Refs from JBossAS MD to JBossWS UMDM format.
*
* Some of the methods on this class are public to allow weld
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
final class WSRefUtils {
private WSRefUtils() {
}
static UnifiedServiceRefMetaData translate(final ServiceReferenceMetaData serviceRefMD) {
UnifiedServiceRefMetaDataBuilder builder = new UnifiedServiceRefMetaDataBuilder();
builder.setServiceRefName(serviceRefMD.getName());
builder.setServiceRefType(serviceRefMD.getServiceRefType());
builder.setServiceInterface(serviceRefMD.getServiceInterface());
builder.setWsdlFile(serviceRefMD.getWsdlFile());
builder.setMappingFile(serviceRefMD.getJaxrpcMappingFile());
builder.setServiceQName(serviceRefMD.getServiceQname());
// propagate port components
final Collection<? extends PortComponentRef> portComponentsMD = serviceRefMD.getPortComponentRef();
if (portComponentsMD != null) {
for (final PortComponentRef portComponentMD : portComponentsMD) {
final UnifiedPortComponentRefMetaData portComponentUMDM = getUnifiedPortComponentRefMetaData(portComponentMD);
if (portComponentUMDM.getServiceEndpointInterface() != null || portComponentUMDM.getPortQName() != null) {
builder.addPortComponentRef(portComponentUMDM);
} else {
WSLogger.ROOT_LOGGER.ignoringPortComponentRef(portComponentUMDM);
}
}
}
// propagate handlers
final Collection<ServiceReferenceHandlerMetaData> handlersMD = serviceRefMD.getHandlers();
if (handlersMD != null) {
for (final ServiceReferenceHandlerMetaData handlerMD : handlersMD) {
final UnifiedHandlerMetaData handlerUMDM = getUnifiedHandlerMetaData(handlerMD);
builder.addHandler(handlerUMDM);
}
}
// propagate handler chains
ServiceReferenceHandlerChainsMetaData handlerChainsMD = serviceRefMD.getHandlerChains();
if (handlerChainsMD != null) {
final UnifiedHandlerChainsMetaData handlerChainsUMDM = getUnifiedHandlerChainsMetaData(handlerChainsMD);
builder.setHandlerChains(handlerChainsUMDM);
}
// propagate jboss specific MD
if (serviceRefMD instanceof JBossServiceReferenceMetaData) {
final JBossServiceReferenceMetaData jbossServiceRefMD = (JBossServiceReferenceMetaData) serviceRefMD;
builder.setServiceImplClass(jbossServiceRefMD.getServiceClass());
builder.setConfigName(jbossServiceRefMD.getConfigName());
builder.setConfigFile(jbossServiceRefMD.getConfigFile());
builder.setWsdlOverride(jbossServiceRefMD.getWsdlOverride());
builder.setHandlerChain(jbossServiceRefMD.getHandlerChain());
}
return builder.build();
}
private static UnifiedPortComponentRefMetaData getUnifiedPortComponentRefMetaData(final PortComponentRef portComponentMD) {
final UnifiedPortComponentRefMetaDataBuilder builder = new UnifiedPortComponentRefMetaDataBuilder();
// propagate service endpoint interface
builder.setServiceEndpointInterface(portComponentMD.getServiceEndpointInterface());
// propagate MTOM properties
builder.setMtomEnabled(portComponentMD.isEnableMtom());
builder.setMtomThreshold(portComponentMD.getMtomThreshold());
// propagate addressing properties
final Addressing addressingMD = portComponentMD.getAddressing();
if (addressingMD != null) {
builder.setAddressingAnnotationSpecified(true);
builder.setAddressingEnabled(addressingMD.isEnabled());
builder.setAddressingRequired(addressingMD.isRequired());
builder.setAddressingResponses(addressingMD.getResponses());
}
// propagate respect binding properties
if (portComponentMD.getRespectBinding() != null) {
builder.setRespectBindingAnnotationSpecified(true);
builder.setRespectBindingEnabled(true);
}
// propagate link
builder.setPortComponentLink(portComponentMD.getPortComponentLink());
// propagate jboss specific MD
if (portComponentMD instanceof JBossPortComponentRef) {
final JBossPortComponentRef jbossPortComponentMD = (JBossPortComponentRef) portComponentMD;
// propagate port QName
builder.setPortQName(jbossPortComponentMD.getPortQname());
// propagate configuration properties
builder.setConfigName(jbossPortComponentMD.getConfigName());
builder.setConfigFile(jbossPortComponentMD.getConfigFile());
// propagate stub properties
final List<StubPropertyMetaData> stubPropertiesMD = jbossPortComponentMD.getStubProperties();
if (stubPropertiesMD != null) {
for (final StubPropertyMetaData stubPropertyMD : stubPropertiesMD) {
builder.addStubProperty(new UnifiedStubPropertyMetaData(stubPropertyMD.getPropName(), stubPropertyMD.getPropValue()));
}
}
}
return builder.build();
}
private static UnifiedHandlerMetaData getUnifiedHandlerMetaData(ServiceReferenceHandlerMetaData srhmd) {
List<UnifiedInitParamMetaData> unifiedInitParamMDs = new LinkedList<UnifiedInitParamMetaData>();
List<ParamValueMetaData> initParams = srhmd.getInitParam();
if (initParams != null) {
for (ParamValueMetaData initParam : initParams) {
unifiedInitParamMDs.add(new UnifiedInitParamMetaData(initParam.getParamName(), initParam.getParamValue()));
}
}
List<QName> soapHeaders = srhmd.getSoapHeader();
Set<QName> soapHeaderList = soapHeaders != null ? new HashSet<QName>(soapHeaders) : null;
List<String> soapRoles = srhmd.getSoapRole();
Set<String> soapRolesList = soapRoles != null ? new HashSet<String>(soapRoles) : null;
List<String> portNames = srhmd.getPortName();
Set<String> portNameList = portNames != null ? new HashSet<String>(portNames) : null;
return new UnifiedHandlerMetaData(srhmd.getHandlerClass(), srhmd.getHandlerName(), unifiedInitParamMDs, soapHeaderList, soapRolesList, portNameList);
}
private static UnifiedHandlerChainsMetaData getUnifiedHandlerChainsMetaData(final ServiceReferenceHandlerChainsMetaData handlerChainsMD) {
List<UnifiedHandlerChainMetaData> uhcmds = new LinkedList<UnifiedHandlerChainMetaData>();
for (final ServiceReferenceHandlerChainMetaData handlerChainMD : handlerChainsMD.getHandlers()) {
List<UnifiedHandlerMetaData> uhmds = new LinkedList<UnifiedHandlerMetaData>();
for (final ServiceReferenceHandlerMetaData handlerMD : handlerChainMD.getHandler()) {
final UnifiedHandlerMetaData handlerUMDM = getUnifiedHandlerMetaData(handlerMD);
uhmds.add(handlerUMDM);
}
uhcmds.add(new UnifiedHandlerChainMetaData(handlerChainMD.getServiceNamePattern(), handlerChainMD.getPortNamePattern(),
handlerChainMD.getProtocolBindings(), uhmds, false, null));
}
return new UnifiedHandlerChainsMetaData(uhcmds);
}
static void processAnnotatedElement(final AnnotatedElement anElement, final UnifiedServiceRefMetaData serviceRefUMDM) {
processAddressingAnnotation(anElement, serviceRefUMDM);
processMTOMAnnotation(anElement, serviceRefUMDM);
processRespectBindingAnnotation(anElement, serviceRefUMDM);
processHandlerChainAnnotation(anElement, serviceRefUMDM);
processServiceRefType(anElement, serviceRefUMDM);
}
private static void processAddressingAnnotation(final AnnotatedElement anElement, final UnifiedServiceRefMetaData serviceRefUMDM) {
final jakarta.xml.ws.soap.Addressing addressingAnnotation = getAnnotation(anElement, jakarta.xml.ws.soap.Addressing.class);
if (addressingAnnotation != null) {
serviceRefUMDM.setAddressingMedadata(new AddressingMetadata(true,
addressingAnnotation.enabled(),
addressingAnnotation.required(),
addressingAnnotation.responses().toString()));
}
}
private static void processMTOMAnnotation(final AnnotatedElement anElement, final UnifiedServiceRefMetaData serviceRefUMDM) {
final MTOM mtomAnnotation = getAnnotation(anElement, MTOM.class);
if (mtomAnnotation != null) {
serviceRefUMDM.setMTOMMetadata(new MTOMMetadata(true, mtomAnnotation.enabled(), mtomAnnotation.threshold()));
}
}
private static void processRespectBindingAnnotation(final AnnotatedElement anElement, final UnifiedServiceRefMetaData serviceRefUMDM) {
final jakarta.xml.ws.RespectBinding respectBindingAnnotation = getAnnotation(anElement, jakarta.xml.ws.RespectBinding.class);
if (respectBindingAnnotation != null) {
serviceRefUMDM.setRespectBindingMetadata(new RespectBindingMetadata(true, respectBindingAnnotation.enabled()));
}
}
private static void processServiceRefType(final AnnotatedElement anElement, final UnifiedServiceRefMetaData serviceRefUMDM) {
if (anElement instanceof Field) {
final Class<?> targetClass = ((Field) anElement).getType();
serviceRefUMDM.setServiceRefType(targetClass.getName());
if (Service.class.isAssignableFrom(targetClass))
serviceRefUMDM.setServiceInterface(targetClass.getName());
} else if (anElement instanceof Method) {
final Class<?> targetClass = ((Method) anElement).getParameterTypes()[0];
serviceRefUMDM.setServiceRefType(targetClass.getName());
if (Service.class.isAssignableFrom(targetClass))
serviceRefUMDM.setServiceInterface(targetClass.getName());
} else {
final WebServiceRef serviceRefAnnotation = getWebServiceRefAnnotation(anElement, serviceRefUMDM);
Class<?> targetClass = null;
if (serviceRefAnnotation != null && (serviceRefAnnotation.type() != Object.class))
{
targetClass = serviceRefAnnotation.type();
serviceRefUMDM.setServiceRefType(targetClass.getName());
if (Service.class.isAssignableFrom(targetClass))
serviceRefUMDM.setServiceInterface(targetClass.getName());
}
}
}
private static void processHandlerChainAnnotation(final AnnotatedElement anElement, final UnifiedServiceRefMetaData serviceRefUMDM) {
final jakarta.jws.HandlerChain handlerChainAnnotation = getAnnotation(anElement, jakarta.jws.HandlerChain.class);
if (handlerChainAnnotation != null) {
// Set the handlerChain from @HandlerChain on the annotated element
String handlerChain = null;
if (handlerChainAnnotation.file().length() > 0)
handlerChain = handlerChainAnnotation.file();
// Resolve path to handler chain
if (handlerChain != null) {
try {
new URL(handlerChain);
} catch (MalformedURLException ignored) {
final Class<?> declaringClass = getDeclaringClass(anElement);
if (declaringClass != null) {
handlerChain = declaringClass.getPackage().getName().replace('.', '/') + "/" + handlerChain;
}
}
serviceRefUMDM.setHandlerChain(handlerChain);
}
}
}
private static <T extends Annotation> T getAnnotation(final AnnotatedElement anElement, final Class<T> annotationClass) {
return anElement != null ? (T) anElement.getAnnotation(annotationClass) : null;
}
private static Class<?> getDeclaringClass(final AnnotatedElement annotatedElement) {
Class<?> declaringClass = null;
if (annotatedElement instanceof Field) {
declaringClass = ((Field) annotatedElement).getDeclaringClass();
} else if (annotatedElement instanceof Method) {
declaringClass = ((Method) annotatedElement).getDeclaringClass();
} else if (annotatedElement instanceof Class) {
declaringClass = (Class<?>) annotatedElement;
}
return declaringClass;
}
private static WebServiceRef getWebServiceRefAnnotation(final AnnotatedElement anElement, final UnifiedServiceRefMetaData serviceRefUMDM) {
final WebServiceRef webServiceRefAnnotation = getAnnotation(anElement, WebServiceRef.class);
final WebServiceRefs webServiceRefsAnnotation = getAnnotation(anElement, WebServiceRefs.class);
if (webServiceRefAnnotation == null && webServiceRefsAnnotation == null) {
return null;
}
// Build the list of @WebServiceRef relevant annotations
final List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
if (webServiceRefAnnotation != null) {
wsrefList.add(webServiceRefAnnotation);
}
if (webServiceRefsAnnotation != null) {
for (final WebServiceRef webServiceRefAnn : webServiceRefsAnnotation.value()) {
wsrefList.add(webServiceRefAnn);
}
}
// Return effective @WebServiceRef annotation
WebServiceRef returnValue = null;
if (wsrefList.size() == 1) {
returnValue = wsrefList.get(0);
} else {
for (WebServiceRef webServiceRefAnn : wsrefList) {
if (serviceRefUMDM.getServiceRefName().endsWith(webServiceRefAnn.name())) {
returnValue = webServiceRefAnn;
break;
}
}
}
return returnValue;
}
}
| 17,355 | 47.752809 | 157 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefAnnotationWrapper.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.webserviceref;
import jakarta.xml.ws.WebServiceRef;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
/**
* WebServiceRef annotation wrapper.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class WSRefAnnotationWrapper {
private final String type;
private final String name;
private final String value;
private final String wsdlLocation;
public WSRefAnnotationWrapper(final AnnotationInstance annotation) {
name = stringValueOrNull(annotation, "name");
type = classValueOrNull(annotation, "type");
value = classValueOrNull(annotation, "value");
wsdlLocation = stringValueOrNull(annotation, "wsdlLocation");
}
public WSRefAnnotationWrapper(final WebServiceRef annotation) {
name = annotation.name().isEmpty() ? null : annotation.name();
type = annotation.type() == Object.class ? null : annotation.type().getName();
value = annotation.value().getName();
wsdlLocation = annotation.wsdlLocation().isEmpty() ? null : annotation.wsdlLocation();
}
public String name() {
return name;
}
public String type() {
return type;
}
public String value() {
return value;
}
public String wsdlLocation() {
return wsdlLocation;
}
private String stringValueOrNull(final AnnotationInstance annotation, final String attribute) {
final AnnotationValue value = annotation.value(attribute);
return value != null ? value.asString() : null;
}
private String classValueOrNull(final AnnotationInstance annotation, final String attribute) {
final AnnotationValue value = annotation.value(attribute);
return value != null ? value.asClass().name().toString() : null;
}
}
| 2,891 | 34.268293 | 99 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefAnnotationProcessor.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.webserviceref;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.AnnotatedElement;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.jboss.as.ee.component.Attachments;
import org.jboss.as.ee.component.BindingConfiguration;
import org.jboss.as.ee.component.ComponentDescription;
import org.jboss.as.ee.component.EEModuleClassDescription;
import org.jboss.as.ee.component.EEModuleDescription;
import org.jboss.as.ee.component.FieldInjectionTarget;
import org.jboss.as.ee.component.FixedInjectionSource;
import org.jboss.as.ee.component.InjectionSource;
import org.jboss.as.ee.component.InjectionTarget;
import org.jboss.as.ee.component.LookupInjectionSource;
import org.jboss.as.ee.component.MethodInjectionTarget;
import org.jboss.as.ee.component.ResourceInjectionConfiguration;
import org.jboss.as.ee.utils.ClassLoadingUtils;
import org.jboss.as.ejb3.component.session.SessionBeanComponentDescription;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.FieldInfo;
import org.jboss.jandex.MethodInfo;
import org.jboss.modules.Module;
import static org.jboss.as.ee.utils.InjectionUtils.getInjectionTarget;
import static org.jboss.as.webservices.util.ASHelper.getAnnotations;
import static org.jboss.as.webservices.util.DotNames.WEB_SERVICE_REFS_ANNOTATION;
import static org.jboss.as.webservices.util.DotNames.WEB_SERVICE_REF_ANNOTATION;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @WebServiceRef annotation processor.
*/
public class WSRefAnnotationProcessor implements DeploymentUnitProcessor {
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
// Process @WebServiceRef annotations
final List<AnnotationInstance> webServiceRefAnnotations = getAnnotations(unit, WEB_SERVICE_REF_ANNOTATION);
for (final AnnotationInstance annotation : webServiceRefAnnotations) {
final AnnotationTarget annotationTarget = annotation.target();
final WSRefAnnotationWrapper annotationWrapper = new WSRefAnnotationWrapper(annotation);
if (annotationTarget instanceof FieldInfo) {
processFieldRef(unit, annotationWrapper, (FieldInfo) annotationTarget);
} else if (annotationTarget instanceof MethodInfo) {
processMethodRef(unit, annotationWrapper, (MethodInfo) annotationTarget);
} else if (annotationTarget instanceof ClassInfo) {
processClassRef(unit, annotationWrapper, (ClassInfo) annotationTarget);
}
}
// Process @WebServiceRefs annotations
final List<AnnotationInstance> webServiceRefsAnnotations = getAnnotations(unit, WEB_SERVICE_REFS_ANNOTATION);
for (final AnnotationInstance outerAnnotation : webServiceRefsAnnotations) {
final AnnotationTarget annotationTarget = outerAnnotation.target();
if (annotationTarget instanceof ClassInfo) {
final AnnotationInstance[] values = outerAnnotation.value("value").asNestedArray();
for (final AnnotationInstance annotation : values) {
final WSRefAnnotationWrapper annotationWrapper = new WSRefAnnotationWrapper(annotation);
processClassRef(unit, annotationWrapper, (ClassInfo) annotationTarget);
}
}
}
}
private static void processFieldRef(final DeploymentUnit unit, final WSRefAnnotationWrapper annotation, final FieldInfo fieldInfo) throws DeploymentUnitProcessingException {
final String fieldName = fieldInfo.name();
final String injectionType = isEmpty(annotation.type()) || annotation.type().equals(Object.class.getName()) ? fieldInfo.type().name().toString() : annotation.type();
final InjectionTarget injectionTarget = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, injectionType);
final String bindingName = isEmpty(annotation.name()) ? fieldInfo.declaringClass().name().toString() + "/" + fieldInfo.name() : annotation.name();
processRef(unit, injectionType, annotation, fieldInfo.declaringClass(), injectionTarget, bindingName);
}
private static void processMethodRef(final DeploymentUnit unit, final WSRefAnnotationWrapper annotation, final MethodInfo methodInfo) throws DeploymentUnitProcessingException {
final String methodName = methodInfo.name();
if (!methodName.startsWith("set") || methodInfo.args().length != 1) {
throw WSLogger.ROOT_LOGGER.invalidServiceRefSetterMethodName(methodInfo);
}
final String injectionType = isEmpty(annotation.type()) || annotation.type().equals(Object.class.getName()) ? methodInfo.args()[0].name().toString() : annotation.type();
final InjectionTarget injectionTarget = new MethodInjectionTarget(methodInfo.declaringClass().name().toString(), methodName, injectionType);
final String bindingName = isEmpty(annotation.name()) ? methodInfo.declaringClass().name().toString() + "/" + methodName.substring(3, 4).toLowerCase(Locale.ENGLISH) + methodName.substring(4) : annotation.name();
processRef(unit, injectionType, annotation, methodInfo.declaringClass(), injectionTarget, bindingName);
}
private static void processClassRef(final DeploymentUnit unit, final WSRefAnnotationWrapper annotation, final ClassInfo classInfo) throws DeploymentUnitProcessingException {
if (isEmpty(annotation.name())) {
throw WSLogger.ROOT_LOGGER.requiredServiceRefName();
}
if (isEmpty(annotation.type())) {
throw WSLogger.ROOT_LOGGER.requiredServiceRefType();
}
processRef(unit, annotation.type(), annotation, classInfo, null, annotation.name());
}
private static void processRef(final DeploymentUnit unit, final String type, final WSRefAnnotationWrapper annotation, final ClassInfo classInfo, final InjectionTarget injectionTarget, final String bindingName) throws DeploymentUnitProcessingException {
final EEModuleDescription moduleDescription = unit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final AnnotatedElement target = createAnnotatedElement(unit, classInfo, injectionTarget);
final String componentClassName = classInfo.name().toString();
final Map<String, String> bindingMap = new HashMap<String, String>();
boolean isEJB = false;
for (final ComponentDescription componentDescription : moduleDescription.getComponentsByClassName(componentClassName)) {
if (componentDescription instanceof SessionBeanComponentDescription) {
isEJB = true;
bindingMap.put(componentDescription.getComponentName() + "/" + bindingName, bindingName);
}
}
if (!isEJB) {
bindingMap.put(bindingName, bindingName);
}
for (String refKey : bindingMap.keySet()) {
String refName = bindingMap.get(refKey);
ManagedReferenceFactory factory = WebServiceReferences.createWebServiceFactory(unit, type, annotation, target, refName, refKey);
final EEModuleClassDescription classDescription = moduleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
// Create the binding from whence our injection comes.
final InjectionSource serviceRefSource = new FixedInjectionSource(factory, factory);
final BindingConfiguration bindingConfiguration = new BindingConfiguration(refName, serviceRefSource);
classDescription.getBindingConfigurations().add(bindingConfiguration);
// our injection comes from the local lookup, no matter what.
final ResourceInjectionConfiguration injectionConfiguration = injectionTarget != null ?
new ResourceInjectionConfiguration(injectionTarget, new LookupInjectionSource(refName)) : null;
if (injectionConfiguration != null) {
classDescription.addResourceInjection(injectionConfiguration);
}
}
}
private static AnnotatedElement createAnnotatedElement(final DeploymentUnit unit, final ClassInfo classInfo, final InjectionTarget injectionTarget) throws DeploymentUnitProcessingException {
if (injectionTarget == null) {
return elementForInjectionTarget(unit, classInfo);
} else {
return elementForInjectionTarget(unit, injectionTarget);
}
}
private static AnnotatedElement elementForInjectionTarget(final DeploymentUnit unit, final ClassInfo classInfo) throws DeploymentUnitProcessingException {
final Class<?> target = getClass(unit, classInfo.name().toString());
return target;
}
private static AnnotatedElement elementForInjectionTarget(final DeploymentUnit unit, final InjectionTarget injectionTarget) throws DeploymentUnitProcessingException {
final Module module = unit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
final DeploymentReflectionIndex deploymentReflectionIndex = unit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
final String injectionTargetClassName = injectionTarget.getClassName();
final String injectionTargetName = getInjectionTargetName(injectionTarget);
final AccessibleObject fieldOrMethod = getInjectionTarget(injectionTargetClassName, injectionTargetName, module.getClassLoader(), deploymentReflectionIndex);
return fieldOrMethod;
}
private static String getInjectionTargetName(final InjectionTarget injectionTarget) {
final String name = injectionTarget.getName();
if (injectionTarget instanceof FieldInjectionTarget) {
return name;
} else if (injectionTarget instanceof MethodInjectionTarget) {
return name.substring(3, 4).toUpperCase(Locale.ENGLISH) + name.substring(4);
}
throw new UnsupportedOperationException();
}
private static Class<?> getClass(final DeploymentUnit du, final String className) throws DeploymentUnitProcessingException { // TODO: refactor to common code
if (!isEmpty(className)) {
try {
return ClassLoadingUtils.loadClass(className, du);
} catch (ClassNotFoundException e) {
throw new DeploymentUnitProcessingException(e);
}
}
return null;
}
private static boolean isEmpty(final String string) { // TODO: some common class - StringUtils ?
return string == null || string.isEmpty();
}
}
| 12,301 | 55.431193 | 256 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/verification/JwsWebServiceEndpointVerifier.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.verification;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import jakarta.jws.WebMethod;
import org.jboss.as.server.deployment.reflect.ClassReflectionIndex;
import org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex;
import org.jboss.as.webservices.logging.WSLogger;
/**
* Verifies the structural correctness of JSR-181 style web services.
* <ul>
* <li>web methods must not be static or final
* <li>web methods must be public
* <li>web service implementation class must not declare a finalize method
* <ul>
* <br>
* We don't check for the @WebService annotation or whether the class is abstract, final or public because these checks are
* performed by {@link org.jboss.as.webservices.util.ASHelper.isJaxwsEndpoint(ClassInfo, CompositeIndex)} from {@link
* org.jboss.as.webservices.deployers.AbstractIntegrationProcessorJAXWS.deploy(DeploymentPhaseContext)}.<br>
*
* @author sfcoy
*
*/
public final class JwsWebServiceEndpointVerifier {
private final DeploymentReflectionIndex deploymentReflectionIndex;
private final Class<?> endpointClass;
private final Class<?> endpointInterfaceClass;
final List<VerificationFailure> verificationFailures = new LinkedList<VerificationFailure>();
public JwsWebServiceEndpointVerifier(Class<?> endpointClass, Class<?> endpointInterfaceClass,
DeploymentReflectionIndex deploymentReflectionIndex) {
this.deploymentReflectionIndex = deploymentReflectionIndex;
this.endpointClass = endpointClass;
this.endpointInterfaceClass = endpointInterfaceClass;
}
public void verify() {
if (endpointInterfaceClass != null) {
for (Method endpointInterfaceDefinedWebMethod : endpointInterfaceDefinedWebMethods()) {
verifyWebMethod(endpointInterfaceDefinedWebMethod);
}
} // else implicit web methods are valid by definition
verifyFinalizeMethod();
}
public boolean failed() {
return !verificationFailures.isEmpty();
}
public void logFailures() {
for (VerificationFailure verificationFailure : verificationFailures)
verificationFailure.logFailure();
}
void verifyWebMethod(final Method endpointInterfaceDefinedWebMethod) {
final Method endpointImplementationMethod = findEndpointImplMethodMatching(endpointInterfaceDefinedWebMethod);
if (endpointImplementationMethod != null) {
final int methodModifiers = endpointImplementationMethod.getModifiers();
final WebMethod possibleWebMethodAnnotation = endpointImplementationMethod.getAnnotation(WebMethod.class);
if (possibleWebMethodAnnotation == null || !possibleWebMethodAnnotation.exclude()) {
if (Modifier.isPublic(methodModifiers)) {
if (Modifier.isStatic(methodModifiers) || Modifier.isFinal(methodModifiers)) {
verificationFailures.add(new WebMethodIsStaticOrFinal(endpointImplementationMethod));
}
} else {
verificationFailures.add(new WebMethodIsNotPublic(endpointImplementationMethod));
}
}
}
}
void verifyFinalizeMethod() {
ClassReflectionIndex classReflectionIndex = deploymentReflectionIndex.getClassIndex(endpointClass);
Method finalizeMethod = classReflectionIndex.getMethod(void.class, "finalize");
if (finalizeMethod != null) {
verificationFailures.add(new ImplementationHasFinalize());
}
}
Collection<Method> endpointInterfaceDefinedWebMethods() {
return deploymentReflectionIndex.getClassIndex(endpointInterfaceClass).getMethods();
}
Method findEndpointImplMethodMatching(final Method endpointInterfaceDefinedWebMethod) {
try {
return endpointClass.getMethod(endpointInterfaceDefinedWebMethod.getName(),
endpointInterfaceDefinedWebMethod.getParameterTypes());
} catch (NoSuchMethodException e) {
try {
return endpointClass.getDeclaredMethod(endpointInterfaceDefinedWebMethod.getName(),
endpointInterfaceDefinedWebMethod.getParameterTypes());
} catch (NoSuchMethodException e1) {
verificationFailures.add(new WebServiceMethodNotFound(endpointInterfaceDefinedWebMethod));
}
} catch (SecurityException e) {
verificationFailures.add(new WebServiceMethodNotAccessible(endpointInterfaceDefinedWebMethod, e));
}
return null;
}
abstract class VerificationFailure {
abstract void logFailure();
}
abstract class MethodVerificationFailure extends VerificationFailure {
protected final Method failedMethod;
protected MethodVerificationFailure(Method failedMethod) {
this.failedMethod = failedMethod;
}
}
final class ImplementationHasFinalize extends VerificationFailure {
@Override
public void logFailure() {
WSLogger.ROOT_LOGGER.finalizeMethodNotAllowed(endpointClass);
}
}
final class WebMethodIsStaticOrFinal extends MethodVerificationFailure {
WebMethodIsStaticOrFinal(Method failedMethod) {
super(failedMethod);
}
@Override
public void logFailure() {
WSLogger.ROOT_LOGGER.webMethodMustNotBeStaticOrFinal(failedMethod);
}
}
final class WebMethodIsNotPublic extends MethodVerificationFailure {
WebMethodIsNotPublic(Method failedMethod) {
super(failedMethod);
}
@Override
public void logFailure() {
WSLogger.ROOT_LOGGER.webMethodMustBePublic(failedMethod);
}
}
final class WebServiceMethodNotFound extends MethodVerificationFailure {
WebServiceMethodNotFound(Method failedMethod) {
super(failedMethod);
}
@Override
public void logFailure() {
WSLogger.ROOT_LOGGER.webServiceMethodNotFound(endpointClass, failedMethod);
}
}
final class WebServiceMethodNotAccessible extends MethodVerificationFailure {
private final SecurityException securityException;
WebServiceMethodNotAccessible(Method failedMethod, SecurityException e) {
super(failedMethod);
this.securityException = e;
}
@Override
public void logFailure() {
WSLogger.ROOT_LOGGER.accessibleWebServiceMethodNotFound(endpointClass, failedMethod, securityException);
}
}
}
| 7,777 | 35.688679 | 123 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/publish/EndpointPublisherFactoryImpl.java | /*
* JBoss, Home of Professional Open Source
* Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package org.jboss.as.webservices.publish;
import static org.jboss.as.webservices.util.ASHelper.getMSCService;
import org.jboss.as.web.host.WebHost;
import org.jboss.wsf.spi.publish.EndpointPublisher;
import org.jboss.wsf.spi.publish.EndpointPublisherFactory;
/**
* Factory for retrieving an EndpointPublisher instance for the currently running JBoss Application Server container.
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class EndpointPublisherFactoryImpl implements EndpointPublisherFactory {
public EndpointPublisher newEndpointPublisher(final String hostname) {
return new EndpointPublisherImpl(getMSCService(WebHost.SERVICE_NAME.append(hostname), WebHost.class));
}
}
| 1,778 | 43.475 | 117 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/publish/EndpointPublisherImpl.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.publish;
import java.io.File;
import java.security.AccessController;
import java.util.concurrent.CountDownLatch;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.server.CurrentServiceContainer;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.web.host.ServletBuilder;
import org.jboss.as.web.host.WebDeploymentBuilder;
import org.jboss.as.web.host.WebDeploymentController;
import org.jboss.as.web.host.WebHost;
import org.jboss.as.webservices.config.ServerConfigFactoryImpl;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.deployers.AllowWSRequestPredicate;
import org.jboss.as.webservices.deployers.EndpointServiceDeploymentAspect;
import org.jboss.as.webservices.deployers.deployment.DeploymentAspectsProvider;
import org.jboss.as.webservices.deployers.deployment.WSDeploymentBuilder;
import org.jboss.as.webservices.service.EndpointService;
import org.jboss.as.webservices.util.WSAttachmentKeys;
import org.jboss.metadata.javaee.spec.ParamValueMetaData;
import org.jboss.metadata.web.jboss.JBossServletMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.spec.ServletMappingMetaData;
import org.jboss.msc.service.LifecycleEvent;
import org.jboss.msc.service.LifecycleListener;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceRegistry;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.ws.common.deployment.DeploymentAspectManagerImpl;
import org.jboss.ws.common.deployment.EndpointHandlerDeploymentAspect;
import org.jboss.ws.common.integration.AbstractDeploymentAspect;
import org.jboss.ws.common.invocation.InvocationHandlerJAXWS;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
import org.jboss.wsf.spi.deployment.DeploymentAspectManager;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.WSFServlet;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
import org.jboss.wsf.spi.publish.Context;
import org.jboss.wsf.spi.publish.EndpointPublisher;
import org.wildfly.security.manager.WildFlySecurityManager;
/**
* WS endpoint publisher, allows for publishing a WS endpoint on AS 7
*
* @author [email protected]
* @authro <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class EndpointPublisherImpl implements EndpointPublisher {
private final WebHost host;
private final boolean runningInService;
private static List<DeploymentAspect> publisherDepAspects = null;
private static List<DeploymentAspect> depAspects = null;
protected EndpointPublisherImpl(WebHost host) {
this(host, false);
}
protected EndpointPublisherImpl(WebHost host, boolean runningInService) {
this.host = host;
this.runningInService = runningInService;
}
protected EndpointPublisherImpl(boolean runningInService) {
this(null, runningInService);
}
@Override
public Context publish(String context, ClassLoader loader, Map<String, String> urlPatternToClassNameMap) throws Exception {
return publish(currentServiceContainer(), context, loader, urlPatternToClassNameMap, null, null, null, null);
}
@Override
public Context publish(String context, ClassLoader loader, Map<String, String> urlPatternToClassNameMap, WebservicesMetaData metadata) throws Exception {
return publish(currentServiceContainer(), context, loader, urlPatternToClassNameMap, null, metadata, null, null);
}
@Override
public Context publish(String context, ClassLoader loader, Map<String, String> urlPatternToClassNameMap,
WebservicesMetaData metadata, JBossWebservicesMetaData jbwsMetadata) throws Exception {
return publish(currentServiceContainer(), context, loader, urlPatternToClassNameMap, null, metadata, jbwsMetadata, null);
}
protected Context publish(ServiceTarget target, String context, ClassLoader loader,
Map<String, String> urlPatternToClassNameMap, JBossWebMetaData jbwmd, WebservicesMetaData metadata,
JBossWebservicesMetaData jbwsMetadata, CapabilityServiceSupport capabilityServiceSupport)
throws Exception {
DeploymentUnit unit = doPrepare(context, loader, urlPatternToClassNameMap, jbwmd, metadata, jbwsMetadata, capabilityServiceSupport);
doDeploy(target, unit);
return doPublish(target, unit);
}
/**
* Prepare the ws Deployment and return a DeploymentUnit containing it
*
* @param context
* @param loader
* @param urlPatternToClassNameMap
* @param jbwmd
* @param metadata
* @param jbwsMetadata
* @return
*/
protected DeploymentUnit doPrepare(String context, ClassLoader loader,
Map<String, String> urlPatternToClassNameMap, JBossWebMetaData jbwmd, WebservicesMetaData metadata,
JBossWebservicesMetaData jbwsMetadata, CapabilityServiceSupport capabilityServiceSupport) {
ClassLoader origClassLoader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
WSEndpointDeploymentUnit unit = new WSEndpointDeploymentUnit(loader, context, urlPatternToClassNameMap,
jbwmd, metadata, jbwsMetadata, capabilityServiceSupport);
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
WSDeploymentBuilder.getInstance().build(unit);
return unit;
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(origClassLoader);
}
}
/**
* Triggers the WS deployment aspects, which process the deployment and
* install the endpoint services.
*
* @param target
* @param unit
*/
protected void doDeploy(ServiceTarget target, DeploymentUnit unit) {
List<DeploymentAspect> aspects = getDeploymentAspects();
ClassLoader origClassLoader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
Deployment dep = null;
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
dep = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
dep.addAttachment(ServiceTarget.class, target);
DeploymentAspectManager dam = new DeploymentAspectManagerImpl();
dam.setDeploymentAspects(aspects);
dam.deploy(dep);
} finally {
if (dep != null) {
dep.removeAttachment(ServiceTarget.class);
}
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(origClassLoader);
}
}
/**
* Publish the webapp for the WS deployment unit
*
* @param target
* @param unit
* @return
* @throws Exception
*/
protected Context doPublish(ServiceTarget target, DeploymentUnit unit) throws Exception {
final Deployment deployment = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
final List<Endpoint> endpoints = deployment.getService().getEndpoints();
//If we're running in a Service, that will already have proper dependencies set on the installed endpoint services,
//otherwise we need to explicitly wait for the endpoint services to be started before creating the webapp.
if (!runningInService) {
final ServiceRegistry registry = unit.getServiceRegistry();
final CountDownLatch latch = new CountDownLatch(endpoints.size());
final LifecycleListener listener = new LifecycleListener() {
@Override
public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
if (event == LifecycleEvent.UP) {
latch.countDown();
controller.removeListener(this);
}
}
};
ServiceName serviceName;
for (Endpoint ep : endpoints) {
serviceName = EndpointService.getServiceName(unit, ep.getShortName());
registry.getRequiredService(serviceName).addListener(listener);
}
latch.await();
}
deployment.addAttachment(WebDeploymentController.class, startWebApp(host, unit)); //TODO simplify and use findChild later in destroy()/stopWebApp()
return new Context(unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY).getContextRoot(), endpoints);
}
private static WebDeploymentController startWebApp(WebHost host, DeploymentUnit unit) throws Exception {
WebDeploymentBuilder deployment = new WebDeploymentBuilder();
WebDeploymentController handle;
try {
JBossWebMetaData jbwebMD = unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY);
deployment.setContextRoot(jbwebMD.getContextRoot());
File docBase = new File(ServerConfigFactoryImpl.getConfig().getServerTempDir(), jbwebMD.getContextRoot());
if (!docBase.exists()) {
docBase.mkdirs();
}
deployment.setDocumentRoot(docBase);
deployment.setClassLoader(unit.getAttachment(WSAttachmentKeys.CLASSLOADER_KEY));
deployment.addAllowedRequestPredicate(new AllowWSRequestPredicate());
addServlets(jbwebMD, deployment);
handle = host.addWebDeployment(deployment);
handle.create();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.createContextPhaseFailed(e);
}
try {
handle.start();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.startContextPhaseFailed(e);
}
return handle;
}
private static void addServlets(JBossWebMetaData jbwebMD, WebDeploymentBuilder deployment) {
for (JBossServletMetaData smd : jbwebMD.getServlets()) {
final String sc = smd.getServletClass();
if (sc.equals(WSFServlet.class.getName())) {
ServletBuilder servletBuilder = new ServletBuilder();
final String servletName = smd.getServletName();
List<ParamValueMetaData> params = smd.getInitParam();
List<String> urlPatterns = null;
for (ServletMappingMetaData smmd : jbwebMD.getServletMappings()) {
if (smmd.getServletName().equals(servletName)) {
urlPatterns = smmd.getUrlPatterns();
servletBuilder.addUrlMappings(urlPatterns);
break;
}
}
WSFServlet wsfs = new WSFServlet();
servletBuilder.setServletName(servletName);
servletBuilder.setServlet(wsfs);
servletBuilder.setServletClass(WSFServlet.class);
for (ParamValueMetaData param : params) {
servletBuilder.addInitParam(param.getParamName(), param.getParamValue());
}
deployment.addServlet(servletBuilder);
}
}
}
@Override
public void destroy(Context context) throws Exception {
List<Endpoint> eps = context.getEndpoints();
if (eps == null || eps.isEmpty()) {
return;
}
Deployment dep = eps.get(0).getService().getDeployment();
try {
stopWebApp(dep);
} finally {
undeploy(dep);
}
}
/**
* Triggers the WS deployment aspects, which process
* the deployment unit and stop the endpoint services.
*
* @throws Exception
*/
protected void undeploy(DeploymentUnit unit) throws Exception {
undeploy(unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY));
}
protected void undeploy(Deployment deployment) throws Exception {
List<DeploymentAspect> aspects = getDeploymentAspects();
ClassLoader origClassLoader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
DeploymentAspectManager dam = new DeploymentAspectManagerImpl();
dam.setDeploymentAspects(aspects);
dam.undeploy(deployment);
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(origClassLoader);
}
}
/**
* Stops the webapp serving the provided ws deployment
*
* @param deployment
* @throws Exception
*/
protected void stopWebApp(Deployment deployment) throws Exception {
WebDeploymentController context;
try {
context = deployment.getAttachment(WebDeploymentController.class);
context.stop();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.stopContextPhaseFailed(e);
}
try {
context.destroy();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.destroyContextPhaseFailed(e);
}
}
private List<DeploymentAspect> getDeploymentAspects() {
return runningInService ? getReplacedDeploymentAspects() : getPublisherDeploymentAspects();
}
private static synchronized List<DeploymentAspect> getReplacedDeploymentAspects() {
if (depAspects == null) {
depAspects = new LinkedList<DeploymentAspect>();
List<DeploymentAspect> serverAspects = DeploymentAspectsProvider.getSortedDeploymentAspects();
for (DeploymentAspect aspect : serverAspects) {
if(aspect instanceof EndpointHandlerDeploymentAspect) {
depAspects.add(aspect);
//add another aspect to set InvocationHandlerJAXWS to each endpoint
ForceJAXWSInvocationHandlerDeploymentAspect handlerAspect = new ForceJAXWSInvocationHandlerDeploymentAspect();
depAspects.add(handlerAspect);
} else {
depAspects.add(aspect);
}
}
}
return depAspects;
}
private static synchronized List<DeploymentAspect> getPublisherDeploymentAspects() {
if (publisherDepAspects == null) {
publisherDepAspects = new LinkedList<DeploymentAspect>();
// copy to replace the EndpointServiceDeploymentAspect
List<DeploymentAspect> serverAspects = DeploymentAspectsProvider.getSortedDeploymentAspects();
for (DeploymentAspect aspect : serverAspects) {
if (aspect instanceof EndpointServiceDeploymentAspect) {
final EndpointServiceDeploymentAspect a = (EndpointServiceDeploymentAspect) aspect;
EndpointServiceDeploymentAspect clone = (EndpointServiceDeploymentAspect) (a.clone());
clone.setStopServices(true);
publisherDepAspects.add(clone);
} else if(aspect instanceof EndpointHandlerDeploymentAspect) {
publisherDepAspects.add(aspect);
//add another aspect to set InvocationHandlerJAXWS to each endpoint
ForceJAXWSInvocationHandlerDeploymentAspect handlerAspect = new ForceJAXWSInvocationHandlerDeploymentAspect();
publisherDepAspects.add(handlerAspect);
} else {
publisherDepAspects.add(aspect);
}
}
}
return publisherDepAspects;
}
static class ForceJAXWSInvocationHandlerDeploymentAspect extends AbstractDeploymentAspect {
public ForceJAXWSInvocationHandlerDeploymentAspect() {
}
@Override
public void start(final Deployment dep) {
for (final Endpoint ep : dep.getService().getEndpoints()) {
ep.setInvocationHandler(new InvocationHandlerJAXWS());
}
}
}
private static ServiceContainer currentServiceContainer() {
if(System.getSecurityManager() == null) {
return CurrentServiceContainer.getServiceContainer();
}
return AccessController.doPrivileged(CurrentServiceContainer.GET_ACTION);
}
}
| 17,863 | 44.571429 | 157 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/publish/WSEndpointDeploymentUnit.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.publish;
import java.security.AccessController;
import java.util.Map;
import java.util.StringTokenizer;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.server.CurrentServiceContainer;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.SimpleAttachable;
import org.jboss.as.webservices.metadata.model.JAXWSDeployment;
import org.jboss.as.webservices.metadata.model.POJOEndpoint;
import org.jboss.as.webservices.util.WSAttachmentKeys;
import org.jboss.dmr.ModelNode;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
public class WSEndpointDeploymentUnit extends SimpleAttachable implements DeploymentUnit {
private String deploymentName;
public WSEndpointDeploymentUnit(ClassLoader loader, String context, Map<String,String> urlPatternToClassName, WebservicesMetaData metadata) {
this(loader, context, urlPatternToClassName, new JBossWebMetaData(), metadata, null, null);
}
public WSEndpointDeploymentUnit(ClassLoader loader, String context, Map<String, String> urlPatternToClassName,
JBossWebMetaData jbossWebMetaData, WebservicesMetaData metadata, JBossWebservicesMetaData jbwsMetaData,
CapabilityServiceSupport capabilityServiceSupport) {
this.deploymentName = context + ".deployment";
JAXWSDeployment jaxwsDeployment = new JAXWSDeployment();
if (jbossWebMetaData == null) {
jbossWebMetaData = new JBossWebMetaData();
}
jbossWebMetaData.setContextRoot(context);
String endpointName = null;
String className = null;
for (String urlPattern : urlPatternToClassName.keySet()) {
className = urlPatternToClassName.get(urlPattern);
endpointName = getShortName(className, urlPattern);
addEndpoint(jbossWebMetaData, jaxwsDeployment, endpointName, className, urlPattern);
}
this.putAttachment(WSAttachmentKeys.CLASSLOADER_KEY, loader);
this.putAttachment(WSAttachmentKeys.JAXWS_ENDPOINTS_KEY, jaxwsDeployment);
this.putAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY, jbossWebMetaData);
if (metadata != null) {
this.putAttachment(WSAttachmentKeys.WEBSERVICES_METADATA_KEY, metadata);
}
if (jbwsMetaData != null) {
this.putAttachment(WSAttachmentKeys.JBOSS_WEBSERVICES_METADATA_KEY, jbwsMetaData);
}
if (capabilityServiceSupport != null) {
this.putAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT, capabilityServiceSupport);
}
}
private String getShortName(String className, String urlPattern) {
final StringTokenizer st = new StringTokenizer(urlPattern, "/*");
final StringBuilder sb = new StringBuilder();
String token = null;
boolean first = true;
while (st.hasMoreTokens()) {
token = st.nextToken();
if (token != null) {
if (!first) sb.append('.');
sb.append(token);
first = false;
}
}
return first ? className : sb.toString();
}
private void addEndpoint(JBossWebMetaData jbossWebMetaData, JAXWSDeployment jaxwsDeployment, String endpointName, String className, String urlPattern) {
if (urlPattern == null) {
urlPattern = "/*";
} else {
urlPattern = urlPattern.trim();
if (!urlPattern.startsWith("/")) {
urlPattern = "/" + urlPattern;
}
}
jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointName, className, null, urlPattern, false));
}
@Override
public ServiceName getServiceName() {
return ServiceName.JBOSS.append("ws-endpoint-deployment").append(deploymentName);
}
@Override
public DeploymentUnit getParent() {
return null;
}
@Override
public String getName() {
return deploymentName;
}
@Override
public ServiceRegistry getServiceRegistry() {
return currentServiceContainer();
}
//@Override
public ModelNode getDeploymentSubsystemModel(String subsystemName) {
throw new UnsupportedOperationException();
}
//@Override
public ModelNode createDeploymentSubModel(String subsystemName, PathElement address) {
throw new UnsupportedOperationException();
}
//@Override
public ModelNode createDeploymentSubModel(String subsystemName, PathAddress address) {
throw new UnsupportedOperationException();
}
//@Override
public ModelNode createDeploymentSubModel(String subsystemName, PathAddress address, Resource resource) {
throw new UnsupportedOperationException();
}
private static ServiceContainer currentServiceContainer() {
if(System.getSecurityManager() == null) {
return CurrentServiceContainer.getServiceContainer();
}
return AccessController.doPrivileged(CurrentServiceContainer.GET_ACTION);
}
}
| 6,553 | 39.708075 | 156 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/publish/EndpointPublisherHelper.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.publish;
import java.util.List;
import java.util.Map;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.web.host.WebHost;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
import org.jboss.wsf.spi.publish.Context;
/**
* Helper methods for publishing endpoints
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
*
*/
public class EndpointPublisherHelper {
public static Context doPublishStep(WebHost host, ServiceTarget target, DeploymentUnit unit) throws Exception {
EndpointPublisherImpl publisher = new EndpointPublisherImpl(host, true);
return publisher.doPublish(target, unit);
}
public static void undoPublishStep(WebHost host, Context wsctx) throws Exception {
List<Endpoint> eps = wsctx.getEndpoints();
if (eps == null || eps.isEmpty()) {
return;
}
EndpointPublisherImpl publisher = new EndpointPublisherImpl(host, true);
publisher.stopWebApp(eps.get(0).getService().getDeployment());
}
public static void doDeployStep(ServiceTarget target, DeploymentUnit unit) {
EndpointPublisherImpl publisher = new EndpointPublisherImpl(true);
publisher.doDeploy(target, unit);
}
public static void undoDeployStep(DeploymentUnit unit) throws Exception {
EndpointPublisherImpl publisher = new EndpointPublisherImpl(true);
publisher.undeploy(unit);
}
public static DeploymentUnit doPrepareStep(String context, ClassLoader loader, Map<String, String> urlPatternToClassName,
JBossWebMetaData jbwmd, WebservicesMetaData wsmd, JBossWebservicesMetaData jbwsmd, CapabilityServiceSupport capabilityServiceSupport) {
EndpointPublisherImpl publisher = new EndpointPublisherImpl(null, true);
return publisher.doPrepare(context, loader, urlPatternToClassName, jbwmd, wsmd, jbwsmd, capabilityServiceSupport);
}
}
| 3,279 | 42.733333 | 147 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/Constants.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or =at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.dmr;
/**
* @author <a href="mailto:[email protected]">Darran Lofthouse</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
interface Constants {
String ID = "id";
String CLASS = "class";
String MODIFY_WSDL_ADDRESS = "modify-wsdl-address";
String WSDL_HOST = "wsdl-host";
String WSDL_PORT = "wsdl-port";
String WSDL_SECURE_PORT = "wsdl-secure-port";
String WSDL_URI_SCHEME = "wsdl-uri-scheme";
String ENDPOINT = "endpoint";
String ENDPOINT_NAME = "name";
String ENDPOINT_CONTEXT = "context";
String ENDPOINT_CLASS = "class";
String ENDPOINT_TYPE = "type";
String ENDPOINT_WSDL = "wsdl-url";
String ENDPOINT_CONFIG = "endpoint-config";
String CLIENT_CONFIG = "client-config";
String CONFIG_NAME = "config-name";
String NAME = "name";
String PROPERTY="property";
String PROPERTY_NAME="property-name";
String PROPERTY_VALUE="property-value";
String PRE_HANDLER_CHAIN="pre-handler-chain";
String PRE_HANDLER_CHAINS="pre-handler-chains";
String POST_HANDLER_CHAIN="post-handler-chain";
String POST_HANDLER_CHAINS="post-handler-chains";
String HANDLER_CHAIN="handler-chain";
String PROTOCOL_BINDINGS="protocol-bindings";
String HANDLER="handler";
String HANDLER_NAME="handler-name";
String HANDLER_CLASS="handler-class";
String VALUE = "value";
String STATISTICS_ENABLED = "statistics-enabled";
String WSDL_PATH_REWRITE_RULE = "wsdl-path-rewrite-rule";
}
| 2,565 | 40.387097 | 75 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/EndpointConfigAdd.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.dmr;
import static org.jboss.as.webservices.dmr.PackageUtils.getEndpointConfigServiceName;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.webservices.service.ConfigService;
import org.jboss.as.webservices.service.PropertyService;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.wsf.spi.metadata.config.AbstractCommonConfig;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
/**
* @author <a href="[email protected]">Jim Ma</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
*/
final class EndpointConfigAdd extends AbstractAddStepHandler {
static final EndpointConfigAdd INSTANCE = new EndpointConfigAdd();
private EndpointConfigAdd() {
// forbidden instantiation
}
@Override
protected void populateModel(final ModelNode operation, final ModelNode model) {
// does nothing
}
@Override
protected void rollbackRuntime(OperationContext context, ModelNode operation, Resource resource) {
super.rollbackRuntime(context, operation, resource);
if (!context.isBooting()) {
context.revertReloadRequired();
}
}
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
//modify the runtime if we're booting, otherwise set reload required and leave the runtime unchanged
if (context.isBooting()) {
final PathAddress address = context.getCurrentAddress();
final String name = context.getCurrentAddressValue();
final ServiceName serviceName = getEndpointConfigServiceName(name);
final ServiceTarget target = context.getServiceTarget();
final ServiceBuilder<?> serviceBuilder = target.addService(serviceName);
final List<Supplier<PropertyService>> propertySuppliers = new ArrayList<>();
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PROPERTY)) {
propertySuppliers.add(serviceBuilder.requires(sn));
}
final List<Supplier<UnifiedHandlerChainMetaData>> preHandlerChainSuppliers = new ArrayList<>();
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PRE_HANDLER_CHAIN)) {
preHandlerChainSuppliers.add(serviceBuilder.requires(sn));
}
final List<Supplier<UnifiedHandlerChainMetaData>> postHandlerChainSuppliers = new ArrayList<>();
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.POST_HANDLER_CHAIN)) {
postHandlerChainSuppliers.add(serviceBuilder.requires(sn));
}
final Consumer<AbstractCommonConfig> config = serviceBuilder.provides(serviceName);
serviceBuilder.setInstance(new ConfigService(name, false, config, propertySuppliers, preHandlerChainSuppliers, postHandlerChainSuppliers));
serviceBuilder.install();
} else {
context.reloadRequired();
}
}
}
| 4,744 | 45.980198 | 150 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSEndpointMetrics.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.dmr;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.util.ServiceContainerEndpointRegistry;
import org.jboss.as.webservices.util.WSServices;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.management.EndpointMetrics;
/**
* Provides WS endpoint metrics.
*
* @author <a href="mailto:[email protected]">Jim Ma</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
final class WSEndpointMetrics implements OperationStepHandler {
static final WSEndpointMetrics INSTANCE = new WSEndpointMetrics();
static final AttributeDefinition MIN_PROCESSING_TIME = new SimpleAttributeDefinitionBuilder("min-processing-time", ModelType.INT, false)
.setUndefinedMetricValue(ModelNode.ZERO)
.setStorageRuntime()
.build();
static final AttributeDefinition MAX_PROCESSING_TIME = new SimpleAttributeDefinitionBuilder("max-processing-time", ModelType.INT, false)
.setUndefinedMetricValue(ModelNode.ZERO)
.setStorageRuntime()
.build();
static final AttributeDefinition AVERAGE_PROCESSING_TIME = new SimpleAttributeDefinitionBuilder("average-processing-time", ModelType.INT, false)
.setUndefinedMetricValue(ModelNode.ZERO)
.setStorageRuntime()
.build();
static final AttributeDefinition TOTAL_PROCESSING_TIME = new SimpleAttributeDefinitionBuilder("total-processing-time", ModelType.INT, false)
.setUndefinedMetricValue(ModelNode.ZERO)
.setStorageRuntime()
.build();
static final AttributeDefinition REQUEST_COUNT = new SimpleAttributeDefinitionBuilder("request-count", ModelType.INT, false)
.setUndefinedMetricValue(ModelNode.ZERO)
.setStorageRuntime()
.build();
static final AttributeDefinition RESPONSE_COUNT = new SimpleAttributeDefinitionBuilder("response-count", ModelType.INT, false)
.setUndefinedMetricValue(ModelNode.ZERO)
.setStorageRuntime()
.build();
static final AttributeDefinition FAULT_COUNT = new SimpleAttributeDefinitionBuilder("fault-count", ModelType.INT, false)
.setUndefinedMetricValue(ModelNode.ZERO)
.setStorageRuntime()
.build();
static final AttributeDefinition[] ATTRIBUTES = {MIN_PROCESSING_TIME, MAX_PROCESSING_TIME, AVERAGE_PROCESSING_TIME,
TOTAL_PROCESSING_TIME, REQUEST_COUNT, RESPONSE_COUNT, FAULT_COUNT};
private WSEndpointMetrics() {
}
/**
* {@inheritDoc}
*/
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
if (context.isNormalServer()) {
context.addStep(new OperationStepHandler() {
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final ServiceRegistry registry = context.getServiceRegistry(false);
if (registry != null) {
try {
context.getResult().set(getEndpointMetricsFragment(operation, registry));
} catch (Exception e) {
throw new OperationFailedException(getFallbackMessage() + ": " + e.getMessage());
}
} else {
context.getResult().set(getFallbackMessage());
}
}
}, OperationContext.Stage.RUNTIME);
} else {
context.getResult().set(getFallbackMessage());
}
}
@SuppressWarnings("unchecked")
private ModelNode getEndpointMetricsFragment(final ModelNode operation, final ServiceRegistry registry) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
String endpointId;
try {
endpointId = URLDecoder.decode(address.getLastElement().getValue(), "UTF-8");
} catch (final UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
final String metricName = operation.require(NAME).asString();
final String webContext = endpointId.substring(0, endpointId.indexOf(":"));
final String endpointName = endpointId.substring(endpointId.indexOf(":") + 1);
ServiceName endpointSN = WSServices.ENDPOINT_SERVICE.append("context="+webContext).append(endpointName);
Endpoint endpoint = ServiceContainerEndpointRegistry.getEndpoint(endpointSN);
if (endpoint == null) {
throw new OperationFailedException(WSLogger.ROOT_LOGGER.noMetricsAvailable());
}
final ModelNode result = new ModelNode();
final EndpointMetrics endpointMetrics = endpoint.getEndpointMetrics();
if (endpointMetrics != null) {
if (MIN_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getMinProcessingTime());
} else if (MAX_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getMaxProcessingTime());
} else if (AVERAGE_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getAverageProcessingTime());
} else if (TOTAL_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getTotalProcessingTime());
} else if (REQUEST_COUNT.getName().equals(metricName)) {
result.set(endpointMetrics.getRequestCount());
} else if (RESPONSE_COUNT.getName().equals(metricName)) {
result.set(endpointMetrics.getResponseCount());
} else if (FAULT_COUNT.getName().equals(metricName)) {
result.set(endpointMetrics.getFaultCount());
}
}
return result;
}
private static String getFallbackMessage() {
return WSLogger.ROOT_LOGGER.noMetricsAvailable();
}
}
| 7,785 | 47.360248 | 148 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/ModelDeploymentAspect.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.dmr;
import static org.jboss.as.webservices.dmr.Constants.ENDPOINT;
import static org.jboss.as.webservices.dmr.Constants.ENDPOINT_CLASS;
import static org.jboss.as.webservices.dmr.Constants.ENDPOINT_CONTEXT;
import static org.jboss.as.webservices.dmr.Constants.ENDPOINT_NAME;
import static org.jboss.as.webservices.dmr.Constants.ENDPOINT_TYPE;
import static org.jboss.as.webservices.dmr.Constants.ENDPOINT_WSDL;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import org.jboss.as.controller.PathElement;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentResourceSupport;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.webservices.publish.WSEndpointDeploymentUnit;
import org.jboss.dmr.ModelNode;
import org.jboss.ws.common.integration.AbstractDeploymentAspect;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
/**
* Deployment aspect that modifies DMR WS endpoint model.
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
public final class ModelDeploymentAspect extends AbstractDeploymentAspect {
public ModelDeploymentAspect() {
super();
}
@Override
public void start(final Deployment dep) {
final DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class);
if (unit instanceof WSEndpointDeploymentUnit) return;
final DeploymentResourceSupport deploymentResourceSupport = unit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
for (final Endpoint endpoint : dep.getService().getEndpoints()) {
final ModelNode endpointModel;
try {
endpointModel = deploymentResourceSupport.getDeploymentSubModel(WSExtension.SUBSYSTEM_NAME,
PathElement.pathElement(ENDPOINT, URLEncoder.encode(getId(endpoint), "UTF-8")));
} catch (final UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
endpointModel.get(ENDPOINT_NAME).set(getName(endpoint));
endpointModel.get(ENDPOINT_CONTEXT).set(getContext(endpoint));
endpointModel.get(ENDPOINT_CLASS).set(endpoint.getTargetBeanName());
endpointModel.get(ENDPOINT_TYPE).set(endpoint.getType().toString());
endpointModel.get(ENDPOINT_WSDL).set(endpoint.getAddress() + "?wsdl");
}
}
@Override
public void stop(final Deployment dep) {
//
}
private String getName(final Endpoint endpoint) {
return endpoint.getName().getKeyProperty(Endpoint.SEPID_PROPERTY_ENDPOINT);
}
private String getContext(final Endpoint endpoint) {
return endpoint.getName().getKeyProperty(Endpoint.SEPID_PROPERTY_CONTEXT);
}
private String getId(final Endpoint endpoint) {
final StringBuilder sb = new StringBuilder();
sb.append(getContext(endpoint));
sb.append(':');
sb.append(getName(endpoint));
return sb.toString();
}
}
| 4,114 | 39.343137 | 128 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/Element.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.dmr;
import java.util.HashMap;
import java.util.Map;
/**
* WS configuration elements.
*
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
enum Element {
/** always the first **/
UNKNOWN(null),
SUBSYSTEM("subsystem"),
MODIFY_WSDL_ADDRESS(Constants.MODIFY_WSDL_ADDRESS),
WSDL_HOST(Constants.WSDL_HOST),
WSDL_PORT(Constants.WSDL_PORT),
WSDL_SECURE_PORT(Constants.WSDL_SECURE_PORT),
WSDL_URI_SCHEME(Constants.WSDL_URI_SCHEME),
WSDL_PATH_REWRITE_RULE(Constants.WSDL_PATH_REWRITE_RULE),
CLIENT_CONFIG(Constants.CLIENT_CONFIG),
ENDPOINT_CONFIG(Constants.ENDPOINT_CONFIG),
CONFIG_NAME(Constants.CONFIG_NAME),
PROPERTY(Constants.PROPERTY),
PROPERTY_NAME(Constants.PROPERTY_NAME),
PROPERTY_VALUE(Constants.PROPERTY_VALUE),
PRE_HANDLER_CHAIN(Constants.PRE_HANDLER_CHAIN),
POST_HANDLER_CHAIN(Constants.POST_HANDLER_CHAIN),
PRE_HANDLER_CHAINS(Constants.PRE_HANDLER_CHAINS),
POST_HANDLER_CHAINS(Constants.POST_HANDLER_CHAINS),
HANDLER_CHAIN(Constants.HANDLER_CHAIN),
PROTOCOL_BINDINGS(Constants.PROTOCOL_BINDINGS),
HANDLER(Constants.HANDLER),
HANDLER_NAME(Constants.HANDLER_NAME),
HANDLER_CLASS(Constants.HANDLER_CLASS);
private final String name;
private Element(final String name) {
this.name = name;
}
private static final Map<String, Element> MAP;
static {
final Map<String, Element> map = new HashMap<String, Element>();
for (final Element element : values()) {
final String name = element.getLocalName();
if (name != null)
map.put(name, element);
}
MAP = map;
}
static Element forName(final String localName) {
final Element element = MAP.get(localName);
return element == null ? UNKNOWN : element;
}
/**
* Get the local name of this element.
*
* @return the local name
*/
String getLocalName() {
return name;
}
}
| 3,132 | 32.688172 | 73 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/PackageUtils.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.dmr;
import static org.jboss.as.webservices.dmr.Constants.ENDPOINT_CONFIG;
import static org.jboss.as.webservices.dmr.Constants.HANDLER;
import static org.jboss.as.webservices.dmr.Constants.PROPERTY;
import java.util.LinkedList;
import java.util.List;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.webservices.util.WSServices;
import org.jboss.msc.service.ServiceName;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
*/
final class PackageUtils {
private PackageUtils() {
// forbidden instantiation
}
static ServiceName getEndpointConfigServiceName(String configName) {
return WSServices.ENDPOINT_CONFIG_SERVICE.append(configName);
}
static ServiceName getClientConfigServiceName(String configName) {
return WSServices.CLIENT_CONFIG_SERVICE.append(configName);
}
static ServiceName getConfigServiceName(final String configType, final String configName) {
return (ENDPOINT_CONFIG.equals(configType) ? getEndpointConfigServiceName(configName) : getClientConfigServiceName(configName));
}
static ServiceName getHandlerChainServiceName(final ServiceName configServiceName, final String handlerChainType, final String handlerChainId) {
return configServiceName.append(handlerChainType).append(handlerChainId);
}
static ServiceName getHandlerServiceName(final ServiceName handlerChainServiceName, final String handlerName) {
return handlerChainServiceName.append(HANDLER).append(handlerName);
}
static ServiceName getPropertyServiceName(final ServiceName configServiceName, final String propertyName) {
return configServiceName.append(PROPERTY).append(propertyName);
}
static List<ServiceName> getServiceNameDependencies(final OperationContext context, final ServiceName baseServiceName, final PathAddress address, final String childType) {
final List<ServiceName> childrenServiceNames = new LinkedList<ServiceName>();
final Resource resource = context.readResourceFromRoot(address, false);
final ServiceName sn = baseServiceName.append(childType);
for (String name : resource.getChildrenNames(childType)) {
childrenServiceNames.add(sn.append(name));
}
return childrenServiceNames;
}
}
| 3,543 | 42.219512 | 175 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSDeploymentActivator.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.dmr;
import java.util.List;
import org.jboss.as.server.DeploymentProcessorTarget;
import org.jboss.as.server.deployment.Phase;
import org.jboss.as.webservices.deployers.AspectDeploymentProcessor;
import org.jboss.as.webservices.deployers.GracefulShutdownIntegrationProcessor;
import org.jboss.as.webservices.deployers.JBossWebservicesDescriptorDeploymentProcessor;
import org.jboss.as.webservices.deployers.WSClassVerificationProcessor;
import org.jboss.as.webservices.deployers.WSDependenciesProcessor;
import org.jboss.as.webservices.deployers.WSIntegrationProcessorJAXWS_EJB;
import org.jboss.as.webservices.deployers.WSIntegrationProcessorJAXWS_HANDLER;
import org.jboss.as.webservices.deployers.WSIntegrationProcessorJAXWS_JMS;
import org.jboss.as.webservices.deployers.WSIntegrationProcessorJAXWS_POJO;
import org.jboss.as.webservices.deployers.WSLibraryFilterProcessor;
import org.jboss.as.webservices.deployers.WSModelDeploymentProcessor;
import org.jboss.as.webservices.deployers.WSServiceDependenciesProcessor;
import org.jboss.as.webservices.deployers.WebServiceAnnotationProcessor;
import org.jboss.as.webservices.deployers.WebServicesContextJndiSetupProcessor;
import org.jboss.as.webservices.deployers.WebservicesDescriptorDeploymentProcessor;
import org.jboss.as.webservices.deployers.deployment.DeploymentAspectsProvider;
import org.jboss.as.webservices.injection.WSHandlerChainAnnotationProcessor;
import org.jboss.as.webservices.logging.WSLogger;
import org.jboss.as.webservices.util.ModuleClassLoaderProvider;
import org.jboss.as.webservices.webserviceref.WSRefAnnotationProcessor;
import org.jboss.as.webservices.webserviceref.WSRefDDProcessor;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
/**
* @author [email protected]
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
final class WSDeploymentActivator {
static void activate(final DeploymentProcessorTarget processorTarget, final boolean appclient) {
if (!isModularEnvironment()) {
return;
}
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_WS_REF_DESCRIPTOR, new WSRefDDProcessor());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_WS_REF_ANNOTATION, new WSRefAnnotationProcessor());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_WS, new WSDependenciesProcessor(!appclient));
if (!appclient) {
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_WEBSERVICES_CONTEXT_INJECTION, new WebServicesContextJndiSetupProcessor());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_WEBSERVICES_LIBRARY_FILTER, new WSLibraryFilterProcessor());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_WEBSERVICES_XML, new WebservicesDescriptorDeploymentProcessor());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_JBOSS_WEBSERVICES_XML, new JBossWebservicesDescriptorDeploymentProcessor());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_WEBSERVICES_ANNOTATION, new WebServiceAnnotationProcessor());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_JAXWS_EJB_INTEGRATION, new WSIntegrationProcessorJAXWS_EJB());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_JAXWS_HANDLER_CHAIN_ANNOTATION, new WSHandlerChainAnnotationProcessor());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_WS_JMS_INTEGRATION, new WSIntegrationProcessorJAXWS_JMS());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_JAXWS_ENDPOINT_CREATE_COMPONENT_DESCRIPTIONS, new WSIntegrationProcessorJAXWS_POJO());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_JAXWS_HANDLER_CREATE_COMPONENT_DESCRIPTIONS, new WSIntegrationProcessorJAXWS_HANDLER());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_WS_SERVICES_DEPS, new WSServiceDependenciesProcessor());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_WS_VERIFICATION, new WSClassVerificationProcessor());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_WS_VERIFICATION, new GracefulShutdownIntegrationProcessor());
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_WS_UNIVERSAL_META_DATA_MODEL, new WSModelDeploymentProcessor());
addDeploymentProcessors(processorTarget, Phase.INSTALL, Phase.INSTALL_WS_DEPLOYMENT_ASPECTS);
}
}
private static void addDeploymentProcessors(final DeploymentProcessorTarget processorTarget, final Phase phase, final int priority) {
int index = 1;
List<DeploymentAspect> aspects = DeploymentAspectsProvider.getSortedDeploymentAspects();
for (final DeploymentAspect da : aspects) {
if (WSLogger.ROOT_LOGGER.isTraceEnabled()) {
WSLogger.ROOT_LOGGER.tracef("Installing aspect %s", da.getClass().getName());
}
processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, phase, priority + index++, new AspectDeploymentProcessor(da));
}
}
private static boolean isModularEnvironment() {
try {
ModuleClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
return true;
} catch (Exception e) {
WSLogger.ROOT_LOGGER.couldNotActivateSubsystem(e);
return false;
}
}
}
| 7,129 | 66.904762 | 192 | java |
null | wildfly-main/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/ClientConfigAdd.java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* 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.dmr;
import static org.jboss.as.webservices.dmr.PackageUtils.getClientConfigServiceName;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.webservices.service.ConfigService;
import org.jboss.as.webservices.service.PropertyService;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.wsf.spi.metadata.config.AbstractCommonConfig;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
/**
* @author <a href="mailto:[email protected]">Richard Opalka</a>
* @author <a href="mailto:[email protected]">Alessio Soldano</a>
*/
final class ClientConfigAdd extends AbstractAddStepHandler {
static final ClientConfigAdd INSTANCE = new ClientConfigAdd();
private ClientConfigAdd() {
// forbidden instantiation
}
@Override
protected void populateModel(final ModelNode operation, final ModelNode model) {
// does nothing
}
@Override
protected void rollbackRuntime(OperationContext context, ModelNode operation, Resource resource) {
super.rollbackRuntime(context, operation, resource);
if (!context.isBooting()) {
context.revertReloadRequired();
}
}
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
//modify the runtime if we're booting, otherwise set reload required and leave the runtime unchanged
if (context.isBooting()) {
final PathAddress address = context.getCurrentAddress();
final String name = context.getCurrentAddressValue();
final ServiceName serviceName = getClientConfigServiceName(name);
final ServiceTarget target = context.getServiceTarget();
final ServiceBuilder<?> clientServiceBuilder = target.addService(serviceName);
final List<Supplier<PropertyService>> propertySuppliers = new ArrayList<>();
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PROPERTY)) {
propertySuppliers.add(clientServiceBuilder.requires(sn));
}
final List<Supplier<UnifiedHandlerChainMetaData>> preHandlerChainSuppliers = new ArrayList<>();
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PRE_HANDLER_CHAIN)) {
preHandlerChainSuppliers.add(clientServiceBuilder.requires(sn));
}
final List<Supplier<UnifiedHandlerChainMetaData>> postHandlerChainSuppliers = new ArrayList<>();
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.POST_HANDLER_CHAIN)) {
postHandlerChainSuppliers.add(clientServiceBuilder.requires(sn));
}
final Consumer<AbstractCommonConfig> config = clientServiceBuilder.provides(serviceName);
clientServiceBuilder.setInstance(new ConfigService(name, true, config, propertySuppliers, preHandlerChainSuppliers, postHandlerChainSuppliers));
clientServiceBuilder.install();
} else {
context.reloadRequired();
}
}
}
| 4,676 | 45.77 | 153 | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.