Permalink
Browse files

a little validation

  • Loading branch information...
jeichar
jeichar committed Oct 20, 2008
1 parent c7256a0 commit 1686cd9678b58d87c28ee8d607a1c60133ac0227
Showing with 5,039 additions and 0 deletions.
  1. +19 −0 .classpath
  2. BIN ...ect_$_secureows_$_src_$_deploy_$_src_$_main_$_scala_$_org_$_secureows_$_deploy_$_Validation.scala
  3. BIN ...oject_$_secureows_$_src_$_deploy_$_src_$_test_$_scala_$_org_$_secureows_$_deploy_$_SpecUtil.scala
  4. BIN ...$_secureows_$_src_$_deploy_$_src_$_test_$_scala_$_org_$_secureows_$_deploy_$_ValidationTest.scala
  5. +14 −0 .project
  6. +103 −0 pom.xml
  7. 0 src/main/resources/migration.properties
  8. +63 −0 src/main/scala/org/secureows/deploy/Validation.scala
  9. +107 −0 src/test/resources/org/secureows/deploy/corruptXML/WEB-INF/metaWeb.xsl
  10. +13 −0 src/test/resources/org/secureows/deploy/corruptXML/WEB-INF/services.xml
  11. +127 −0 src/test/resources/org/secureows/deploy/corruptXML/WEB-INF/services_test.xml
  12. +337 −0 src/test/resources/org/secureows/deploy/corruptXML/WEB-INF/web.xml
  13. +14 −0 src/test/resources/org/secureows/deploy/corruptXML/WEB-INF/wmsPolicy_geoserver.xml
  14. +107 −0 src/test/resources/org/secureows/deploy/goodDefinition/WEB-INF/metaWeb.xsl
  15. +22 −0 src/test/resources/org/secureows/deploy/goodDefinition/WEB-INF/services.xml
  16. +337 −0 src/test/resources/org/secureows/deploy/goodDefinition/WEB-INF/web.xml
  17. +14 −0 src/test/resources/org/secureows/deploy/goodDefinition/WEB-INF/wmsPolicy_geoserver.xml
  18. +14 −0 src/test/resources/org/secureows/deploy/goodDefinition/WEB-INF/wmsPolicy_germany.xml
  19. +107 −0 src/test/resources/org/secureows/deploy/missingServiceSpec/WEB-INF/metaWeb.xsl
  20. +13 −0 src/test/resources/org/secureows/deploy/missingServiceSpec/WEB-INF/services.xml
  21. +337 −0 src/test/resources/org/secureows/deploy/missingServiceSpec/WEB-INF/web.xml
  22. +107 −0 src/test/resources/org/secureows/deploy/norole/WEB-INF/metaWeb.xsl
  23. +20 −0 src/test/resources/org/secureows/deploy/norole/WEB-INF/services.xml
  24. +337 −0 src/test/resources/org/secureows/deploy/norole/WEB-INF/web.xml
  25. +14 −0 src/test/resources/org/secureows/deploy/norole/WEB-INF/wmsPolicy_geoserver.xml
  26. +14 −0 src/test/resources/org/secureows/deploy/norole/WEB-INF/wmsPolicy_germany.xml
  27. +14 −0 src/test/resources/org/secureows/deploy/policyFiles/corrupt.xml
  28. +14 −0 src/test/resources/org/secureows/deploy/policyFiles/good.xml
  29. +12 −0 src/test/resources/org/secureows/deploy/policyFiles/missing_optional.xml
  30. +4 −0 src/test/resources/org/secureows/deploy/policyFiles/missing_requests.xml
  31. +13 −0 src/test/resources/org/secureows/deploy/policyFiles/missing_security.xml
  32. +8 −0 src/test/scala/org/secureows/deploy/SpecUtil.scala
  33. +55 −0 src/test/scala/org/secureows/deploy/ValidationTest.scala
  34. +4 −0 svn-commit.tmp
  35. +1 −0 target/classes.timestamp
  36. 0 target/classes/migration.properties
  37. BIN target/classes/org/secureows/deploy/Validation$$anonfun$1.class
  38. BIN target/classes/org/secureows/deploy/Validation$$anonfun$checkServiceSpec$1.class
  39. BIN target/classes/org/secureows/deploy/Validation$$anonfun$checkServiceSpec$2.class
  40. BIN target/classes/org/secureows/deploy/Validation$$anonfun$testTags$1$1.class
  41. BIN target/classes/org/secureows/deploy/Validation$$anonfun$validate$1.class
  42. BIN target/classes/org/secureows/deploy/Validation$$anonfun$validate$2.class
  43. BIN target/classes/org/secureows/deploy/Validation$.class
  44. BIN target/classes/org/secureows/deploy/Validation.class
  45. +63 −0 target/classes/org/secureows/deploy/Validation.scala
  46. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$1$$anonfun$apply$1.class
  47. BIN ...et/classes/org/secureows/deploy/ValidationSpec$$anonfun$1$$anonfun$apply$2$$anonfun$apply$3.class
  48. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$1$$anonfun$apply$2.class
  49. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$1.class
  50. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$2$$anonfun$apply$4.class
  51. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$2$$anonfun$apply$5.class
  52. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$2.class
  53. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$3$$anonfun$apply$6.class
  54. BIN ...et/classes/org/secureows/deploy/ValidationSpec$$anonfun$3$$anonfun$apply$7$$anonfun$apply$8.class
  55. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$3$$anonfun$apply$7.class
  56. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$3.class
  57. BIN .../classes/org/secureows/deploy/ValidationSpec$$anonfun$4$$anonfun$apply$10$$anonfun$apply$11.class
  58. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$4$$anonfun$apply$10.class
  59. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$4$$anonfun$apply$9.class
  60. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$4.class
  61. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$5$$anonfun$apply$12.class
  62. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$5$$anonfun$apply$13.class
  63. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$5$$anonfun$apply$14.class
  64. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$5$$anonfun$apply$15.class
  65. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$5$$anonfun$apply$16.class
  66. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$5.class
  67. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$6$$anonfun$apply$17.class
  68. BIN .../classes/org/secureows/deploy/ValidationSpec$$anonfun$6$$anonfun$apply$18$$anonfun$apply$19.class
  69. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$6$$anonfun$apply$18.class
  70. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$6.class
  71. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$7$$anonfun$apply$19.class
  72. BIN .../classes/org/secureows/deploy/ValidationSpec$$anonfun$7$$anonfun$apply$20$$anonfun$apply$21.class
  73. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$7$$anonfun$apply$20.class
  74. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$7$$anonfun$apply$21.class
  75. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$7.class
  76. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$8$$anonfun$apply$22.class
  77. BIN .../classes/org/secureows/deploy/ValidationSpec$$anonfun$8$$anonfun$apply$23$$anonfun$apply$24.class
  78. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$8$$anonfun$apply$23.class
  79. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$8.class
  80. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$9$$anonfun$apply$25.class
  81. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$9$$anonfun$apply$26.class
  82. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$9$$anonfun$apply$27.class
  83. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$9$$anonfun$apply$28.class
  84. BIN target/classes/org/secureows/deploy/ValidationSpec$$anonfun$9.class
  85. BIN target/classes/org/secureows/deploy/ValidationSpec$.class
  86. BIN target/classes/org/secureows/deploy/ValidationSpec.class
  87. BIN target/classes/org/secureows/deploy/ValidationTest.class
  88. +1 −0 target/test-classes.timestamp
  89. BIN target/test-classes/org/secureows/deploy/SpecUtil$.class
  90. BIN target/test-classes/org/secureows/deploy/SpecUtil.class
  91. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$1$$anonfun$apply$1.class
  92. BIN ...st-classes/org/secureows/deploy/ValidationSpec$$anonfun$1$$anonfun$apply$2$$anonfun$apply$3.class
  93. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$1$$anonfun$apply$2.class
  94. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$1.class
  95. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$2$$anonfun$apply$4.class
  96. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$2$$anonfun$apply$5.class
  97. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$2.class
  98. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$3$$anonfun$apply$6.class
  99. BIN ...st-classes/org/secureows/deploy/ValidationSpec$$anonfun$3$$anonfun$apply$7$$anonfun$apply$8.class
  100. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$3$$anonfun$apply$7.class
  101. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$3.class
  102. BIN ...-classes/org/secureows/deploy/ValidationSpec$$anonfun$4$$anonfun$apply$10$$anonfun$apply$11.class
  103. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$4$$anonfun$apply$10.class
  104. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$4$$anonfun$apply$9.class
  105. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$4.class
  106. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$5$$anonfun$apply$12.class
  107. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$5$$anonfun$apply$13.class
  108. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$5$$anonfun$apply$14.class
  109. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$5$$anonfun$apply$15.class
  110. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$5$$anonfun$apply$16.class
  111. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$5.class
  112. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$6$$anonfun$apply$17.class
  113. BIN ...-classes/org/secureows/deploy/ValidationSpec$$anonfun$6$$anonfun$apply$18$$anonfun$apply$19.class
  114. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$6$$anonfun$apply$18.class
  115. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$6.class
  116. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$7$$anonfun$apply$19.class
  117. BIN ...-classes/org/secureows/deploy/ValidationSpec$$anonfun$7$$anonfun$apply$20$$anonfun$apply$21.class
  118. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$7$$anonfun$apply$20.class
  119. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$7$$anonfun$apply$21.class
  120. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$7.class
  121. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$8$$anonfun$apply$22.class
  122. BIN ...-classes/org/secureows/deploy/ValidationSpec$$anonfun$8$$anonfun$apply$23$$anonfun$apply$24.class
  123. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$8$$anonfun$apply$23.class
  124. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$8.class
  125. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$9$$anonfun$apply$25.class
  126. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$9$$anonfun$apply$26.class
  127. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$9$$anonfun$apply$27.class
  128. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$9$$anonfun$apply$28.class
  129. BIN target/test-classes/org/secureows/deploy/ValidationSpec$$anonfun$9.class
  130. BIN target/test-classes/org/secureows/deploy/ValidationSpec$.class
  131. BIN target/test-classes/org/secureows/deploy/ValidationSpec.class
  132. BIN target/test-classes/org/secureows/deploy/ValidationTest.class
  133. +55 −0 target/test-classes/org/secureows/deploy/ValidationTest.scala
  134. +107 −0 target/test-classes/org/secureows/deploy/badServiceInstanceDef/WEB-INF/metaWeb.xsl
  135. +13 −0 target/test-classes/org/secureows/deploy/badServiceInstanceDef/WEB-INF/services.xml
  136. +337 −0 target/test-classes/org/secureows/deploy/badServiceInstanceDef/WEB-INF/web.xml
  137. +107 −0 target/test-classes/org/secureows/deploy/corruptXML/WEB-INF/metaWeb.xsl
  138. +13 −0 target/test-classes/org/secureows/deploy/corruptXML/WEB-INF/services.xml
  139. +127 −0 target/test-classes/org/secureows/deploy/corruptXML/WEB-INF/services_test.xml
  140. +337 −0 target/test-classes/org/secureows/deploy/corruptXML/WEB-INF/web.xml
  141. +14 −0 target/test-classes/org/secureows/deploy/corruptXML/WEB-INF/wmsPolicy_geoserver.xml
  142. +107 −0 target/test-classes/org/secureows/deploy/goodDefinition/WEB-INF/metaWeb.xsl
  143. +22 −0 target/test-classes/org/secureows/deploy/goodDefinition/WEB-INF/services.xml
  144. +337 −0 target/test-classes/org/secureows/deploy/goodDefinition/WEB-INF/web.xml
  145. +14 −0 target/test-classes/org/secureows/deploy/goodDefinition/WEB-INF/wmsPolicy_geoserver.xml
  146. +14 −0 target/test-classes/org/secureows/deploy/goodDefinition/WEB-INF/wmsPolicy_germany.xml
  147. +107 −0 target/test-classes/org/secureows/deploy/missingServiceSpec/WEB-INF/metaWeb.xsl
  148. +13 −0 target/test-classes/org/secureows/deploy/missingServiceSpec/WEB-INF/services.xml
  149. +337 −0 target/test-classes/org/secureows/deploy/missingServiceSpec/WEB-INF/web.xml
  150. +107 −0 target/test-classes/org/secureows/deploy/norole/WEB-INF/metaWeb.xsl
  151. +20 −0 target/test-classes/org/secureows/deploy/norole/WEB-INF/services.xml
  152. +337 −0 target/test-classes/org/secureows/deploy/norole/WEB-INF/web.xml
  153. +14 −0 target/test-classes/org/secureows/deploy/norole/WEB-INF/wmsPolicy_geoserver.xml
  154. +14 −0 target/test-classes/org/secureows/deploy/norole/WEB-INF/wmsPolicy_germany.xml
  155. +14 −0 target/test-classes/org/secureows/deploy/policyFiles/corrupt.xml
  156. +14 −0 target/test-classes/org/secureows/deploy/policyFiles/good.xml
  157. +12 −0 target/test-classes/org/secureows/deploy/policyFiles/missing_optional.xml
  158. +4 −0 target/test-classes/org/secureows/deploy/policyFiles/missing_requests.xml
  159. +13 −0 target/test-classes/org/secureows/deploy/policyFiles/missing_security.xml
