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;
--- /dev/null
+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();
+ }
+}
--- /dev/null
+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";
+ }
+}
+++ /dev/null
-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();
- }
-}
+++ /dev/null
-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";
- }
-}
<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
--- /dev/null
+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 );
+ }
+
+}
+++ /dev/null
-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 );
- }
-
-}