Author: owulff
Date: Tue Nov 12 21:01:56 2013
New Revision: 1541233
URL: http://svn.apache.org/r1541233
Log:
Initial work on REST interface for IDP
Added:
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPServices.java
Modified:
cxf/fediz/trunk/services/idp/pom.xml
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/IDPConfig.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/ServiceConfig.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/TrustedIDPConfig.java
cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/applicationContext.xml
cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml
Modified: cxf/fediz/trunk/services/idp/pom.xml
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/pom.xml?rev=1541233&r1=1541232&r2=1541233&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/pom.xml (original)
+++ cxf/fediz/trunk/services/idp/pom.xml Tue Nov 12 21:01:56 2013
@@ -119,6 +119,11 @@
<artifactId>commons-lang3</artifactId>
<version>3.0.1</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
</dependencies>
<build>
<resources>
Modified:
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/IDPConfig.java
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/IDPConfig.java?rev=1541233&r1=1541232&r2=1541233&view=diff
==============================================================================
---
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/IDPConfig.java
(original)
+++
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/IDPConfig.java
Tue Nov 12 21:01:56 2013
@@ -27,8 +27,13 @@ import java.util.Map;
//import javax.persistence.Id;
//import javax.persistence.Table;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
//@Entity
//@Table(name = "IDP")
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "IDP", namespace = "http://org.apache.cxf.fediz")
public class IDPConfig implements Serializable {
//@Id
@@ -183,6 +188,8 @@ public class IDPConfig implements Serial
this.supportedProtocols = supportedProtocols;
}
+ @GET
+ @Path("services")
public Map<String, ServiceConfig> getServices() {
return services;
}
@@ -191,6 +198,8 @@ public class IDPConfig implements Serial
this.services = services;
}
+ @GET
+ @Path("trusted-idp")
public Map<String, TrustedIDPConfig> getTrustedIDPs() {
return trustedIDPs;
}
Modified:
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/ServiceConfig.java
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/ServiceConfig.java?rev=1541233&r1=1541232&r2=1541233&view=diff
==============================================================================
---
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/ServiceConfig.java
(original)
+++
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/ServiceConfig.java
Tue Nov 12 21:01:56 2013
@@ -21,6 +21,8 @@ package org.apache.cxf.fediz.service.idp
import java.io.Serializable;
import java.util.List;
+import javax.xml.bind.annotation.XmlRootElement;
+
//import javax.persistence.Column;
//import javax.persistence.Entity;
//import javax.persistence.Id;
@@ -28,6 +30,7 @@ import java.util.List;
//@Entity
//@Table(name = "SERVICE")
+@XmlRootElement(name = "Service", namespace = "http://org.apache.cxf.fediz")
public class ServiceConfig implements Serializable {
Modified:
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/TrustedIDPConfig.java
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/TrustedIDPConfig.java?rev=1541233&r1=1541232&r2=1541233&view=diff
==============================================================================
---
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/TrustedIDPConfig.java
(original)
+++
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/TrustedIDPConfig.java
Tue Nov 12 21:01:56 2013
@@ -20,6 +20,8 @@ package org.apache.cxf.fediz.service.idp
import java.io.Serializable;
+import javax.xml.bind.annotation.XmlRootElement;
+
//import javax.persistence.Column;
//import javax.persistence.Entity;
@@ -28,6 +30,7 @@ import java.io.Serializable;
//@Entity
//@Table(name = "TRUSTEDIDP")
+@XmlRootElement(name = "TrustedIDP", namespace = "http://org.apache.cxf.fediz")
public class TrustedIDPConfig implements Serializable {
Added:
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPServices.java
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPServices.java?rev=1541233&view=auto
==============================================================================
---
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPServices.java
(added)
+++
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPServices.java
Tue Nov 12 21:01:56 2013
@@ -0,0 +1,111 @@
+/**
+ * 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.cxf.fediz.service.idp.rest;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.fediz.service.idp.model.IDPConfig;
+import org.apache.cxf.fediz.service.idp.service.ConfigService;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path("/idp")
+@Produces("text/xml")
+public class IDPServices {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(IDPServices.class);
+
+ private ConfigService configService;
+
+ public IDPServices() {
+ }
+
+
+ @GET
+ @Path("/{id}/")
+ public IDPConfig getIDP(@PathParam("id") String id) {
+ LOG.info("get IDP config: " + id);
+
+ return configService.getIDPConfig(id);
+ }
+
+ @PUT
+ @Path("/idp/")
+ public Response updateIDP(IDPConfig idp) {
+ LOG.info("update IDP config: " + idp.getRealm());
+
+ IDPConfig idpConfig = configService.getIDPConfig(idp.getRealm());
+ Response r;
+ if (idpConfig != null) {
+ //configService.put(idp.getRealm(), idp);
+ r = Response.ok().build();
+ } else {
+ r = Response.notModified().build();
+ }
+
+ return r;
+ }
+
+ @POST
+ @Path("/")
+ public Response addIDP(IDPConfig idp) {
+ LOG.info("add IDP config: " + idp.getRealm());
+
+ //configService.put(idp.getRealm(), idp);
+
+ return Response.ok(idp).build();
+ }
+
+ @DELETE
+ @Path("/{id}/")
+ public Response deleteIDP(@PathParam("id") String id) {
+ LOG.info("delete IDP config: " + id);
+
+ IDPConfig config = configService.getIDPConfig(id);
+
+ Response r;
+ if (config != null) {
+ r = Response.ok().build();
+ //configService.remove(config);
+ } else {
+ r = Response.notModified().build();
+ }
+
+ return r;
+ }
+
+
+ public ConfigService getConfigService() {
+ return configService;
+ }
+
+ public void setConfigService(ConfigService configService) {
+ this.configService = configService;
+ }
+
+}
\ No newline at end of file
Modified:
cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/applicationContext.xml
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/applicationContext.xml?rev=1541233&r1=1541232&r2=1541233&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/applicationContext.xml
(original)
+++ cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/applicationContext.xml
Tue Nov 12 21:01:56 2013
@@ -23,6 +23,7 @@
xmlns:util="http://www.springframework.org/schema/util"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:sec="http://cxf.apache.org/configuration/security"
xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd
@@ -37,7 +38,9 @@
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/configuration/security
- http://cxf.apache.org/schemas/configuration/security.xsd">
+ http://cxf.apache.org/schemas/configuration/security.xsd
+ http://cxf.apache.org/jaxrs
+ http://cxf.apache.org/schemas/jaxrs.xsd">
<context:property-placeholder location="classpath:realm.properties"/>
@@ -59,6 +62,18 @@
</sec:trustManagers>
</http:tlsClientParameters>
</http:conduit>
-
+
+ <jaxrs:server id="idpService" address="/rs">
+ <jaxrs:serviceBeans>
+ <ref bean="idpServiceImpl" />
+ </jaxrs:serviceBeans>
+ </jaxrs:server>
+
+
+ <bean id="idpServiceImpl"
class="org.apache.cxf.fediz.service.idp.rest.IDPServices">
+ <property name="configService" ref="config" />
+ </bean>
+
+
</beans>
Modified: cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml?rev=1541233&r1=1541232&r2=1541233&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml (original)
+++ cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml Tue Nov 12
21:01:56 2013
@@ -43,9 +43,17 @@
<param-name>realm</param-name>
<param-value>${realm-uri}</param-value>
</init-param>
- </servlet>
-
-
+ </servlet>
+ <servlet>
+ <servlet-name>CXFServlet</servlet-name>
+
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>CXFServlet</servlet-name>
+ <url-pattern>/services/*</url-pattern>
+ </servlet-mapping>
<servlet-mapping>
<servlet-name>idp</servlet-name>
<url-pattern>/federation</url-pattern>