From: <st...@us...> - 2009-09-29 13:58:37
|
Revision: 7891 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7891&view=rev Author: steve_l Date: 2009-09-29 13:58:20 +0000 (Tue, 29 Sep 2009) Log Message: ----------- SFOS-628 Security works from the web browser, but not from the test components Modified Paths: -------------- trunk/core/components/jetty/build.xml trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettySecurityRealmImpl.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/components.sf trunk/core/components/jetty/src/org/smartfrog/services/jetty/securityrealm.sf trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/functional/components.sf trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/testwar/components.sf Added Paths: ----------- trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/secureWarServer.sf Modified: trunk/core/components/jetty/build.xml =================================================================== --- trunk/core/components/jetty/build.xml 2009-09-29 13:24:59 UTC (rev 7890) +++ trunk/core/components/jetty/build.xml 2009-09-29 13:58:20 UTC (rev 7891) @@ -49,7 +49,7 @@ <import file="../../common.xml"/> <property name="example.path" value="/org/smartfrog/services/jetty/examples"/> - <property name="deploy.sf" value="org/smartfrog/services/www/jetty/test/system/testwar/examples/warServer.sf"/> + <property name="deploy.sf" value="org/smartfrog/services/jetty/examples/war/secureWarServer.sf"/> Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettySecurityRealmImpl.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettySecurityRealmImpl.java 2009-09-29 13:24:59 UTC (rev 7890) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettySecurityRealmImpl.java 2009-09-29 13:58:20 UTC (rev 7891) @@ -26,6 +26,7 @@ import org.mortbay.jetty.security.ConstraintMapping; import org.mortbay.jetty.security.HashUserRealm; import org.mortbay.jetty.security.SecurityHandler; +import org.mortbay.jetty.security.Password; import org.smartfrog.services.passwords.PasswordHelper; import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.common.SmartFrogException; @@ -82,12 +83,19 @@ String username = v.elementAt(0).toString(); Object passwordEntry = v.elementAt(1); String password = PasswordHelper.extractPassword(this, USERS, passwordEntry); - realm.put(username, password); + Password pass = new Password(password); + realm.put(username, pass); //add the roles + StringBuilder rolelist = new StringBuilder("[ "); for (int role = 2; role < v.size(); role++) { - realm.addUserToRole(username, v.elementAt(role).toString()); + final String rolename = v.elementAt(role).toString(); + rolelist.append("'").append(rolename).append("' "); + realm.addUserToRole(username, rolename); } - sfLog().info("Added User " + username); + rolelist.append("]"); + sfLog().info("Added User " + username + + " in roles " + rolelist + + " pass '" + password + "'"); } //now the constraints constraints = sfResolve(CONSTRAINTS, constraints, true); Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/components.sf =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/components.sf 2009-09-29 13:24:59 UTC (rev 7890) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/components.sf 2009-09-29 13:58:20 UTC (rev 7891) @@ -59,8 +59,14 @@ + SecureWarServer extends JettyWarServer { + + security extends AdminSecurityRealm { + server LAZY PARENT:server; + } + + } - JettyServerOnChannels extends JettyWarServer { Copied: trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/secureWarServer.sf (from rev 7884, trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/jettyWarServer.sf) =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/secureWarServer.sf (rev 0) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/secureWarServer.sf 2009-09-29 13:58:20 UTC (rev 7891) @@ -0,0 +1,24 @@ +/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP + +This library 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 library 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 library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +For more information: www.smartfrog.org + +*/ + +#include "/org/smartfrog/services/jetty/examples/war/components.sf" + + +sfConfig SecureWarServer; \ No newline at end of file Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/securityrealm.sf =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/securityrealm.sf 2009-09-29 13:24:59 UTC (rev 7890) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/securityrealm.sf 2009-09-29 13:58:20 UTC (rev 7891) @@ -44,8 +44,8 @@ METHOD_GET "GET"; METHOD_PUT "GET"; METHOD_POST "POST"; - METHOD_DELETE "POST"; - METHOD_HEAD "POST"; + METHOD_DELETE "DELETE"; + METHOD_HEAD "HEAD"; METHOD_ANY ""; PATH_EVERYTHING "/*"; @@ -62,7 +62,8 @@ users [ - ["admin", adminPassword, name] + ["admin", adminPassword, name], + ["test", "test", name] ]; constraints [ Modified: trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/functional/components.sf =================================================================== --- trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/functional/components.sf 2009-09-29 13:24:59 UTC (rev 7890) +++ trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/functional/components.sf 2009-09-29 13:58:20 UTC (rev 7891) @@ -21,7 +21,7 @@ #include "/org/smartfrog/services/www/jetty/test/system/components.sf" -#include "/org/smartfrog/services/jetty/examples/war/components.sf" +#include "/org/smartfrog/services/www/jetty/test/system/testwar/components.sf" tcp19Test extends JettyTestCompound { @@ -85,7 +85,6 @@ TestSecurity extends JettyTestCompound { condition extends RunFailingTests; - password "secret"; action extends TempDirServer { @@ -94,7 +93,6 @@ security extends AdminSecurityRealm { server LAZY PARENT:server; - adminPassword PARENT:PARENT:password; } } @@ -102,7 +100,7 @@ //we dont care which number comes back, only that we get a number tests extends Sequence { wait extends waitForAnyHttpResponse { - url ( "http://admin:"++password ++ "@localhost:" ++ test.jetty.port.1 ++ "/"); + url ( "http://admin:password@localhost:" ++ test.jetty.port.1 ++ "/"); port action:port; minimumResponseCode HttpCodes:START_2XX; maximumResponseCode HttpCodes:END_2XX; @@ -113,8 +111,6 @@ testSecurityUnauth extends TestSecurity { - condition extends RunFailingTests; - //patch the login tests:wait extends waitForAnyHttpResponse { url ( "http://localhost:" ++ test.jetty.port.1 ++ "/"); @@ -144,13 +140,10 @@ links [["http://jira.smartfrog.org/jira/browse/SFOS-628"]]; - password "secret"; - action extends LocalJettyServer { testRealm extends AdminSecurityRealm { name "testRealm"; - adminPassword password; server LAZY PARENT:server; } @@ -160,7 +153,7 @@ //we dont care which number comes back, only that we get a number tests extends Sequence { wait extends waitForAnyHttpResponse { - url ( "http://admin:"++password ++ "@localhost:" ++ test.jetty.port.1 ++ "/"); + url ( "http://admin:password@localhost:" ++ test.jetty.port.1 ++ "/"); port action:port; } } Modified: trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/testwar/components.sf =================================================================== --- trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/testwar/components.sf 2009-09-29 13:24:59 UTC (rev 7890) +++ trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/testwar/components.sf 2009-09-29 13:58:20 UTC (rev 7891) @@ -118,7 +118,7 @@ host "localhost"; port test.jetty.port.1; path contextPath; - //username "admin"; + username "admin"; password PARENT:ATTRIB password; minimumResponseCode HttpCodes:START_2XX; maximumResponseCode HttpCodes:END_2XX; @@ -154,7 +154,7 @@ testRealm extends JettySecurityRealm { name "testRealm"; users [ - ["test", PARENT:ATTRIB password, "testRole"] + ["test", PARENT:ATTRIB password, name] ]; server LAZY PARENT:server; contextPath "/"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |