]> source.dussan.org Git - archiva.git/commitdiff
package move to o.a.a.r module redback-keys-memory
authorOlivier Lamy <olamy@apache.org>
Sat, 7 Apr 2012 22:18:08 +0000 (22:18 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 7 Apr 2012 22:18:08 +0000 (22:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1310889 13f79535-47bb-0310-9956-ffa450edef68

redback-integrations/redback-rest/redback-rest-services/src/main/java/org/codehaus/redback/rest/services/DefaultLoginService.java
redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/apache/archiva/redback/keys/memory/MemoryAuthenticationKey.java [new file with mode: 0644]
redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/apache/archiva/redback/keys/memory/MemoryKeyManager.java [new file with mode: 0644]
redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/codehaus/plexus/redback/keys/memory/MemoryAuthenticationKey.java [deleted file]
redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/codehaus/plexus/redback/keys/memory/MemoryKeyManager.java [deleted file]
redback-keys/redback-keys-providers/redback-keys-memory/src/main/resources/META-INF/spring-context.xml
redback-keys/redback-keys-providers/redback-keys-memory/src/test/java/org/apache/archiva/redback/keys/memory/MemoryKeyManagerTest.java [new file with mode: 0644]
redback-keys/redback-keys-providers/redback-keys-memory/src/test/java/org/codehaus/plexus/redback/keys/memory/MemoryKeyManagerTest.java [deleted file]

index f9cf65066fbd329fac4c4ba990cd432b39c16cd7..f1f9a8792e16ed9f985537c8e839e7fb2fde4800 100644 (file)
@@ -24,8 +24,8 @@ import org.apache.archiva.redback.users.UserNotFoundException;
 import org.apache.archiva.redback.authentication.PasswordBasedAuthenticationDataSource;
 import org.apache.archiva.redback.keys.AuthenticationKey;
 import org.codehaus.plexus.redback.keys.jdo.JdoAuthenticationKey;
-import org.codehaus.plexus.redback.keys.memory.MemoryAuthenticationKey;
-import org.codehaus.plexus.redback.keys.memory.MemoryKeyManager;
+import org.apache.archiva.redback.keys.memory.MemoryAuthenticationKey;
+import org.apache.archiva.redback.keys.memory.MemoryKeyManager;
 import org.codehaus.plexus.redback.policy.AccountLockedException;
 import org.codehaus.plexus.redback.policy.MustChangePasswordException;
 import org.codehaus.plexus.redback.system.SecuritySession;
diff --git a/redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/apache/archiva/redback/keys/memory/MemoryAuthenticationKey.java b/redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/apache/archiva/redback/keys/memory/MemoryAuthenticationKey.java
new file mode 100644 (file)
index 0000000..fb0b6d0
--- /dev/null
@@ -0,0 +1,109 @@
+package org.apache.archiva.redback.keys.memory;
+
+/*
+ * 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.
+ */
+
+import org.apache.archiva.redback.keys.AuthenticationKey;
+
+import java.util.Date;
+
+/**
+ * MemoryAuthenticationKey
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class MemoryAuthenticationKey
+    implements AuthenticationKey
+{
+    private String key;
+
+    private String forPrincipal;
+
+    private String purpose;
+
+    private Date dateCreated;
+
+    private Date dateExpires;
+
+    public Date getDateCreated()
+    {
+        return dateCreated;
+    }
+
+    public Date getDateExpires()
+    {
+        return dateExpires;
+    }
+
+    public String getForPrincipal()
+    {
+        return forPrincipal;
+    }
+
+    public String getKey()
+    {
+        return key;
+    }
+
+    public String getPurpose()
+    {
+        return purpose;
+    }
+
+    public void setDateCreated( Date dateCreated )
+    {
+        this.dateCreated = dateCreated;
+    }
+
+    public void setDateExpires( Date dateExpires )
+    {
+        this.dateExpires = dateExpires;
+    }
+
+    public void setForPrincipal( String forPrincipal )
+    {
+        this.forPrincipal = forPrincipal;
+    }
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
+
+    public void setPurpose( String purpose )
+    {
+        this.purpose = purpose;
+    }
+
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "MemoryAuthenticationKey[" );
+        sb.append( "key=" ).append( key );
+        sb.append( ",forPrincipal=" ).append( forPrincipal );
+        sb.append( ",purpose=" ).append( purpose );
+        sb.append( ",dateCreated=" ).append( dateCreated );
+        sb.append( ",dateExpired=" ).append( dateExpires );
+        sb.append( ']' );
+
+        return sb.toString();
+    }
+}
diff --git a/redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/apache/archiva/redback/keys/memory/MemoryKeyManager.java b/redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/apache/archiva/redback/keys/memory/MemoryKeyManager.java
new file mode 100644 (file)
index 0000000..6db3864
--- /dev/null
@@ -0,0 +1,126 @@
+package org.apache.archiva.redback.keys.memory;
+
+/*
+ * 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.
+ */
+
+import org.apache.archiva.redback.keys.AbstractKeyManager;
+import org.apache.archiva.redback.keys.AuthenticationKey;
+import org.apache.archiva.redback.keys.KeyManagerException;
+import org.apache.archiva.redback.keys.KeyNotFoundException;
+import org.apache.archiva.redback.keys.memory.MemoryAuthenticationKey;
+import org.codehaus.plexus.util.StringUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * KeyManager backed by an in-memory only store.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+@Service("keyManager#memory")
+public class MemoryKeyManager
+    extends AbstractKeyManager
+{
+    private Map<String, AuthenticationKey> keys = new HashMap<String, AuthenticationKey>();
+
+    public AuthenticationKey createKey( String principal, String purpose, int expirationMinutes )
+        throws KeyManagerException
+    {
+        AuthenticationKey key = new MemoryAuthenticationKey();
+        key.setKey( super.generateUUID() );
+        key.setForPrincipal( principal );
+        key.setPurpose( purpose );
+        key.setDateCreated( new Date() );
+
+        if ( expirationMinutes >= 0 )
+        {
+            Calendar expiration = Calendar.getInstance();
+            expiration.add( Calendar.MINUTE, expirationMinutes );
+            key.setDateExpires( expiration.getTime() );
+        }
+
+        keys.put( key.getKey(), key );
+
+        return key;
+    }
+
+    public AuthenticationKey findKey( String key )
+        throws KeyNotFoundException, KeyManagerException
+    {
+        if ( StringUtils.isEmpty( key ) )
+        {
+            throw new KeyNotFoundException( "Empty key not found." );
+        }
+
+        AuthenticationKey authkey = keys.get( key );
+
+        if ( authkey == null )
+        {
+            throw new KeyNotFoundException( "Key [" + key + "] not found." );
+        }
+
+        assertNotExpired( authkey );
+
+        return authkey;
+    }
+
+    public void deleteKey( AuthenticationKey authkey )
+        throws KeyManagerException
+    {
+        keys.remove( authkey );
+    }
+
+    public void deleteKey( String key )
+        throws KeyManagerException
+    {
+        AuthenticationKey authkey = keys.get( key );
+        if ( authkey != null )
+        {
+            keys.remove( authkey );
+        }
+    }
+
+    public List<AuthenticationKey> getAllKeys()
+    {
+        return new ArrayList<AuthenticationKey>( keys.values() );
+    }
+
+    public AuthenticationKey addKey( AuthenticationKey key )
+    {
+        keys.put( key.getKey(), key );
+        return key;
+    }
+
+    public void eraseDatabase()
+    {
+        keys.clear();
+    }
+
+    public String getId()
+    {
+        return "Memory Key Manager";
+    }
+}
diff --git a/redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/codehaus/plexus/redback/keys/memory/MemoryAuthenticationKey.java b/redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/codehaus/plexus/redback/keys/memory/MemoryAuthenticationKey.java
deleted file mode 100644 (file)
index ead07ca..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.codehaus.plexus.redback.keys.memory;
-
-/*
- * 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.
- */
-
-import org.apache.archiva.redback.keys.AuthenticationKey;
-
-import java.util.Date;
-
-/**
- * MemoryAuthenticationKey
- *
- * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class MemoryAuthenticationKey
-    implements AuthenticationKey
-{
-    private String key;
-
-    private String forPrincipal;
-
-    private String purpose;
-
-    private Date dateCreated;
-
-    private Date dateExpires;
-
-    public Date getDateCreated()
-    {
-        return dateCreated;
-    }
-
-    public Date getDateExpires()
-    {
-        return dateExpires;
-    }
-
-    public String getForPrincipal()
-    {
-        return forPrincipal;
-    }
-
-    public String getKey()
-    {
-        return key;
-    }
-
-    public String getPurpose()
-    {
-        return purpose;
-    }
-
-    public void setDateCreated( Date dateCreated )
-    {
-        this.dateCreated = dateCreated;
-    }
-
-    public void setDateExpires( Date dateExpires )
-    {
-        this.dateExpires = dateExpires;
-    }
-
-    public void setForPrincipal( String forPrincipal )
-    {
-        this.forPrincipal = forPrincipal;
-    }
-
-    public void setKey( String key )
-    {
-        this.key = key;
-    }
-
-    public void setPurpose( String purpose )
-    {
-        this.purpose = purpose;
-    }
-
-    public String toString()
-    {
-        StringBuffer sb = new StringBuffer();
-
-        sb.append( "MemoryAuthenticationKey[" );
-        sb.append( "key=" ).append( key );
-        sb.append( ",forPrincipal=" ).append( forPrincipal );
-        sb.append( ",purpose=" ).append( purpose );
-        sb.append( ",dateCreated=" ).append( dateCreated );
-        sb.append( ",dateExpired=" ).append( dateExpires );
-        sb.append( ']' );
-
-        return sb.toString();
-    }
-}
diff --git a/redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/codehaus/plexus/redback/keys/memory/MemoryKeyManager.java b/redback-keys/redback-keys-providers/redback-keys-memory/src/main/java/org/codehaus/plexus/redback/keys/memory/MemoryKeyManager.java
deleted file mode 100644 (file)
index 4823f81..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.codehaus.plexus.redback.keys.memory;
-
-/*
- * 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.
- */
-
-import org.apache.archiva.redback.keys.AbstractKeyManager;
-import org.apache.archiva.redback.keys.AuthenticationKey;
-import org.apache.archiva.redback.keys.KeyManagerException;
-import org.apache.archiva.redback.keys.KeyNotFoundException;
-import org.codehaus.plexus.util.StringUtils;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * KeyManager backed by an in-memory only store.
- *
- * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
- * @version $Id$
- */
-@Service("keyManager#memory")
-public class MemoryKeyManager
-    extends AbstractKeyManager
-{
-    private Map<String, AuthenticationKey> keys = new HashMap<String, AuthenticationKey>();
-
-    public AuthenticationKey createKey( String principal, String purpose, int expirationMinutes )
-        throws KeyManagerException
-    {
-        AuthenticationKey key = new MemoryAuthenticationKey();
-        key.setKey( super.generateUUID() );
-        key.setForPrincipal( principal );
-        key.setPurpose( purpose );
-        key.setDateCreated( new Date() );
-
-        if ( expirationMinutes >= 0 )
-        {
-            Calendar expiration = Calendar.getInstance();
-            expiration.add( Calendar.MINUTE, expirationMinutes );
-            key.setDateExpires( expiration.getTime() );
-        }
-
-        keys.put( key.getKey(), key );
-
-        return key;
-    }
-
-    public AuthenticationKey findKey( String key )
-        throws KeyNotFoundException, KeyManagerException
-    {
-        if ( StringUtils.isEmpty( key ) )
-        {
-            throw new KeyNotFoundException( "Empty key not found." );
-        }
-
-        AuthenticationKey authkey = keys.get( key );
-
-        if ( authkey == null )
-        {
-            throw new KeyNotFoundException( "Key [" + key + "] not found." );
-        }
-
-        assertNotExpired( authkey );
-
-        return authkey;
-    }
-
-    public void deleteKey( AuthenticationKey authkey )
-        throws KeyManagerException
-    {
-        keys.remove( authkey );
-    }
-
-    public void deleteKey( String key )
-        throws KeyManagerException
-    {
-        AuthenticationKey authkey = keys.get( key );
-        if ( authkey != null )
-        {
-            keys.remove( authkey );
-        }
-    }
-
-    public List<AuthenticationKey> getAllKeys()
-    {
-        return new ArrayList<AuthenticationKey>( keys.values() );
-    }
-
-    public AuthenticationKey addKey( AuthenticationKey key )
-    {
-        keys.put( key.getKey(), key );
-        return key;
-    }
-
-    public void eraseDatabase()
-    {
-        keys.clear();
-    }
-
-    public String getId()
-    {
-        return "Memory Key Manager";
-    }
-}
index a6cf8ab679f62ca5c7bcd3842c4f79818346be00..c314c5d8b3a9ad2db90d29fb2f32721d9d691e20 100644 (file)
@@ -29,6 +29,6 @@
 
   <context:annotation-config />
   <context:component-scan 
-    base-package="org.codehaus.plexus.redback.keys.memory"/>
+    base-package="org.apache.archiva.redback.keys.memory"/>
  
 </beans>
\ No newline at end of file
diff --git a/redback-keys/redback-keys-providers/redback-keys-memory/src/test/java/org/apache/archiva/redback/keys/memory/MemoryKeyManagerTest.java b/redback-keys/redback-keys-providers/redback-keys-memory/src/test/java/org/apache/archiva/redback/keys/memory/MemoryKeyManagerTest.java
new file mode 100644 (file)
index 0000000..256cfd2
--- /dev/null
@@ -0,0 +1,50 @@
+package org.apache.archiva.redback.keys.memory;
+
+/*
+ * 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.
+ */
+
+import org.apache.archiva.redback.keys.KeyManager;
+import org.codehaus.plexus.redback.keys.KeyManagerTestCase;
+import org.junit.Before;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * MemoryKeyManagerTest 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class MemoryKeyManagerTest
+    extends KeyManagerTestCase
+{
+    @Inject @Named(value="keyManager#memory")
+    KeyManager keyManager;
+
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+        
+        super.setKeyManager( keyManager );
+    }
+    
+}
diff --git a/redback-keys/redback-keys-providers/redback-keys-memory/src/test/java/org/codehaus/plexus/redback/keys/memory/MemoryKeyManagerTest.java b/redback-keys/redback-keys-providers/redback-keys-memory/src/test/java/org/codehaus/plexus/redback/keys/memory/MemoryKeyManagerTest.java
deleted file mode 100644 (file)
index e1a502e..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.codehaus.plexus.redback.keys.memory;
-
-/*
- * 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.
- */
-
-import org.apache.archiva.redback.keys.KeyManager;
-import org.codehaus.plexus.redback.keys.KeyManagerTestCase;
-import org.junit.Before;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-/**
- * MemoryKeyManagerTest 
- *
- * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class MemoryKeyManagerTest
-    extends KeyManagerTestCase
-{
-    @Inject @Named(value="keyManager#memory")
-    KeyManager keyManager;
-
-    @Before
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
-        
-        super.setKeyManager( keyManager );
-    }
-    
-}