From jbossws-commits at lists.jboss.org Thu Dec 18 13:06:14 2008 Content-Type: multipart/mixed; boundary="===============4970188228341418359==" MIME-Version: 1.0 From: jbossws-commits at lists.jboss.org To: jbossws-commits at lists.jboss.org Subject: [jbossws-commits] JBossWS SVN: r8956 - in stack/native/branches/dlofthouse/JBWS-1999/modules: core/src/main/resources/schema and 2 other directories. Date: Thu, 18 Dec 2008 13:06:14 -0500 Message-ID: --===============4970188228341418359== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: darran.lofthouse(a)jboss.com Date: 2008-12-18 13:06:14 -0500 (Thu, 18 Dec 2008) New Revision: 8956 Added: stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/or= g/jboss/ws/metadata/wsse/Authorize.java stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/or= g/jboss/ws/metadata/wsse/Role.java stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/or= g/jboss/ws/metadata/wsse/Unchecked.java stack/native/branches/dlofthouse/JBWS-1999/modules/testsuite/native-test= s/src/test/java/org/jboss/test/ws/jaxws/jbws1999/JBWS1999ConfigurationTestC= ase.java stack/native/branches/dlofthouse/JBWS-1999/modules/testsuite/native-test= s/src/test/resources/jaxws/jbws1999/config/jboss-wsse-default-roles.xml Modified: stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/or= g/jboss/ws/metadata/wsse/Config.java stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/or= g/jboss/ws/metadata/wsse/WSSecurityOMFactory.java stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/resourc= es/schema/jboss-ws-security_1_0.xsd Log: New configuration and test case for reading configuration. Added: stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/jav= a/org/jboss/ws/metadata/wsse/Authorize.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/o= rg/jboss/ws/metadata/wsse/Authorize.java (rev 0) +++ stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/o= rg/jboss/ws/metadata/wsse/Authorize.java 2008-12-18 18:06:14 UTC (rev 8956) @@ -0,0 +1,63 @@ +/* +* JBoss, Home of Professional Open Source. +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* as indicated by the @author tags. See the copyright.txt file in the +* distribution for a full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.ws.metadata.wsse; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Authorize specifies that the users credentials should be = + * checked to ensure the user is authorized to call the endpoint. + * + * @author Darran Lofthous= e + * @since December 18th 2008 + */ +public class Authorize implements Serializable +{ + + private Unchecked unchecked; + + private List roles =3D new ArrayList(); + + public List getRoles() + { + return Collections.unmodifiableList(roles); + } + + public void addRole(final Role role) + { + roles.add(role); + } + + public boolean isUnchecked() + { + return unchecked !=3D null; + } + + void setUnchecked(Unchecked unchecked) + { + this.unchecked =3D unchecked; + } + +} Property changes on: stack/native/branches/dlofthouse/JBWS-1999/modules/cor= e/src/main/java/org/jboss/ws/metadata/wsse/Authorize.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Modified: stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/= java/org/jboss/ws/metadata/wsse/Config.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/o= rg/jboss/ws/metadata/wsse/Config.java 2008-12-18 16:47:44 UTC (rev 8955) +++ stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/o= rg/jboss/ws/metadata/wsse/Config.java 2008-12-18 18:06:14 UTC (rev 8956) @@ -38,6 +38,7 @@ private Encrypt encrypt; private Requires requires; private Authenticate authenticate; + private Authorize authorize; = public Encrypt getEncrypt() { @@ -98,4 +99,14 @@ { this.authenticate =3D authenticate; } + = + public Authorize getAuthorize() + { + return this.authorize; + } + = + public void setAuthorize(Authorize authorize) + { + this.authorize =3D authorize; + } } Added: stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/jav= a/org/jboss/ws/metadata/wsse/Role.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/o= rg/jboss/ws/metadata/wsse/Role.java (rev 0) +++ stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/o= rg/jboss/ws/metadata/wsse/Role.java 2008-12-18 18:06:14 UTC (rev 8956) @@ -0,0 +1,53 @@ +/* +* JBoss, Home of Professional Open Source. +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* as indicated by the @author tags. See the copyright.txt file in the +* distribution for a full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.ws.metadata.wsse; + +import java.io.Serializable; + +/** + * Role representation of a role authorized to call an endpoi= nt. + * + * @author Darran Lofthous= e + * @since December 18th 2008 + */ +public class Role implements Serializable +{ + + private String name; + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name =3D name; + } + + @Override + public String toString() + { + return this.name; + } + +} Property changes on: stack/native/branches/dlofthouse/JBWS-1999/modules/cor= e/src/main/java/org/jboss/ws/metadata/wsse/Role.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/jav= a/org/jboss/ws/metadata/wsse/Unchecked.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/o= rg/jboss/ws/metadata/wsse/Unchecked.java (rev 0) +++ stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/o= rg/jboss/ws/metadata/wsse/Unchecked.java 2008-12-18 18:06:14 UTC (rev 8956) @@ -0,0 +1,35 @@ +/* +* JBoss, Home of Professional Open Source. +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* as indicated by the @author tags. See the copyright.txt file in the +* distribution for a full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ = +package org.jboss.ws.metadata.wsse; + +import java.io.Serializable; + +/** + * Unchecked used when all authenticated users are authorized. + * + * @author Darran Lofthous= e + * @since December 18th 2008 + */ +public class Unchecked implements Serializable +{ + +} Property changes on: stack/native/branches/dlofthouse/JBWS-1999/modules/cor= e/src/main/java/org/jboss/ws/metadata/wsse/Unchecked.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Modified: stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/= java/org/jboss/ws/metadata/wsse/WSSecurityOMFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/o= rg/jboss/ws/metadata/wsse/WSSecurityOMFactory.java 2008-12-18 16:47:44 UTC = (rev 8955) +++ stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/java/o= rg/jboss/ws/metadata/wsse/WSSecurityOMFactory.java 2008-12-18 18:06:14 UTC = (rev 8956) @@ -307,6 +307,10 @@ { return new Authenticate(); } + else if ("authorize".equals(localName)) + { + return new Authorize(); + } = return null; } @@ -363,7 +367,7 @@ { log.trace("addChild: [obj=3D" + config + ",child=3D" + authenticate = + "]"); config.setAuthenticate(authenticate); - } + } = = /** * Called when parsing character is complete. @@ -372,7 +376,7 @@ { log.trace("addChild: [obj=3D" + authenticate + ",child=3D" + usernam= eAuth + "]"); authenticate.setUsernameAuth(usernameAuth); - } + } = = /** * Called when parsing character is complete. @@ -382,7 +386,34 @@ log.trace("addChild: [obj=3D" + authenticate + ",child=3D" + signatu= reCertAuth + "]"); authenticate.setSignatureCertAuth(signatureCertAuth); } - + = + /** + * Called when parsing character is complete. + */ + public void addChild(Config config, Authorize authorize, UnmarshallingC= ontext navigator, String namespaceURI, String localName) + { + log.trace("addChild: [obj=3D" + config + ",child=3D" + authorize + "= ]"); + config.setAuthorize(authorize); + } + = + /** + * Called when parsing character is complete. + */ + public void addChild(Authorize authorize, Unchecked unchecked, Unmarsha= llingContext navigator, String namespaceURI, String localName) + { + log.trace("addChild: [obj=3D" + authorize + ",child=3D" + unchecked = + "]"); + authorize.setUnchecked(unchecked); + } + = + /** + * Called when parsing character is complete. + */ + public void addChild(Authorize authorize, Role role, UnmarshallingConte= xt navigator, String namespaceURI, String localName) + { + log.trace("addChild: [obj=3D" + authorize + ",child=3D" + role + "]"= ); + authorize.addRole(role); + } = + = private Object handleTargets(Object object, UnmarshallingContext naviga= tor, String namespaceURI, String localName, Attributes attrs) { log.trace("newChild: " + localName); @@ -452,7 +483,25 @@ = return null; } + = + /** + * Called when parsing of a new element started. + */ + public Object newChild(Authorize authorize, UnmarshallingContext naviga= tor, String namespaceURI, String localName, Attributes attrs) + { + log.trace("newChild: " + localName); + if ("unchecked".equals(localName)) + { + return new Unchecked(); + } + else if ("role".equals(localName)) + { + return new Role(); + } = + return null; + } = + /** * Called when parsing of a new element started. */ @@ -475,7 +524,14 @@ = target.setValue(value); } + = + public void setValue(Role role, UnmarshallingContext navigator, String = namespaceURI, String localName, String value) + { + log.trace("setValue: [obj=3D" + role + ",value=3D" + value + "]"); = + role.setName(value); + } = + /** * Called when parsing character is complete. */ Modified: stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/= resources/schema/jboss-ws-security_1_0.xsd =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/resour= ces/schema/jboss-ws-security_1_0.xsd 2008-12-18 16:47:44 UTC (rev 8955) +++ stack/native/branches/dlofthouse/JBWS-1999/modules/core/src/main/resour= ces/schema/jboss-ws-security_1_0.xsd 2008-12-18 18:06:14 UTC (rev 8956) @@ -136,6 +136,16 @@ Specifies the token to be used for JAAS authen= tication. If this is not specified, the username token will be used if avai= lable. + + + + Specifies that authentication is required and either provides = a list of roles authorized to access the endpoint or unchecked if any = + authenticated user can access the endpoint. + = + This should only be used for POJO endpoints, EJB3 endpoints sh= ould configure security as for any other EJB3 session bean. = + + + @@ -351,4 +361,19 @@ + + + + + Specifies a role that is allowed to call the e= ndpoint. + + = + + + Specifies that any authenticated user can call= the endpoint. + = + + + + Added: stack/native/branches/dlofthouse/JBWS-1999/modules/testsuite/native-= tests/src/test/java/org/jboss/test/ws/jaxws/jbws1999/JBWS1999ConfigurationT= estCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/native/branches/dlofthouse/JBWS-1999/modules/testsuite/native-tes= ts/src/test/java/org/jboss/test/ws/jaxws/jbws1999/JBWS1999ConfigurationTest= Case.java (rev 0) +++ stack/native/branches/dlofthouse/JBWS-1999/modules/testsuite/native-tes= ts/src/test/java/org/jboss/test/ws/jaxws/jbws1999/JBWS1999ConfigurationTest= Case.java 2008-12-18 18:06:14 UTC (rev 8956) @@ -0,0 +1,76 @@ +/* +* JBoss, Home of Professional Open Source. +* Copyright 2008, Red Hat Middleware LLC, and individual contributors +* as indicated by the @author tags. See the copyright.txt file in the +* distribution for a full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.test.ws.jaxws.jbws1999; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.jboss.ws.metadata.wsse.Authorize; +import org.jboss.ws.metadata.wsse.Config; +import org.jboss.ws.metadata.wsse.Role; +import org.jboss.ws.metadata.wsse.WSSecurityConfiguration; +import org.jboss.ws.metadata.wsse.WSSecurityOMFactory; +import org.jboss.wsf.test.JBossWSTest; + +/** + * Test case to test reading the 'authorize' configuration. + * + * @author Darran Lofthous= e + * @since December 18th 2008 + */ +public class JBWS1999ConfigurationTestCase extends JBossWSTest +{ + + private WSSecurityConfiguration load(final String fileName) throws IOEx= ception + { + File configFile =3D getResourceFile("jaxws/jbws1999/config/" + fileN= ame); + WSSecurityOMFactory factory =3D WSSecurityOMFactory.newInstance(); + + return factory.parse(configFile.toURL()); + } + + /** + * Test loading a configuration with a default 'authorize' definition + * which contains two roles. + */ + public void testDefaultRoles() throws Exception + { + WSSecurityConfiguration wsConfig =3D load("jboss-wsse-default-roles.= xml"); + + Config config =3D wsConfig.getDefaultConfig(); + Authorize authorize =3D config.getAuthorize(); + List roles =3D authorize.getRoles(); + + assertEquals("Expected 2 roles", 2, roles.size()); + + List roleNames =3D new ArrayList(roles.size()); + for (Role current : roles) + { + roleNames.add(current.getName()); + } + assertTrue("Expected 'Trader' role.", roleNames.contains("Trader")); + assertTrue("Expected 'Banker' role.", roleNames.contains("Banker")); + } + +} Property changes on: stack/native/branches/dlofthouse/JBWS-1999/modules/tes= tsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws1999/JBWS1999= ConfigurationTestCase.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: stack/native/branches/dlofthouse/JBWS-1999/modules/testsuite/native-= tests/src/test/resources/jaxws/jbws1999/config/jboss-wsse-default-roles.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/native/branches/dlofthouse/JBWS-1999/modules/testsuite/native-tes= ts/src/test/resources/jaxws/jbws1999/config/jboss-wsse-default-roles.xml = (rev 0) +++ stack/native/branches/dlofthouse/JBWS-1999/modules/testsuite/native-tes= ts/src/test/resources/jaxws/jbws1999/config/jboss-wsse-default-roles.xml 20= 08-12-18 18:06:14 UTC (rev 8956) @@ -0,0 +1,12 @@ + + + + + Banker + Trader + + = + = + \ No newline at end of file Property changes on: stack/native/branches/dlofthouse/JBWS-1999/modules/tes= tsuite/native-tests/src/test/resources/jaxws/jbws1999/config/jboss-wsse-def= ault-roles.xml ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF --===============4970188228341418359==--