You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ow...@apache.org on 2014/01/22 22:47:03 UTC
svn commit: r1560525 [1/4] - in /cxf/fediz/trunk: ./ services/idp/
services/idp/src/main/java/org/apache/cxf/fediz/service/idp/
services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/
services/idp/src/main/java/org/apache/cxf/fediz/service/i...
Author: owulff
Date: Wed Jan 22 21:47:02 2014
New Revision: 1560525
URL: http://svn.apache.org/r1560525
Log:
REST interface enhanced and JPA Layer added
Added:
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/Application.java
- copied, changed from r1560523, 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/domain/Claim.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/Idp.java
- copied, changed from r1560523, 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/domain/RequestClaim.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/TrustedIdp.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/TrustedIDPConfig.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationService.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationServiceImpl.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/Applications.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ClaimService.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ClaimServiceImpl.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/Claims.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPServiceConfigs.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IdpService.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IdpServiceImpl.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/Idps.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/QueryResourceInfoComparator.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/RootService.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/ConfigService.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/RootServiceImpl.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/TrustedIdpService.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/TrustedIdpServiceImpl.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/TrustedIdps.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPTrustedIdps.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/ApplicationDAO.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/ConfigService.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/ClaimDAO.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/ConfigService.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/IdpDAO.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/TrustedIdpDAO.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/ConfigService.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationClaimEntity.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPAImpl.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationEntity.java
- copied, changed from r1560523, 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/service/jpa/ClaimDAOJPAImpl.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimEntity.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ConfigServiceJPA.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/DBInitApplicationListener.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/DBLoader.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/ConfigService.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/DBLoaderImpl.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPAImpl.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpEntity.java
- copied, changed from r1560523, 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/service/jpa/TrustedIdpDAOJPAImpl.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpEntity.java
- copied, changed from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/TrustedIDPConfig.java
cxf/fediz/trunk/services/idp/src/main/resources/META-INF/
cxf/fediz/trunk/services/idp/src/main/resources/META-INF/orm.xml
cxf/fediz/trunk/services/idp/src/main/resources/META-INF/spring-persistence.xml
cxf/fediz/trunk/services/idp/src/main/resources/persistence.properties
cxf/fediz/trunk/services/idp/src/main/resources/persistenceContext.xml
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPATest.java
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPATest.java
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPATest.java
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TestDBLoader.java
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPATest.java
cxf/fediz/trunk/services/idp/src/test/resources/persistence.properties
cxf/fediz/trunk/services/idp/src/test/resources/testContext.xml
Removed:
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPServiceConfigs.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPServices.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPTrustedIdps.java
Modified:
cxf/fediz/trunk/pom.xml
cxf/fediz/trunk/services/idp/pom.xml
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/FederationEntryPoint.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/MetadataServlet.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSPortFilter.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheTokenForWauthAction.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ProcessHRDSExpressionAction.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ValidateTokenAction.java
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/RequestClaim.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/java/org/apache/cxf/fediz/service/idp/service/ConfigService.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/ConfigServiceSpring.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/util/MetadataWriter.java
cxf/fediz/trunk/services/idp/src/main/resources/log4j.properties
cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/applicationContext.xml
cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/federation-signin-request.xml
cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/federation-validate-request.xml
cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/idp-config-realma.xml
cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/idp-config-realmb.xml
cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/idplist.jsp
cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/security-config.xml
cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/util/MetadataWriterTest.java
cxf/fediz/trunk/services/sts/src/main/resources/log4j.properties
cxf/fediz/trunk/systests/jetty8/pom.xml
cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyPreAuthSpringTest.java
cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
cxf/fediz/trunk/systests/spring/pom.xml
cxf/fediz/trunk/systests/spring/src/test/resources/log4j.properties
cxf/fediz/trunk/systests/spring/src/test/resources/logging.properties
cxf/fediz/trunk/systests/tomcat7/pom.xml
cxf/fediz/trunk/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
Modified: cxf/fediz/trunk/pom.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/pom.xml?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/pom.xml (original)
+++ cxf/fediz/trunk/pom.xml Wed Jan 22 21:47:02 2014
@@ -35,7 +35,7 @@
<commons.lang.version>3.0.1</commons.lang.version>
<commons.logging.version>1.1.1</commons.logging.version>
<cxf.version>2.7.7</cxf.version>
- <cxf.build-utils.version>2.5.0</cxf.build-utils.version>
+ <cxf.build-utils.version>2.6.0</cxf.build-utils.version>
<ehcache.version>2.5.1</ehcache.version>
<httpclient.version>4.2.2</httpclient.version>
<jericho.version>3.2</jericho.version>
@@ -483,6 +483,11 @@
<artifactId>cxf-buildtools</artifactId>
<version>${cxf.build-utils.version}</version>
</dependency>
+ <dependency>
+ <groupId>net.sourceforge.pmd</groupId>
+ <artifactId>pmd</artifactId>
+ <version>5.0.4</version>
+ </dependency>
</dependencies>
<configuration>
<rulesets>
Modified: cxf/fediz/trunk/services/idp/pom.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/pom.xml?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/pom.xml (original)
+++ cxf/fediz/trunk/services/idp/pom.xml Wed Jan 22 21:47:02 2014
@@ -74,6 +74,28 @@
<version>${spring.version}</version>
</dependency>
<dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.3.1.RELEASE</version>
@@ -123,7 +145,48 @@
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf.version}</version>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-extension-providers</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-jaxrs</artifactId>
+ <version>1.9.13</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-xc</artifactId>
+ <version>1.9.13</version>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ -->
+
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.7</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ <version>2.1_3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-all</artifactId>
+ <version>2.2.2</version>
+ </dependency>
</dependencies>
<build>
<resources>
@@ -146,6 +209,32 @@
</resources>
<plugins>
<plugin>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>2.2.2</version>
+ <inherited>true</inherited>
+ <configuration>
+ <persistenceXmlFile>${project.basedir}/src/main/resources/META-INF/spring-persistence.xml</persistenceXmlFile>
+ <includes>org/apache/cxf/fediz/service/idp/service/jpa/**/*.class</includes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>enhancer</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.11.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
<!--for mvn tomcat:deploy/:undeploy/:redeploy -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/FederationEntryPoint.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/FederationEntryPoint.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/FederationEntryPoint.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/FederationEntryPoint.java Wed Jan 22 21:47:02 2014
@@ -28,7 +28,7 @@ import javax.servlet.http.HttpServletReq
import javax.servlet.http.HttpServletResponse;
import org.apache.cxf.fediz.core.FederationConstants;
-import org.apache.cxf.fediz.service.idp.model.IDPConfig;
+import org.apache.cxf.fediz.service.idp.domain.Idp;
import org.apache.cxf.fediz.service.idp.service.ConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,7 +57,7 @@ public class FederationEntryPoint implem
private ApplicationContext appContext;
private ConfigService configService;
private String realm;
- private IDPConfig idpConfig;
+ private Idp idpConfig;
public ConfigService getConfigService() {
return configService;
@@ -79,7 +79,7 @@ public class FederationEntryPoint implem
Assert.notNull(this.appContext, "ApplicationContext cannot be null.");
Assert.notNull(this.configService, "ConfigService cannot be null.");
Assert.notNull(this.realm, "realm cannot be null.");
- idpConfig = configService.getIDPConfig(realm);
+ idpConfig = configService.getIDP(realm);
Assert.notNull(this.idpConfig, "idpConfig cannot be null. Check realm and config service implementation");
}
Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/MetadataServlet.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/MetadataServlet.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/MetadataServlet.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/MetadataServlet.java Wed Jan 22 21:47:02 2014
@@ -30,7 +30,7 @@ import javax.servlet.http.HttpServletRes
import org.w3c.dom.Document;
-import org.apache.cxf.fediz.service.idp.model.IDPConfig;
+import org.apache.cxf.fediz.service.idp.domain.Idp;
import org.apache.cxf.fediz.service.idp.service.ConfigService;
import org.apache.cxf.fediz.service.idp.util.MetadataWriter;
import org.apache.ws.security.util.DOM2Writer;
@@ -60,7 +60,7 @@ public class MetadataServlet extends Htt
PrintWriter out = response.getWriter();
try {
ConfigService cs = (ConfigService)getApplicationContext().getBean("config");
- IDPConfig idpConfig = cs.getIDPConfig(realm);
+ Idp idpConfig = cs.getIDP(realm);
LOG.debug(idpConfig.toString());
MetadataWriter mw = new MetadataWriter();
Document metadata = mw.getMetaData(idpConfig);
Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSPortFilter.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSPortFilter.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSPortFilter.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSPortFilter.java Wed Jan 22 21:47:02 2014
@@ -50,8 +50,9 @@ public class STSPortFilter extends Gener
Assert.isTrue(applicationContext != null, "Application context must not be null");
STSAuthenticationProvider authProvider = applicationContext.getBean(STSAuthenticationProvider.class);
Assert.isTrue(authProvider != null, "STSAuthenticationProvider must be configured");
-
- if (!isPortSet) {
+
+ //Only update the port if HTTPS is used, otherwise ignored (like retrieving the WADL over HTTP)
+ if (!isPortSet && request.isSecure()) {
try {
URL url = new URL(authProvider.getWsdlLocation());
URL updatedUrl = new URL(url.getProtocol(), url.getHost(), request.getLocalPort(), url.getFile());
Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheTokenForWauthAction.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheTokenForWauthAction.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheTokenForWauthAction.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheTokenForWauthAction.java Wed Jan 22 21:47:02 2014
@@ -19,7 +19,7 @@
package org.apache.cxf.fediz.service.idp.beans;
import org.apache.cxf.fediz.service.idp.STSUserDetails;
-import org.apache.cxf.fediz.service.idp.model.IDPConfig;
+import org.apache.cxf.fediz.service.idp.domain.Idp;
import org.apache.cxf.fediz.service.idp.util.WebUtils;
import org.apache.cxf.ws.security.tokenstore.SecurityToken;
import org.slf4j.Logger;
@@ -46,7 +46,7 @@ public class CacheTokenForWauthAction {
final STSUserDetails stsUserDetails = (STSUserDetails) auth.getDetails();
SecurityToken securityToken = stsUserDetails.getSecurityToken();
- IDPConfig idpConfig = (IDPConfig)WebUtils.getAttributeFromFlowScope(context, IDP_CONFIG);
+ Idp idpConfig = (Idp)WebUtils.getAttributeFromFlowScope(context, IDP_CONFIG);
WebUtils.putAttributeInExternalContext(context, idpConfig.getRealm(), securityToken);
LOG.info("Token [IDP_TOKEN=" + securityToken.getId()
Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ProcessHRDSExpressionAction.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ProcessHRDSExpressionAction.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ProcessHRDSExpressionAction.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ProcessHRDSExpressionAction.java Wed Jan 22 21:47:02 2014
@@ -18,7 +18,7 @@
*/
package org.apache.cxf.fediz.service.idp.beans;
-import org.apache.cxf.fediz.service.idp.model.IDPConfig;
+import org.apache.cxf.fediz.service.idp.domain.Idp;
import org.apache.cxf.fediz.service.idp.util.WebUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,7 +35,7 @@ public class ProcessHRDSExpressionAction
.getLogger(ProcessHRDSExpressionAction.class);
public String submit(RequestContext context) {
- IDPConfig idpConfig = (IDPConfig)WebUtils.getAttributeFromFlowScope(context, IDP_CONFIG);
+ Idp idpConfig = (Idp)WebUtils.getAttributeFromFlowScope(context, IDP_CONFIG);
String hrds = idpConfig.getHrds();
//TODO
if (hrds == null) {
Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java Wed Jan 22 21:47:02 2014
@@ -40,9 +40,9 @@ import org.apache.cxf.fediz.core.Federat
import org.apache.cxf.fediz.core.exception.ProcessingException;
import org.apache.cxf.fediz.core.exception.ProcessingException.TYPE;
import org.apache.cxf.fediz.service.idp.IdpSTSClient;
-import org.apache.cxf.fediz.service.idp.model.IDPConfig;
-import org.apache.cxf.fediz.service.idp.model.RequestClaim;
-import org.apache.cxf.fediz.service.idp.model.ServiceConfig;
+import org.apache.cxf.fediz.service.idp.domain.Application;
+import org.apache.cxf.fediz.service.idp.domain.Idp;
+import org.apache.cxf.fediz.service.idp.domain.RequestClaim;
import org.apache.cxf.fediz.service.idp.util.WebUtils;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.staxutils.W3CDOMStreamWriter;
@@ -159,14 +159,14 @@ public class STSClientAction {
SecurityToken idpToken = getSecurityToken(context);
- IDPConfig idpConfig = (IDPConfig) WebUtils.getAttributeFromFlowScope(context, IDP_CONFIG);
+ Idp idpConfig = (Idp) WebUtils.getAttributeFromFlowScope(context, IDP_CONFIG);
Bus cxfBus = getBus();
IdpSTSClient sts = new IdpSTSClient(cxfBus);
sts.setAddressingNamespace(HTTP_WWW_W3_ORG_2005_08_ADDRESSING);
- ServiceConfig serviceConfig = idpConfig.getServices().get(wtrealm);
+ Application serviceConfig = idpConfig.findApplication(wtrealm);
if (serviceConfig == null) {
LOG.warn("No service config found for " + wtrealm);
throw new ProcessingException(TYPE.BAD_REQUEST);
Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ValidateTokenAction.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ValidateTokenAction.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ValidateTokenAction.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ValidateTokenAction.java Wed Jan 22 21:47:02 2014
@@ -39,8 +39,8 @@ import org.apache.cxf.fediz.core.config.
import org.apache.cxf.fediz.core.config.jaxb.ValidationType;
import org.apache.cxf.fediz.core.exception.ProcessingException;
import org.apache.cxf.fediz.core.exception.ProcessingException.TYPE;
-import org.apache.cxf.fediz.service.idp.model.IDPConfig;
-import org.apache.cxf.fediz.service.idp.model.TrustedIDPConfig;
+import org.apache.cxf.fediz.service.idp.domain.Idp;
+import org.apache.cxf.fediz.service.idp.domain.TrustedIdp;
import org.apache.cxf.fediz.service.idp.util.WebUtils;
import org.apache.cxf.ws.security.tokenstore.SecurityToken;
import org.apache.ws.security.util.UUIDGenerator;
@@ -61,7 +61,7 @@ public class ValidateTokenAction {
public SecurityToken submit(RequestContext context)
throws ProcessingException, IOException {
- IDPConfig idpConfig = (IDPConfig) WebUtils.getAttributeFromFlowScope(
+ Idp idpConfig = (Idp) WebUtils.getAttributeFromFlowScope(
context, IDP_CONFIG);
if (idpConfig == null) {
@@ -85,7 +85,7 @@ public class ValidateTokenAction {
TYPE.BAD_REQUEST);
}
- TrustedIDPConfig trustedIDPConfig = idpConfig.getTrustedIDPs().get(whr);
+ TrustedIdp trustedIDPConfig = idpConfig.findTrustedIDP(whr);
if (trustedIDPConfig == null) {
throw new ProcessingException(
@@ -129,8 +129,8 @@ public class ValidateTokenAction {
return idpToken;
}
- private FederationContext getFederationContext(IDPConfig idpConfig,
- TrustedIDPConfig trustedIdpConfig) throws ProcessingException {
+ private FederationContext getFederationContext(Idp idpConfig,
+ TrustedIdp trustedIdpConfig) throws ProcessingException {
ContextConfig config = new ContextConfig();
Copied: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/Application.java (from r1560523, 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/domain/Application.java?p2=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/Application.java&p1=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/ServiceConfig.java&r1=1560523&r2=1560525&rev=1560525&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/domain/Application.java Wed Jan 22 21:47:02 2014
@@ -16,63 +16,86 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.cxf.fediz.service.idp.model;
+package org.apache.cxf.fediz.service.idp.domain;
import java.io.Serializable;
+import java.net.URI;
+import java.util.ArrayList;
import java.util.List;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
-//import javax.persistence.Column;
-//import javax.persistence.Entity;
-//import javax.persistence.Id;
-//import javax.persistence.Table;
-
-//@Entity
-//@Table(name = "SERVICE")
-@XmlRootElement(name = "Service", namespace = "http://org.apache.cxf.fediz")
-public class ServiceConfig implements Serializable {
-
+@XmlRootElement(name = "application", namespace = "http://org.apache.cxf.fediz/")
+@XmlType(propOrder = {"realm", "role", "serviceDisplayName", "serviceDescription", "protocol",
+ "tokenType", "lifeTime", "encryptionCertificate", "requestedClaims", "id" })
+public class Application implements Serializable {
- //@Id
- //private Long id;
+ private static final long serialVersionUID = 5644327504861846964L;
+
+
+ protected int id;
+
//Could be imported from Metadata document or manually filled
//@Column(name = "REALM", nullable = true, length = FIELD_LENGTH)
- private String realm; //wtrealm, whr
+ protected String realm; //wtrealm, whr
//Could be read from Metadata, RoleDescriptor protocolSupportEnumeration=
// "http://docs.oasis-open.org/wsfed/federation/200706"
// Metadata could provide more than one but one must be chosen
- private String protocol;
+ protected String protocol;
// Public key only
// Could be read from Metadata, md:KeyDescriptor, use="encryption"
- private String encryptionCertificate;
+ protected String encryptionCertificate;
// Could be read from Metadata, fed:ClaimTypesRequested
- private List<RequestClaim> requestedClaims;
+ protected List<RequestClaim> requestedClaims = new ArrayList<RequestClaim>();
//Could be read from Metadata, ServiceDisplayName
//usage for list of application where user is logged in
- private String serviceDisplayName;
+ protected String serviceDisplayName;
//Could be read from Metadata, ServiceDescription
//usage for list of application where user is logged in
- private String serviceDescription;
+ protected String serviceDescription;
//Could be read from Metadata, RoleDescriptor
//fed:ApplicationServiceType, fed:SecurityTokenServiceType
- private String role;
-
-
+ protected String role;
+
// Not in Metadata, configured in IDP or passed in wreq parameter
- private String tokenType;
+ protected String tokenType;
// Not in Metadata, configured in IDP or passed in wreq parameter
- private String lifeTime;
+ protected String lifeTime;
+
+ private URI href;
+
+
+ @XmlAttribute
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @XmlAttribute
+ public URI getHref() {
+ return href;
+ }
+
+ public void setHref(URI href) {
+ this.href = href;
+ }
public String getRealm() {
return realm;
@@ -98,6 +121,8 @@ public class ServiceConfig implements Se
this.encryptionCertificate = encryptionCertificate;
}
+ @XmlElementWrapper(name = "claims")
+ @XmlElementRef(name = "requestedClaims")
public List<RequestClaim> getRequestedClaims() {
return requestedClaims;
}
Added: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/Claim.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/Claim.java?rev=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/Claim.java (added)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/Claim.java Wed Jan 22 21:47:02 2014
@@ -0,0 +1,79 @@
+/**
+ * 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.domain;
+
+import java.io.Serializable;
+import java.net.URI;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "claim", namespace = "http://org.apache.cxf.fediz/")
+public class Claim implements Serializable {
+
+ private static final long serialVersionUID = 2635896159019665467L;
+
+ protected URI claimType;
+ protected String displayName;
+ protected String description;
+ protected int id;
+ private URI href;
+
+ @XmlAttribute
+ public URI getHref() {
+ return href;
+ }
+
+ public void setHref(URI href) {
+ this.href = href;
+ }
+
+ @XmlAttribute
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public void setClaimType(URI claimType) {
+ this.claimType = claimType;
+ }
+
+ public URI getClaimType() {
+ return claimType;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
Copied: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/Idp.java (from r1560523, 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/domain/Idp.java?p2=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/Idp.java&p1=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/IDPConfig.java&r1=1560523&r2=1560525&rev=1560525&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/domain/Idp.java Wed Jan 22 21:47:02 2014
@@ -16,95 +16,110 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.cxf.fediz.service.idp.model;
+package org.apache.cxf.fediz.service.idp.domain;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
-@XmlRootElement(name = "IDP", namespace = "http://org.apache.cxf.fediz")
-public class IDPConfig implements Serializable {
+@XmlRootElement(name = "idp", namespace = "http://org.apache.cxf.fediz/")
+@XmlType(propOrder = {"realm", "uri", "serviceDisplayName", "serviceDescription", "idpUrl", "stsUrl",
+ "certificate", "certificatePassword", "provideIDPList", "useCurrentIDP", "hrds",
+ "supportedProtocols", "tokenTypesOffered", "claimTypesOffered", "authenticationURIs",
+ "applications", "trustedIdps", "id" })
+public class Idp implements Serializable {
- // @Id
- // private Long id;
-
- /**
- *
- */
private static final long serialVersionUID = -5570301342547139039L;
- // @Column(name = "REALM", nullable = false, length = FIELD_LENGTH)
+
+ protected int id;
+
// Unique
// fed:TargetScope
- private String realm; // wtrealm, whr
+ protected String realm; // wtrealm, whr
// Unique
// https://<host>:<port>/fediz-idp/<IDP uri>/
- private String uri;
+ protected String uri;
// Home Realm Discovery Service
// Spring EL
- private String hrds;
+ protected String hrds;
// @Column(name = "INACTIVE", nullable = true, length = FIELD_LENGTH)
// if HRDS can't determine the home realm, should
// the list of trusted IDPs be shown to make a choice
- private boolean provideIDPList;
+ protected boolean provideIDPList;
// If HRDS can't discover a home realm and displaying IDP list is not
// enabled
// it falls back to current IDP if an authentication domain is configured
- private boolean useCurrentIDP;
+ protected boolean useCurrentIDP;
// Store certificate in DB or filesystem, provide options?
// md:KeyDescriptor, use="signing"
- private String certificate;
+ protected String certificate;
// Password to read the private key to sign metadata document
- private String certificatePassword;
+ protected String certificatePassword;
// fed:SecurityTokenSerivceEndpoint
- private String stsUrl;
+ protected String stsUrl;
// fed:PassiveRequestorEndpoint
// published hostname, port must be configured
- private String idpUrl;
+ protected String idpUrl;
// RoleDescriptor protocolSupportEnumeration=
// "http://docs.oasis-open.org/wsfed/federation/200706"
// "http://docs.oasis-open.org/ws-sx/ws-trust/200512"
// Could be more in the future
- private List<String> supportedProtocols;
+ protected List<String> supportedProtocols = new ArrayList<String>();
// list of RPs and RP-IDPs from whom we accept SignInResponse
// which includes RP IDPs
// key: wtrealm
- private Map<String, ServiceConfig> services;
+ protected List<Application> applications = new ArrayList<Application>();
// list of trusted IDP from whom we accept SignInResponse
// key: whr
- private Map<String, TrustedIDPConfig> trustedIDPs;
+ protected List<TrustedIdp> trustedIdpList = new ArrayList<TrustedIdp>();
// which URI to redirect for authentication
// fediz-idp/<IDP uri>/login/auth/<auth URI>
// wauth to auth URI mapping
- private Map<String, String> authenticationURIs;
+ protected Map<String, String> authenticationURIs = new HashMap<String, String>();
// required to create Federation Metadata document
// fed:TokenTypesOffered
- private List<String> tokenTypesOffered;
+ protected List<String> tokenTypesOffered = new ArrayList<String>();
// fed:ClaimTypesOffered
- private List<String> claimTypesOffered;
+ protected List<Claim> claimTypesOffered = new ArrayList<Claim>();
// ServiceDisplayName
- private String serviceDisplayName;
+ protected String serviceDisplayName;
// ServiceDescription
- private String serviceDescription;
+ protected String serviceDescription;
+
+ @XmlAttribute
+ public int getId() {
+ return id;
+ }
+ public void setId(int id) {
+ this.id = id;
+ }
+
public String getRealm() {
return realm;
}
@@ -177,6 +192,7 @@ public class IDPConfig implements Serial
this.idpUrl = idpUrl;
}
+ @XmlElementWrapper(name = "supportedProtocols")
public List<String> getSupportedProtocols() {
return supportedProtocols;
}
@@ -185,20 +201,38 @@ public class IDPConfig implements Serial
this.supportedProtocols = supportedProtocols;
}
- public Map<String, ServiceConfig> getServices() {
- return services;
- }
-
- public void setServices(Map<String, ServiceConfig> services) {
- this.services = services;
- }
-
- public Map<String, TrustedIDPConfig> getTrustedIDPs() {
- return trustedIDPs;
- }
-
- public void setTrustedIDPs(Map<String, TrustedIDPConfig> trustedIDPs) {
- this.trustedIDPs = trustedIDPs;
+ public Application findApplication(String realmApplication) {
+ for (Application item : applications) {
+ if (realmApplication.equals(item.getRealm())) {
+ return item;
+ }
+ }
+ return null;
+ }
+
+ @XmlElementWrapper(name = "applications")
+ @XmlElementRef(name = "application")
+ public List<Application> getApplications() {
+ return applications;
+ }
+
+ public void setApplications(List<Application> applications) {
+ this.applications = applications;
+ }
+
+ public TrustedIdp findTrustedIDP(String realmTrustedIdp) {
+ for (TrustedIdp item : trustedIdpList) {
+ if (realmTrustedIdp.equals(item.getRealm())) {
+ return item;
+ }
+ }
+ return null;
+ }
+
+ @XmlElementWrapper(name = "trustedIdps")
+ @XmlElementRef(name = "trustedIdp")
+ public List<TrustedIdp> getTrustedIdps() {
+ return trustedIdpList;
}
public Map<String, String> getAuthenticationURIs() {
@@ -209,6 +243,7 @@ public class IDPConfig implements Serial
this.authenticationURIs = authenticationURIs;
}
+ @XmlElementWrapper(name = "tokenTypesOffered")
public List<String> getTokenTypesOffered() {
return tokenTypesOffered;
}
@@ -217,11 +252,13 @@ public class IDPConfig implements Serial
this.tokenTypesOffered = tokenTypesOffered;
}
- public List<String> getClaimTypesOffered() {
+ @XmlElementWrapper(name = "claimTypesOffered")
+ @XmlElementRef(name = "claimType")
+ public List<Claim> getClaimTypesOffered() {
return claimTypesOffered;
}
- public void setClaimTypesOffered(List<String> claimTypesOffered) {
+ public void setClaimTypesOffered(List<Claim> claimTypesOffered) {
this.claimTypesOffered = claimTypesOffered;
}
Copied: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/RequestClaim.java (from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java)
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/RequestClaim.java?p2=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/RequestClaim.java&p1=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java&r1=1560523&r2=1560525&rev=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/RequestClaim.java Wed Jan 22 21:47:02 2014
@@ -16,27 +16,33 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.cxf.fediz.service.idp.model;
+package org.apache.cxf.fediz.service.idp.domain;
-import java.io.Serializable;
-import java.net.URI;
+import javax.xml.bind.annotation.XmlRootElement;
-public class RequestClaim implements Serializable {
+@XmlRootElement(name = "requestClaim", namespace = "http://org.apache.cxf.fediz/")
+public class RequestClaim extends Claim {
- private URI claimType;
+ private static final long serialVersionUID = 8097560995225077866L;
- private boolean optional;
+ protected boolean optional;
-
- public void setClaimType(URI claimType) {
- this.claimType = claimType;
+ public RequestClaim() {
+ super();
}
- public URI getClaimType() {
- return claimType;
+
+ public RequestClaim(Claim c) {
+ super();
+ this.setClaimType(c.getClaimType());
+ this.setDescription(c.getDescription());
+ this.setDisplayName(c.getDisplayName());
+ this.setId(c.getId());
}
+
public void setOptional(boolean optional) {
this.optional = optional;
}
+
public boolean isOptional() {
return optional;
}
Copied: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/TrustedIdp.java (from r1560523, 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/domain/TrustedIdp.java?p2=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/domain/TrustedIdp.java&p1=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/TrustedIDPConfig.java&r1=1560523&r2=1560525&rev=1560525&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/domain/TrustedIdp.java Wed Jan 22 21:47:02 2014
@@ -16,61 +16,69 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.cxf.fediz.service.idp.model;
+package org.apache.cxf.fediz.service.idp.domain;
import java.io.Serializable;
+import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+@XmlRootElement(name = "trustedIdp", namespace = "http://org.apache.cxf.fediz/")
+@XmlType(propOrder = {"realm", "url", "name", "description", "protocol", "trustType",
+ "certificate", "federationType", "cacheTokens", "logo", "id" })
+//@XmlAttribute on Id must be set on getter, not on attribute, otherwise error
+public class TrustedIdp implements Serializable {
-//import javax.persistence.Column;
-//import javax.persistence.Entity;
-//import javax.persistence.Id;
-//import javax.persistence.Table;
-
-//@Entity
-//@Table(name = "TRUSTEDIDP")
-@XmlRootElement(name = "TrustedIDP", namespace = "http://org.apache.cxf.fediz")
-public class TrustedIDPConfig implements Serializable {
-
-
- //@Id
- //private Long id;
+ private static final long serialVersionUID = -6520081722646469178L;
+
+
+ protected int id;
//@Column(name = "REALM", nullable = true, length = FIELD_LENGTH)
- private String realm; //wtrealm, whr
+ protected String realm; //wtrealm, whr
// Should tokens be cached from trusted IDPs
// to avoid redirection to the trusted IDP again for next SignIn request
- private boolean cacheTokens;
+ protected boolean cacheTokens;
//Could be read from Metadata, PassiveRequestorEndpoint
- private String url;
+ protected String url;
//Could be read from Metadata, md:KeyDescriptor, use="signing"
//Store certificate in DB or filesystem, provide options?
- private String certificate;
+ protected String certificate;
//Direct trust (signing cert imported), Indirect trust (CA certs imported, subject configured)
- private String trustType;
+ protected String trustType;
//Could be read from Metadata, RoleDescriptor protocolSupportEnumeration=
// "http://docs.oasis-open.org/wsfed/federation/200706"
// Metadata could provide more than one but one must be chosen
- private String protocol;
+ protected String protocol;
//FederateIdentity, FederateClaims
- private String federationType;
+ protected String federationType;
//optional (to provide a list of IDPs)
- private String name;
+ protected String name;
//optional (to provide a list of IDPs)
- private String description;
+ protected String description;
//optional (to provide a list of IDPs)
- private String logo;
+ protected String logo;
+
+ @XmlAttribute
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
public String getRealm() {
return realm;
}
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=1560525&r1=1560524&r2=1560525&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 Wed Jan 22 21:47:02 2014
@@ -18,227 +18,22 @@
*/
package org.apache.cxf.fediz.service.idp.model;
-import java.io.Serializable;
-import java.util.List;
+import java.util.ArrayList;
import java.util.Map;
-import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.cxf.fediz.service.idp.domain.Application;
+import org.apache.cxf.fediz.service.idp.domain.Idp;
+import org.apache.cxf.fediz.service.idp.domain.TrustedIdp;
-@XmlRootElement(name = "IDP", namespace = "http://org.apache.cxf.fediz")
-public class IDPConfig implements Serializable {
+public class IDPConfig extends Idp {
- // @Id
- // private Long id;
-
- /**
- *
- */
private static final long serialVersionUID = -5570301342547139039L;
- // @Column(name = "REALM", nullable = false, length = FIELD_LENGTH)
- // Unique
- // fed:TargetScope
- private String realm; // wtrealm, whr
-
- // Unique
- // https://<host>:<port>/fediz-idp/<IDP uri>/
- private String uri;
-
- // Home Realm Discovery Service
- // Spring EL
- private String hrds;
-
- // @Column(name = "INACTIVE", nullable = true, length = FIELD_LENGTH)
- // if HRDS can't determine the home realm, should
- // the list of trusted IDPs be shown to make a choice
- private boolean provideIDPList;
-
- // If HRDS can't discover a home realm and displaying IDP list is not
- // enabled
- // it falls back to current IDP if an authentication domain is configured
- private boolean useCurrentIDP;
-
- // Store certificate in DB or filesystem, provide options?
- // md:KeyDescriptor, use="signing"
- private String certificate;
-
- // Password to read the private key to sign metadata document
- private String certificatePassword;
-
- // fed:SecurityTokenSerivceEndpoint
- private String stsUrl;
-
- // fed:PassiveRequestorEndpoint
- // published hostname, port must be configured
- private String idpUrl;
-
- // RoleDescriptor protocolSupportEnumeration=
- // "http://docs.oasis-open.org/wsfed/federation/200706"
- // "http://docs.oasis-open.org/ws-sx/ws-trust/200512"
- // Could be more in the future
- private List<String> supportedProtocols;
-
- // list of RPs and RP-IDPs from whom we accept SignInResponse
- // which includes RP IDPs
- // key: wtrealm
- private Map<String, ServiceConfig> services;
-
- // list of trusted IDP from whom we accept SignInResponse
- // key: whr
- private Map<String, TrustedIDPConfig> trustedIDPs;
-
- // which URI to redirect for authentication
- // fediz-idp/<IDP uri>/login/auth/<auth URI>
- // wauth to auth URI mapping
- private Map<String, String> authenticationURIs;
-
- // required to create Federation Metadata document
- // fed:TokenTypesOffered
- private List<String> tokenTypesOffered;
-
- // fed:ClaimTypesOffered
- private List<String> claimTypesOffered;
-
- // ServiceDisplayName
- private String serviceDisplayName;
-
- // ServiceDescription
- private String serviceDescription;
-
- public String getRealm() {
- return realm;
- }
-
- public void setRealm(String realm) {
- this.realm = realm;
- }
-
- public String getUri() {
- return uri;
- }
-
- public void setUri(String uri) {
- this.uri = uri;
- }
-
- public String getHrds() {
- return hrds;
- }
-
- public void setHrds(String hrds) {
- this.hrds = hrds;
- }
-
- public boolean isProvideIDPList() {
- return provideIDPList;
- }
-
- public void setProvideIDPList(boolean provideIDPList) {
- this.provideIDPList = provideIDPList;
- }
-
- public boolean isUseCurrentIDP() {
- return useCurrentIDP;
- }
-
- public void setUseCurrentIDP(boolean useCurrentIDP) {
- this.useCurrentIDP = useCurrentIDP;
- }
-
- public String getCertificate() {
- return certificate;
- }
-
- public void setCertificate(String certificate) {
- this.certificate = certificate;
- }
-
- public String getCertificatePassword() {
- return certificatePassword;
+ public void setServices(Map<String, Application> applications) {
+ this.applications = new ArrayList<Application>(applications.values());
}
-
- public void setCertificatePassword(String password) {
- this.certificatePassword = password;
- }
-
- public String getStsUrl() {
- return stsUrl;
- }
-
- public void setStsUrl(String stsUrl) {
- this.stsUrl = stsUrl;
- }
-
- public String getIdpUrl() {
- return idpUrl;
- }
-
- public void setIdpUrl(String idpUrl) {
- this.idpUrl = idpUrl;
- }
-
- public List<String> getSupportedProtocols() {
- return supportedProtocols;
- }
-
- public void setSupportedProtocols(List<String> supportedProtocols) {
- this.supportedProtocols = supportedProtocols;
- }
-
- public Map<String, ServiceConfig> getServices() {
- return services;
- }
-
- public void setServices(Map<String, ServiceConfig> services) {
- this.services = services;
- }
-
- public Map<String, TrustedIDPConfig> getTrustedIDPs() {
- return trustedIDPs;
- }
-
+
public void setTrustedIDPs(Map<String, TrustedIDPConfig> trustedIDPs) {
- this.trustedIDPs = trustedIDPs;
+ this.trustedIdpList = new ArrayList<TrustedIdp>(trustedIDPs.values());
}
-
- public Map<String, String> getAuthenticationURIs() {
- return authenticationURIs;
- }
-
- public void setAuthenticationURIs(Map<String, String> authenticationURIs) {
- this.authenticationURIs = authenticationURIs;
- }
-
- public List<String> getTokenTypesOffered() {
- return tokenTypesOffered;
- }
-
- public void setTokenTypesOffered(List<String> tokenTypesOffered) {
- this.tokenTypesOffered = tokenTypesOffered;
- }
-
- public List<String> getClaimTypesOffered() {
- return claimTypesOffered;
- }
-
- public void setClaimTypesOffered(List<String> claimTypesOffered) {
- this.claimTypesOffered = claimTypesOffered;
- }
-
- public String getServiceDisplayName() {
- return serviceDisplayName;
- }
-
- public void setServiceDisplayName(String serviceDisplayName) {
- this.serviceDisplayName = serviceDisplayName;
- }
-
- public String getServiceDescription() {
- return serviceDescription;
- }
-
- public void setServiceDescription(String serviceDescription) {
- this.serviceDescription = serviceDescription;
- }
-
}
Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java Wed Jan 22 21:47:02 2014
@@ -18,26 +18,9 @@
*/
package org.apache.cxf.fediz.service.idp.model;
-import java.io.Serializable;
-import java.net.URI;
-
-public class RequestClaim implements Serializable {
-
- private URI claimType;
-
- private boolean optional;
+//@XmlRootElement(name = "Claim", namespace = "http://org.apache.cxf.fediz")
+public class RequestClaim extends org.apache.cxf.fediz.service.idp.domain.RequestClaim {
+ private static final long serialVersionUID = 2635896159019665467L;
- public void setClaimType(URI claimType) {
- this.claimType = claimType;
- }
- public URI getClaimType() {
- return claimType;
- }
- public void setOptional(boolean optional) {
- this.optional = optional;
- }
- public boolean isOptional() {
- return optional;
- }
}
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=1560525&r1=1560524&r2=1560525&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 Wed Jan 22 21:47:02 2014
@@ -18,10 +18,7 @@
*/
package org.apache.cxf.fediz.service.idp.model;
-import java.io.Serializable;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.cxf.fediz.service.idp.domain.Application;
//import javax.persistence.Column;
//import javax.persistence.Entity;
@@ -30,121 +27,9 @@ import javax.xml.bind.annotation.XmlRoot
//@Entity
//@Table(name = "SERVICE")
-@XmlRootElement(name = "Service", namespace = "http://org.apache.cxf.fediz")
-public class ServiceConfig implements Serializable {
-
-
- //@Id
- //private Long id;
-
-
- //Could be imported from Metadata document or manually filled
-
- //@Column(name = "REALM", nullable = true, length = FIELD_LENGTH)
- private String realm; //wtrealm, whr
-
- //Could be read from Metadata, RoleDescriptor protocolSupportEnumeration=
- // "http://docs.oasis-open.org/wsfed/federation/200706"
- // Metadata could provide more than one but one must be chosen
- private String protocol;
-
- // Public key only
- // Could be read from Metadata, md:KeyDescriptor, use="encryption"
- private String encryptionCertificate;
-
- // Could be read from Metadata, fed:ClaimTypesRequested
- private List<RequestClaim> requestedClaims;
-
- //Could be read from Metadata, ServiceDisplayName
- //usage for list of application where user is logged in
- private String serviceDisplayName;
-
- //Could be read from Metadata, ServiceDescription
- //usage for list of application where user is logged in
- private String serviceDescription;
-
- //Could be read from Metadata, RoleDescriptor
- //fed:ApplicationServiceType, fed:SecurityTokenServiceType
- private String role;
-
-
- // Not in Metadata, configured in IDP or passed in wreq parameter
- private String tokenType;
-
- // Not in Metadata, configured in IDP or passed in wreq parameter
- private String lifeTime;
-
- public String getRealm() {
- return realm;
- }
-
- public void setRealm(String realm) {
- this.realm = realm;
- }
-
- public String getProtocol() {
- return protocol;
- }
-
- public void setProtocol(String protocol) {
- this.protocol = protocol;
- }
-
- public String getEncryptionCertificate() {
- return encryptionCertificate;
- }
-
- public void setEncryptionCertificate(String encryptionCertificate) {
- this.encryptionCertificate = encryptionCertificate;
- }
-
- public List<RequestClaim> getRequestedClaims() {
- return requestedClaims;
- }
-
- public void setRequestedClaims(List<RequestClaim> requestedClaims) {
- this.requestedClaims = requestedClaims;
- }
-
- public String getServiceDisplayName() {
- return serviceDisplayName;
- }
-
- public void setServiceDisplayName(String serviceDisplayName) {
- this.serviceDisplayName = serviceDisplayName;
- }
-
- public String getServiceDescription() {
- return serviceDescription;
- }
-
- public void setServiceDescription(String serviceDescription) {
- this.serviceDescription = serviceDescription;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
-
- public String getTokenType() {
- return tokenType;
- }
-
- public void setTokenType(String tokenType) {
- this.tokenType = tokenType;
- }
-
- public String getLifeTime() {
- return lifeTime;
- }
-
- public void setLifeTime(String lifeTime) {
- this.lifeTime = lifeTime;
- }
+//@XmlRootElement(name = "Service", namespace = "http://org.apache.cxf.fediz")
+public class ServiceConfig extends Application {
+ private static final long serialVersionUID = 585676715065240699L;
}
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=1560525&r1=1560524&r2=1560525&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 Wed Jan 22 21:47:02 2014
@@ -18,24 +18,17 @@
*/
package org.apache.cxf.fediz.service.idp.model;
-import java.io.Serializable;
-import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import org.apache.cxf.fediz.service.idp.domain.TrustedIdp;
-//import javax.persistence.Column;
-//import javax.persistence.Entity;
-//import javax.persistence.Id;
-//import javax.persistence.Table;
+//@XmlRootElement(name = "TrustedIDP", namespace = "http://org.apache.cxf.fediz")
+public class TrustedIDPConfig extends TrustedIdp {
-//@Entity
-//@Table(name = "TRUSTEDIDP")
-@XmlRootElement(name = "TrustedIDP", namespace = "http://org.apache.cxf.fediz")
-public class TrustedIDPConfig implements Serializable {
+ private static final long serialVersionUID = 7017232258951933643L;
-
- //@Id
- //private Long id;
+ private int id;
//@Column(name = "REALM", nullable = true, length = FIELD_LENGTH)
private String realm; //wtrealm, whr
@@ -71,6 +64,15 @@ public class TrustedIDPConfig implements
//optional (to provide a list of IDPs)
private String logo;
+ @XmlAttribute
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
public String getRealm() {
return realm;
}
Added: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationService.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationService.java?rev=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationService.java (added)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationService.java Wed Jan 22 21:47:02 2014
@@ -0,0 +1,77 @@
+/**
+ * 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 java.util.List;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+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.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.cxf.fediz.service.idp.domain.Application;
+import org.apache.cxf.fediz.service.idp.domain.RequestClaim;
+
+
+@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+@Path("applications")
+public interface ApplicationService {
+
+ @GET
+ Applications getApplications(@QueryParam("start") int start,
+ @QueryParam("size") @DefaultValue("2") int size,
+ @QueryParam("expand") @DefaultValue("all") List<String> expand,
+ @Context UriInfo uriInfo);
+
+ @GET
+ @Path("{realm}")
+ Application getApplication(@PathParam("realm") String realm,
+ @QueryParam("expand") @DefaultValue("all") List<String> expand);
+
+ @POST
+ Response addApplication(@Context UriInfo ui, Application service);
+
+ @PUT
+ @Path("{realm}")
+ Response updateApplication(@Context UriInfo ui, @PathParam("realm") String realm, Application application);
+
+ @DELETE
+ @Path("{realm}")
+ Response deleteApplication(@PathParam("realm") String realm);
+
+ @POST
+ @Path("{realm}/claims")
+ Response addClaimToApplication(@Context UriInfo ui, @PathParam("realm") String realm, RequestClaim claim);
+
+ @DELETE
+ @Path("{realm}/claims/{claimType}")
+ Response removeClaimFromApplication(@Context UriInfo ui, @PathParam("realm") String realm,
+ @PathParam("claimType") String claimType);
+
+}
Added: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationServiceImpl.java?rev=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationServiceImpl.java (added)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationServiceImpl.java Wed Jan 22 21:47:02 2014
@@ -0,0 +1,151 @@
+/**
+ * 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 java.net.URI;
+import java.util.List;
+
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.ValidationException;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.cxf.fediz.service.idp.domain.Application;
+import org.apache.cxf.fediz.service.idp.domain.Claim;
+import org.apache.cxf.fediz.service.idp.domain.RequestClaim;
+import org.apache.cxf.fediz.service.idp.service.ApplicationDAO;
+import org.apache.cxf.fediz.service.idp.service.ClaimDAO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ApplicationServiceImpl implements ApplicationService {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(ApplicationServiceImpl.class);
+
+ @Autowired
+ private ApplicationDAO applicationDAO;
+
+ @Autowired
+ private ClaimDAO claimDAO;
+
+ @Override
+ public Applications getApplications(int start, int size, List<String> expand, UriInfo uriInfo) {
+ List<Application> applications = applicationDAO.getApplications(start, size, expand);
+
+ for (Application a : applications) {
+ URI self = uriInfo.getAbsolutePathBuilder().path(a.getRealm()).build();
+ a.setHref(self);
+ }
+
+ Applications list = new Applications();
+ list.setApplications(applications);
+ return list;
+ }
+
+ @Override
+ public Application getApplication(String realm, List<String> expand) {
+ Application application = applicationDAO.getApplication(realm, expand);
+ if (application == null) {
+ throw new NotFoundException();
+ } else {
+ return application;
+ }
+ }
+
+ @Override
+ public Response addApplication(UriInfo ui, Application application) {
+ LOG.info("add Service config");
+ if (application.getRequestedClaims() != null && application.getRequestedClaims().size() > 0) {
+ LOG.warn("Application resource contains sub resource 'claims'");
+ throw new WebApplicationException(Status.BAD_REQUEST);
+ }
+ Application createdApplication = applicationDAO.addApplication(application);
+
+ UriBuilder uriBuilder = UriBuilder.fromUri(ui.getRequestUri());
+ uriBuilder.path("{index}");
+ URI location = uriBuilder.build(createdApplication.getRealm());
+ return Response.created(location).entity(application).build();
+ }
+
+ @Override
+ public Response updateApplication(UriInfo ui, String realm, Application application) {
+ if (!realm.equals(application.getRealm().toString())) {
+ throw new ValidationException(Status.BAD_REQUEST);
+ }
+ if (application.getRequestedClaims() != null && application.getRequestedClaims().size() > 0) {
+ LOG.warn("Application resource contains sub resource 'claims'");
+ throw new WebApplicationException(Status.BAD_REQUEST);
+ }
+ applicationDAO.updateApplication(realm, application);
+
+ return Response.noContent().build();
+ }
+
+ @Override
+ public Response deleteApplication(String realm) {
+ applicationDAO.deleteApplication(realm);
+
+ return Response.noContent().build();
+ }
+
+ @Override
+ public Response addClaimToApplication(UriInfo ui, String realm, RequestClaim claim) {
+ Application application = applicationDAO.getApplication(realm, null);
+ if (application.getRequestedClaims().contains(claim)) {
+ LOG.warn("Claim '" + claim.getClaimType() + "' already added");
+ //[TODO] Status.CONFLICT correct if the relation to with Claim already exists
+ throw new WebApplicationException(Status.CONFLICT);
+ }
+ Claim foundClaim = claimDAO.getClaim(claim.getClaimType().toString());
+ RequestClaim rc = new RequestClaim(foundClaim);
+ application.getRequestedClaims().add(rc);
+ applicationDAO.updateApplication(realm, application);
+
+ return Response.noContent().build();
+ }
+
+ @Override
+ public Response removeClaimFromApplication(UriInfo ui, String realm, String claimType) {
+ Application application = applicationDAO.getApplication(realm, null);
+
+ RequestClaim foundItem = null;
+ for (RequestClaim item : application.getRequestedClaims()) {
+ if (item.getClaimType().toString().equals(claimType)) {
+ foundItem = item;
+ break;
+ }
+ }
+ if (foundItem == null) {
+ LOG.warn("Claim '" + claimType + "' not found");
+ throw new WebApplicationException(Status.NOT_FOUND);
+ }
+ application.getRequestedClaims().remove(foundItem);
+ applicationDAO.updateApplication(realm, application);
+
+ return Response.noContent().build();
+ }
+}
\ No newline at end of file
Copied: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/Applications.java (from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java)
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/Applications.java?p2=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/Applications.java&p1=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java&r1=1560523&r2=1560525&rev=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/model/RequestClaim.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/Applications.java Wed Jan 22 21:47:02 2014
@@ -16,28 +16,34 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.cxf.fediz.service.idp.model;
-import java.io.Serializable;
-import java.net.URI;
+package org.apache.cxf.fediz.service.idp.rest;
-public class RequestClaim implements Serializable {
-
- private URI claimType;
-
- private boolean optional;
-
-
- public void setClaimType(URI claimType) {
- this.claimType = claimType;
+import java.util.Collection;
+
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.cxf.fediz.service.idp.domain.Application;
+
+@XmlRootElement(name = "applications")
+public class Applications {
+
+ private Collection<Application> applications;
+
+ public Applications() {
}
- public URI getClaimType() {
- return claimType;
+
+ public Applications(Collection<Application> applications) {
+ this.applications = applications;
}
- public void setOptional(boolean optional) {
- this.optional = optional;
+
+ @XmlElementRef
+ public Collection<Application> getApplications() {
+ return applications;
}
- public boolean isOptional() {
- return optional;
+
+ public void setApplications(Collection<Application> applications) {
+ this.applications = applications;
}
-}
+}
\ No newline at end of file
Added: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ClaimService.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ClaimService.java?rev=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ClaimService.java (added)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ClaimService.java Wed Jan 22 21:47:02 2014
@@ -0,0 +1,63 @@
+/**
+ * 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.DefaultValue;
+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.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.cxf.fediz.service.idp.domain.Claim;
+
+
+@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+@Path("claims")
+public interface ClaimService {
+
+ @GET
+ Response getClaims(@QueryParam("start") int start,
+ @QueryParam("size") @DefaultValue("2") int size,
+ @Context UriInfo uriInfo);
+
+ @GET
+ @Path("{claimType}")
+ Claim getClaim(@PathParam("claimType") String claimType);
+
+ @POST
+ Response addClaim(@Context UriInfo ui, Claim claim);
+
+ @PUT
+ @Path("{claimType}")
+ Response updateClaim(@Context UriInfo ui, @PathParam("claimType") String claimType, Claim claim);
+
+ @DELETE
+ @Path("{claimType}")
+ Response deleteClaim(@PathParam("claimType") String claimType);
+
+}
Added: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ClaimServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ClaimServiceImpl.java?rev=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ClaimServiceImpl.java (added)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ClaimServiceImpl.java Wed Jan 22 21:47:02 2014
@@ -0,0 +1,107 @@
+/**
+ * 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 java.net.URI;
+import java.util.List;
+
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.ValidationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.cxf.fediz.service.idp.domain.Claim;
+import org.apache.cxf.fediz.service.idp.service.ClaimDAO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ClaimServiceImpl implements ClaimService {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(ClaimServiceImpl.class);
+
+ @Autowired
+ private ClaimDAO claimDAO;
+
+ @Override
+ public Response getClaims(int start, int size, UriInfo uriInfo) {
+ List<Claim> claims = claimDAO.getClaims(start, size);
+
+ for (Claim c : claims) {
+ URI self = uriInfo.getAbsolutePathBuilder().path(c.getClaimType().toString()).build();
+ c.setHref(self);
+ }
+
+ Claims list = new Claims();
+ list.setClaims(claims);
+
+
+ //return Response.ok(list).type(MediaType.APPLICATION_JSON_TYPE).build();
+ return Response.ok(list).build();
+ }
+
+ @Override
+ public Response addClaim(UriInfo ui, Claim claim) {
+ LOG.info("add Claim config");
+
+ Claim createdClaim = claimDAO.addClaim(claim);
+
+ UriBuilder uriBuilder = UriBuilder.fromUri(ui.getRequestUri());
+ uriBuilder.path("{index}");
+ URI location = uriBuilder.build(createdClaim.getClaimType().toString());
+ return Response.created(location).entity(claim).build();
+ }
+
+ @Override
+ public Claim getClaim(String claimType) {
+ Claim claim = claimDAO.getClaim(claimType);
+ if (claim == null) {
+ throw new NotFoundException();
+ } else {
+ return claim;
+ }
+ }
+
+ @Override
+ public Response updateClaim(UriInfo ui, String claimType, Claim claim) {
+ if (!claimType.equals(claim.getClaimType().toString())) {
+ throw new ValidationException(Status.BAD_REQUEST);
+ }
+ claimDAO.updateClaim(claimType, claim);
+
+ return Response.noContent().build();
+ }
+
+ @Override
+ public Response deleteClaim(String claimType) {
+ claimDAO.deleteClaim(claimType);
+
+ return Response.noContent().build();
+ }
+
+
+
+
+}
\ No newline at end of file
Copied: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/Claims.java (from r1560523, cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPServiceConfigs.java)
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/Claims.java?p2=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/Claims.java&p1=cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPServiceConfigs.java&r1=1560523&r2=1560525&rev=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/IDPServiceConfigs.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/Claims.java Wed Jan 22 21:47:02 2014
@@ -19,44 +19,32 @@
package org.apache.cxf.fediz.service.idp.rest;
-import java.util.Map;
+import java.util.Collection;
+import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.cxf.fediz.service.idp.model.ServiceConfig;
+import org.apache.cxf.fediz.service.idp.domain.Claim;
-@XmlRootElement
-public class IDPServiceConfigs {
+@XmlRootElement(name = "claims")
+public class Claims {
- private Map<String, ServiceConfig> services;
+ private Collection<Claim> claims;
- public IDPServiceConfigs() {
+ public Claims() {
}
- public IDPServiceConfigs(Map<String, ServiceConfig> services) {
- this.services = services;
+ public Claims(Collection<Claim> claims) {
+ this.claims = claims;
}
- public Map<String, ServiceConfig> getServices() {
- return services;
+ @XmlElementRef
+ public Collection<Claim> getClaims() {
+ return claims;
}
- public void setServices(Map<String, ServiceConfig> services) {
- this.services = services;
+ public void setClaims(Collection<Claim> claims) {
+ this.claims = claims;
}
-// @GET
-// @Path("{wtrealm}")
-// public ServiceConfig getServiceConfig(@PathParam("wtrealm") String wtrealm) {
-// ServiceConfig config = services.get(wtrealm);
-// if (config == null) {
-// throw new NotFoundException();
-// }
-// return config;
-// }
-
-// @GET
-// public IDPServiceConfigs getState() {
-// return this;
-// }
}
\ No newline at end of file