You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2004/05/28 15:18:32 UTC
cvs commit: jakarta-turbine-fulcrum/security/adapters/turbine/src/java/org/apache/fulcrum/security/adapter/turbine UserAdapter.java
epugh 2004/05/28 06:18:32
Modified: security/adapters/turbine/src/java/org/apache/fulcrum/security/adapter/turbine
UserAdapter.java
Added: security/adapters/turbine/src/test/org/apache/fulcrum/security/adapter/turbine
UserAdapterTest.java
Log:
More methods for UserAdapter. I have had these submitted to me for a while!
Revision Changes Path
1.1 jakarta-turbine-fulcrum/security/adapters/turbine/src/test/org/apache/fulcrum/security/adapter/turbine/UserAdapterTest.java
Index: UserAdapterTest.java
===================================================================
package org.apache.fulcrum.security.adapter.turbine;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import junit.framework.TestCase;
import org.apache.fulcrum.security.entity.User;
import org.apache.fulcrum.security.model.dynamic.entity.DynamicUser;
/**
* Test that we can use a UserAdapter properly.
*
* @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
* @version $Id: UserAdapterTest.java,v 1.1 2004/05/28 13:18:31 epugh Exp $
*/
public class UserAdapterTest extends TestCase
{
/**
* Constructor for UserAdapterTest.
* @param arg0
*/
public UserAdapterTest(String arg0)
{
super(arg0);
}
public void testWithInteger()
{
User user = new DynamicUser();
user.setId(new Integer(56));
UserAdapter ga = new UserAdapter(user);
assertEquals(56, ga.getId());
assertEquals(new Integer(56), ga.getIdAsObj());
}
public void testWithLong()
{
User user = new DynamicUser();
user.setId(new Long(56));
UserAdapter ga = new UserAdapter(user);
assertEquals(56, ga.getId());
assertEquals(new Integer(56), ga.getIdAsObj());
}
public void testWithString()
{
User user = new DynamicUser();
user.setId("56");
UserAdapter ga = new UserAdapter(user);
assertEquals(56, ga.getId());
assertEquals(new Integer(56), ga.getIdAsObj());
}
public void testSetGetTemp(){
User user = new DynamicUser();
user.setId("56");
UserAdapter ga = new UserAdapter(user);
Double d = new Double(10.243);
ga.setTemp("temp",d);
assertSame(ga.getTemp("temp"),d);
}
}
1.2 +34 -27 jakarta-turbine-fulcrum/security/adapters/turbine/src/java/org/apache/fulcrum/security/adapter/turbine/UserAdapter.java
Index: UserAdapter.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/security/adapters/turbine/src/java/org/apache/fulcrum/security/adapter/turbine/UserAdapter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UserAdapter.java 5 Dec 2003 23:33:16 -0000 1.1
+++ UserAdapter.java 28 May 2004 13:18:32 -0000 1.2
@@ -59,6 +59,7 @@
import javax.servlet.http.HttpSessionBindingEvent;
import org.apache.fulcrum.security.entity.SecurityEntity;
+import org.apache.turbine.om.security.TurbineUser;
import org.apache.turbine.om.security.User;
/**
@@ -69,11 +70,19 @@
*/
public class UserAdapter extends BaseAdapter implements User
{
+
+ /*
+ * turbineUser object to delegate extra methods that the fulcrum user
+ * doesn't support
+ */
+ private TurbineUser turbineUser;
- public UserAdapter(org.apache.fulcrum.security.entity.User user)
- {
- super((SecurityEntity)user);
- }
+
+ public UserAdapter(org.apache.fulcrum.security.entity.User user)
+ {
+ super((SecurityEntity)user);
+ turbineUser = new TurbineUser();
+ }
/* Does Nothing.
* @see org.apache.turbine.om.security.User#getAccessCounter()
*/
@@ -109,7 +118,7 @@
{
return null;
}
- /* Does Nothing.
+ /*
* @see org.apache.turbine.om.security.User#getPassword()
*/
public String getPassword()
@@ -140,29 +149,29 @@
return null;
}
- /* Does Nothing.
+ /*
* @see org.apache.turbine.om.security.User#getTempStorage()
*/
public Hashtable getTempStorage()
{
- return null;
+ return turbineUser.getTempStorage();
}
- /* Does Nothing.
+ /*
* @see org.apache.turbine.om.security.User#getTemp(java.lang.String)
*/
public Object getTemp(String arg0)
{
- return null;
+ return turbineUser.getTemp(arg0);
}
- /* Does Nothing.
+ /*
* @see org.apache.turbine.om.security.User#getTemp(java.lang.String, java.lang.Object)
*/
public Object getTemp(String arg0, Object arg1)
{
- return null;
+ return turbineUser.getTemp(arg0,arg1);
}
/* Adapter from getUserName to getName!
* @see org.apache.turbine.om.security.User#getUserName()
@@ -195,20 +204,19 @@
return null;
}
- /* Does Nothing.
+ /*
* @see org.apache.turbine.om.security.User#setHasLoggedIn(java.lang.Boolean)
*/
public void setHasLoggedIn(Boolean arg0)
{
-
+ turbineUser.setHasLoggedIn(arg0);
}
- /* Does Nothing.
+ /*
* @see org.apache.turbine.om.security.User#hasLoggedIn()
*/
public boolean hasLoggedIn()
{
-
- return false;
+ return turbineUser.hasLoggedIn();
}
/* Does Nothing.
* @see org.apache.turbine.om.security.User#incrementAccessCounter()
@@ -224,13 +232,12 @@
{
}
- /* Does Nothing.
+ /*
* @see org.apache.turbine.om.security.User#removeTemp(java.lang.String)
*/
public Object removeTemp(String arg0)
{
-
- return null;
+ return turbineUser.removeTemp(arg0);
}
/* Does Nothing.
* @see org.apache.turbine.om.security.User#setAccessCounter(int)
@@ -260,12 +267,12 @@
{
}
- /* Does Nothing.
+ /*
* @see org.apache.turbine.om.security.User#setPassword(java.lang.String)
*/
public void setPassword(String arg0)
{
- ((org.apache.fulcrum.security.entity.User)entity).setPassword(arg0);
+ ((org.apache.fulcrum.security.entity.User)entity).setPassword(arg0);
}
/* Does Nothing.
* @see org.apache.turbine.om.security.User#setPerm(java.lang.String, java.lang.Object)
@@ -281,26 +288,26 @@
{
}
- /* Does Nothing.
+ /*
* @see org.apache.turbine.om.security.User#setTempStorage(java.util.Hashtable)
*/
public void setTempStorage(Hashtable arg0)
{
-
+ turbineUser.setTempStorage(arg0);
}
- /* Does Nothing.
+ /* D
* @see org.apache.turbine.om.security.User#setTemp(java.lang.String, java.lang.Object)
*/
public void setTemp(String arg0, Object arg1)
{
-
+ turbineUser.setTemp(arg0,arg1);
}
/* Adaper for user name to name.
* @see org.apache.turbine.om.security.User#setUserName(java.lang.String)
*/
public void setUserName(String arg0)
{
- setName(arg0);
+ setName(arg0);
}
/* Does Nothing.
* @see org.apache.turbine.om.security.User#setFirstName(java.lang.String)
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org