View
@@ -0,0 +1,19 @@
<classpath>
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
<classpathentry kind="src" path="src/main/scala"/>
<classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
<classpathentry kind="src" path="src/test/scala" output="target/test-classes"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="ch.epfl.lamp.sdt.launching.SCALA_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.4.0/jmock-2.4.0.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar" sourcepath="M2_REPO/junit/junit/4.4/junit-4.4-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/scala-lang/scala-library/2.7.1/scala-library-2.7.1.jar" sourcepath="M2_REPO/org/scala-lang/scala-library/2.7.1/scala-library-2.7.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/scalacheck/scalacheck/1.3/scalacheck-1.3.jar" sourcepath="M2_REPO/org/scalacheck/scalacheck/1.3/scalacheck-1.3-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/scalatest/scalatest/0.9.3/scalatest-0.9.3.jar"/>
<classpathentry kind="var" path="M2_REPO/org/scalaforge/scalax/0.1/scalax-0.1.jar" sourcepath="M2_REPO/org/scalaforge/scalax/0.1/scalax-0.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.5.0/slf4j-api-1.5.0.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.5.0/slf4j-api-1.5.0-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/specs/specs/1.3.1/specs-1.3.1.jar" sourcepath="M2_REPO/org/specs/specs/1.3.1/specs-1.3.1-sources.jar"/>
</classpath>
View
@@ -0,0 +1,14 @@
<projectDescription>
<name>deploy</name>
<comment/>
<projects/>
<buildSpec>
<buildCommand>
<name>ch.epfl.lamp.sdt.core.scalabuilder</name>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>ch.epfl.lamp.sdt.core.scalanature</nature>
</natures>
</projectDescription>
View
103 pom.xml
@@ -0,0 +1,103 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.secureows</groupId>
<artifactId>deploy</artifactId>
<version>1.0-SNAPSHOT</version>
<inceptionYear>2008</inceptionYear>
<properties>
<scala.version>2.7.1</scala.version>
</properties>
<repositories>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scalaforge</groupId>
<artifactId>scalax</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.specs</groupId>
<artifactId>specs</artifactId>
<version>1.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<buildcommands>
<buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
</buildcommands>
<additionalProjectnatures>
<projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
</additionalProjectnatures>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
</classpathContainers>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
No changes.
@@ -0,0 +1,63 @@
package org.secureows.deploy
import scala.xml._
import java.io.{File,PrintStream}
object Validation {
var log:PrintStream = System.out
def validate(webapp:File):Option[String]={
val webinf = new File(webapp,"WEB-INF")
val servicesFile = new File(webinf,"services.xml")
try{
val servicesXML = XML.loadFile(servicesFile)
val services = servicesXML \ "service"
val validateSpecs = for( service <- services ) yield {
if ( (service \\ "role").isEmpty ) {
Some("At least one role must be defined")
} else {
val serviceSpec = new File(webinf,"wmsPolicy_"+(service\"@serviceId")+".xml")
checkServiceSpec(serviceSpec)
}
}
validateSpecs.find( !_.isEmpty ).getOrElse(None)
}catch{
case e:org.xml.sax.SAXParseException => Some(servicesFile+" is not valid XML"+e.getMessage)
}
}
private[deploy] def checkServiceSpec( xmlFile:File ):Option[String]={
def testTags()={
val xml = XML.loadFile(xmlFile)
val tags = Map( "Security"->true,
"Requests"->true,
"GetMap"->false,
"GetFeatureInfo"->false,
"GetCapabilities"->false,
"GetLegendGraphic"->false)
for( (tag,required) <- tags ) yield {
if ( (xml \\ tag ).isEmpty ) {
if( required ) Some( "The "+tag+" is required but is missing")
else {log.printf ("WARNING: the %s tag is missing\n", Array(tag)); None}
}else None
}
}
try{
if( xmlFile.exists() ){
testTags().find( !_.isEmpty ).getOrElse(None)
} else {
Some(xmlFile+" is missing. It is a the definition for a service defined in the services.xml file")
}
}catch{
case e => Some(xmlFile+" is not valid XML"+e.getMessage)
}
}
}
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- XSL stylesheet used to generate web.xml from the service configuration file -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<!-- for debugging -->
<xsl:output method="xml"/>
<xsl:template match="/">
<web-app id="owsproxy" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>owsproxyserver</display-name>
<xsl:apply-templates select="//service"/>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Ows Proxy Realm</realm-name>
</login-config>
</web-app>
</xsl:template>
<xsl:template match="role">
<role-name><xsl:value-of select="."/></role-name>
</xsl:template>
<xsl:template match="service">
<filter>
<filter-name>OWSProxyServletFilter_<xsl:value-of select="@serviceId"/></filter-name>
<filter-class>
org.deegree.security.owsproxy.OWSProxyServletFilter
</filter-class>
<init-param>
<param-name>WMS:POLICY</param-name>
<param-value>/WEB-INF/<xsl:value-of select="@directory"/>/wmsPolicy_<xsl:value-of select="@serviceId"/>.xml</param-value>
</init-param>
<init-param>
<param-name>ALTREQUESTPAGE</param-name>
<param-value>/accessDenied.html</param-value>
</init-param>
</filter>
<!-- TODO OTHERS -->
<filter-mapping>
<filter-name>OWSProxyServletFilter_<xsl:value-of select="@serviceId"/></filter-name>
<servlet-name><xsl:value-of select="@serviceId"/></servlet-name>
</filter-mapping>
<!-- XXX This could be global if no parameter are used -->
<filter>
<filter-name>OWSLoggerFilter_<xsl:value-of select="@serviceId"/></filter-name>
<filter-class>com.camptocamp.owsproxy.OWSLoggerFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OWSLoggerFilter_<xsl:value-of select="@serviceId"/></filter-name>
<servlet-name><xsl:value-of select="@serviceId"/></servlet-name>
</filter-mapping>
<servlet>
<description></description>
<display-name><xsl:value-of select="@serviceDescription"/></display-name>
<servlet-name><xsl:value-of select="@serviceId"/></servlet-name>
<servlet-class>com.camptocamp.owsproxy.OWSProxyServlet</servlet-class>
<init-param>
<param-name>serviceEndPoint</param-name>
<param-value><xsl:value-of select="@serviceEndPoint"/></param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name><xsl:value-of select="@serviceId"/></servlet-name>
<url-pattern>/<xsl:value-of select="@serviceId"/></url-pattern>
</servlet-mapping>
<security-constraint>
<display-name>Ows Proxy Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/<xsl:value-of select="@serviceId"/></url-pattern>
<!-- If you list http methods, only those methods are protected -->
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<!-- Anyone with one of the listed roles may access this area -->
<xsl:apply-templates select="./roles/*"/>
</auth-constraint>
</security-constraint>
</xsl:template>
</xsl:stylesheet>
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<services>
<service serviceId="geoserver"
serviceDescription="Geoserver on localhost"
serviceEndPoint="http://localhost:8080/geoserver/wms">
<roles>
<role>tomcat</role>
<role>role1
</roles>
</service>
</services>
Oops, something went wrong.

0 comments on commit 1686cd9

Please sign in to comment.