diff options
Diffstat (limited to '')
5 files changed, 159 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java index 04b2f4c199..46f819d6b9 100644 --- a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java +++ b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java @@ -132,6 +132,10 @@ public class DefaultServletHostExtensionPoint implements ServletHostExtensionPoi public void addServletMapping(String uri, Servlet servlet) throws ServletMappingException { getServletHost().addServletMapping(uri, servlet); } + + public void addServletMapping(String uri, Servlet servlet, SecurityContext securityContext) throws ServletMappingException { + getServletHost().addServletMapping(uri, servlet, securityContext); + } public String getContextPath() { return getServletHost().getContextPath(); diff --git a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java index 4dfa1dd8a3..668b069bf9 100644 --- a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java +++ b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java @@ -68,6 +68,16 @@ public class ExtensibleServletHost implements ServletHost { // For now just select the first one getDefaultServletHost().addServletMapping(uri, servlet); } + + public void addServletMapping(String uri, Servlet servlet, SecurityContext securityContext) throws ServletMappingException { + if (servletHosts.getServletHosts().isEmpty()) { + throw new ServletMappingException("No servlet host available"); + } + + // TODO implement selection of the correct Servlet host based on the mapping + // For now just select the first one + getDefaultServletHost().addServletMapping(uri, servlet, securityContext); + } public Servlet getServletMapping(String uri) throws ServletMappingException { if (servletHosts.getServletHosts().isEmpty()) { diff --git a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java new file mode 100644 index 0000000000..f290bb3e59 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +package org.apache.tuscany.sca.host.http; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +/** + * A class to store policy context to enable Security QoS to + * HTTP binding + */ +public class SecurityContext { + private boolean isSSLEnabled = false; + private Properties sslProperties; + + private boolean isAuthenticationEnabled = false; + private List<UserContext> users = new ArrayList<UserContext>(); + + public boolean isSSLEnabled() { + return isSSLEnabled; + } + + public void setSSLEnabled(boolean value) { + this.isSSLEnabled = value; + } + + public Properties getSSLProperties() { + return sslProperties; + } + + public void setSSLProperties(Properties sslProperties) { + this.sslProperties = sslProperties; + } + + public boolean isAuthenticationEnabled() { + return this.isAuthenticationEnabled; + } + + public void setAuthenticationEnabled(boolean value) { + this.isAuthenticationEnabled = value; + } + + public List<UserContext> getUsers() { + return this.users; + } +} diff --git a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java index 07a54c1c37..6747472bc1 100644 --- a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java +++ b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java @@ -58,6 +58,19 @@ public interface ServletHost { * @throws ServletMappingException */ void addServletMapping(String uri, Servlet servlet) throws ServletMappingException; + + /** + * Add a mapping for an instance of a Servlet. This requests that the + * Servlet container direct all requests to the designated mapping to the + * supplied Servlet instance. SecurityContext can be passed to enable + * QoS services such as Confidentiality (SSL) and Authentication/Authorization + * + * @param uri the URI-mapping for the Servlet + * @param servlet the Servlet that should be invoked + * @param securityContext the SecurityContext to enable QoS services + * @throws ServletMappingException + */ + void addServletMapping(String uri, Servlet servlet, SecurityContext securityContext) throws ServletMappingException; /** * Remove a Servlet mapping. This directs the Servlet container not to direct diff --git a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java new file mode 100644 index 0000000000..4a19eda81d --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +package org.apache.tuscany.sca.host.http; + +import java.util.ArrayList; +import java.util.List; + +/** + * Model class used to define list of users and it's roles + * + * These info is used to configure authentication/authorization + * in embedded http servers + * + * @version $Rev$ $Date$ + */ +public class UserContext { + private String username; + private String password; + private List<String> roles = new ArrayList<String>(); + + + public UserContext() { + + } + + public UserContext(String username, String password) { + this.username = username; + this.password = password; + } + + public String getUsername() { + return this.username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return this.password; + } + + public void setPassword(String password) { + this.password = password; + } + + public List<String> getRoles() { + return this.roles; + } + +} |