making the certificate management war adhere the REST API guidelines

4.x.x
prabathabey 9 years ago
parent f5aa2c5eb1
commit d65174d026

@ -48,7 +48,7 @@
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<configuration> <configuration>
<packagingExcludes>WEB-INF/lib/*cxf*.jar</packagingExcludes> <packagingExcludes>WEB-INF/lib/*cxf*.jar</packagingExcludes>
<warName>admin-certificate</warName> <warName>api#certificate-mgt#v1.0</warName>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
@ -75,7 +75,7 @@
<copy todir="${basedir}/../../../repository/deployment/server/webapps" <copy todir="${basedir}/../../../repository/deployment/server/webapps"
overwrite="true"> overwrite="true">
<fileset dir="${basedir}/target"> <fileset dir="${basedir}/target">
<include name="admin-certificate.war"/> <include name="api#certificate-mgt#v1.0.war"/>
</fileset> </fileset>
</copy> </copy>
</tasks> </tasks>

@ -13,7 +13,7 @@ import javax.ws.rs.core.Response;
@Api(value = "Certificate Management", description = "This API carries all certificate management related operations " + @Api(value = "Certificate Management", description = "This API carries all certificate management related operations " +
"such as get all the available devices, etc.") "such as get all the available devices, etc.")
@Path("/certificates") @Path("/admin/certificates")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public interface CertificateManagementAdminService { public interface CertificateManagementAdminService {

@ -0,0 +1,44 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. 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.wso2.carbon.certificate.mgt.cert.jaxrs.api.util;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class ApiOriginFilter implements Filter {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response);
}
public void destroy() {
//do nothing
}
public void init(FilterConfig filterConfig) throws ServletException {
//do nothing
}
}

@ -26,6 +26,7 @@
<jaxrs:server id="services" address="/"> <jaxrs:server id="services" address="/">
<jaxrs:serviceBeans> <jaxrs:serviceBeans>
<ref bean="certificateServiceBean"/>
<ref bean="swaggerResource"/> <ref bean="swaggerResource"/>
</jaxrs:serviceBeans> </jaxrs:serviceBeans>
<jaxrs:providers> <jaxrs:providers>
@ -34,15 +35,6 @@
<ref bean="swaggerWriter"/> <ref bean="swaggerWriter"/>
</jaxrs:providers> </jaxrs:providers>
</jaxrs:server> </jaxrs:server>
<jaxrs:server id="certificateService" address="/certificates">
<jaxrs:serviceBeans>
<ref bean="certificateServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers"/> <bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers"/>
<bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource"/> <bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource"/>
@ -51,8 +43,9 @@
<property name="resourcePackage" value="org.wso2.carbon.certificate.mgt.cert.jaxrs.api"/> <property name="resourcePackage" value="org.wso2.carbon.certificate.mgt.cert.jaxrs.api"/>
<property name="version" value="1.0.0"/> <property name="version" value="1.0.0"/>
<property name="host" value="localhost:9443"/> <property name="host" value="localhost:9443"/>
<property name="basePath" value="/"/> <property name="schemes" value="https" />
<property name="title" value="Device Management Admin Service API Definitions"/> <property name="basePath" value="/api/certificate-mgt/v1.0"/>
<property name="title" value="Certificate Management Admin Service API Definitions"/>
<property name="contact" value="dev@wso2.org"/> <property name="contact" value="dev@wso2.org"/>
<property name="license" value="Apache 2.0"/> <property name="license" value="Apache 2.0"/>
<property name="licenseUrl" value="http://www.apache.org/licenses/LICENSE-2.0.html"/> <property name="licenseUrl" value="http://www.apache.org/licenses/LICENSE-2.0.html"/>

@ -25,6 +25,11 @@
<servlet-class> <servlet-class>
org.apache.cxf.transport.servlet.CXFServlet org.apache.cxf.transport.servlet.CXFServlet
</servlet-class> </servlet-class>
<init-param>
<param-name>swagger.security.filter</param-name>
<param-value>ApiAuthorizationFilterImpl</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>CXFServlet</servlet-name> <servlet-name>CXFServlet</servlet-name>
@ -63,4 +68,14 @@
</user-data-constraint> </user-data-constraint>
</security-constraint> </security-constraint>
<filter>
<filter-name>ApiOriginFilter</filter-name>
<filter-class>org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util.ApiOriginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ApiOriginFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app> </web-app>

@ -59,7 +59,7 @@
<outputDirectory> <outputDirectory>
${project.build.directory}/maven-shared-archive-resources/webapps ${project.build.directory}/maven-shared-archive-resources/webapps
</outputDirectory> </outputDirectory>
<destFileName>admin-certificate.war</destFileName> <destFileName>api#certificate-mgt#v1.0.war</destFileName>
</artifactItem> </artifactItem>
</artifactItems> </artifactItems>
</configuration> </configuration>

@ -1,2 +1,2 @@
instructions.configure = \ instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.certificate.mgt.cert.admin.api_${feature.version}/webapps/admin-certificate.war,target:${installFolder}/../../deployment/server/webapps/admin-certificate.war,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.certificate.mgt.cert.admin.api_${feature.version}/webapps/api#certificate-mgt#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#certificate-mgt#v1.0.war,overwrite:true);\
Loading…
Cancel
Save