directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbenn...@apache.org
Subject svn commit: r486187 [9/49] - in /directory/trunks/triplesec: ./ admin-api/ admin-api/src/ admin-api/src/main/ admin-api/src/main/java/ admin-api/src/main/java/org/ admin-api/src/main/java/org/safehaus/ admin-api/src/main/java/org/safehaus/triplesec/ ad...
Date Tue, 12 Dec 2006 15:24:14 GMT
Added: directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetInitParameterValue.xml
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetInitParameterValue.xml?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetInitParameterValue.xml (added)
+++ directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetInitParameterValue.xml Tue Dec 12 07:23:31 2006
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="WebApp_ID" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
+  <filter> 
+    <filter-name>activation</filter-name>  
+    <filter-class>org.safehaus.triplesec.activation.ActivateAccountFilter</filter-class>  
+    <init-param> 
+      <param-name>PROVIDER_URL</param-name>  
+      <param-value>ldap://localhost:10389/ou=users,dc=example,dc=com</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>SECURITY_PRINCIPAL</param-name>  
+      <param-value>uid=admin,ou=system</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>SECURITY_CREDENTIALS</param-name>  
+      <param-value>secret</param-value> 
+    </init-param>  
+    <!-- sms and smtp configuration -->  
+    <init-param> 
+      <param-name>smtpHost</param-name>  
+      <param-value>hertz</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>smtpSubject</param-name>  
+      <param-value>blah blah bork bork</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>smtpFrom</param-name>  
+      <param-value>dev@safehaus.org</param-value> 
+    </init-param>  
+    <!-- 
+      <init-param>
+          <param-name>smtpUsername</param-name>
+          <param-value>tsec</param-value>
+      </init-param>
+      <init-param>
+          <param-name>smtpPassword</param-name>
+          <param-value>secret</param-value>
+      </init-param>
+       -->  
+    <init-param> 
+      <param-name>smsUsername</param-name>  
+      <param-value>hauskeys</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>smsPassword</param-name>  
+      <param-value>*****</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>smsAccount</param-name>  
+      <param-value>demo</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>smsNmsiHttpUrl</param-name>  
+      <param-value>http://www.nbroadcasting.com/customers/messages/Sender.asp</param-value> 
+    </init-param>  
+    <!-- optional parameter overrides -->  
+    <!-- Uncomment this to make the activation filter generate an error message instead -->  
+    <!-- of generating a decoy midlet for requests with unknown activation keys.  This  -->  
+    <!-- is done by default to prevent trolling applications/bots from being successful.-->  
+    <init-param> 
+      <param-name>doDecoyMidlet</param-name>  
+      <param-value>false</param-value> 
+    </init-param>  
+    <!-- Uncomment this to override the default length of the OTP values generated by   -->  
+    <!-- the midlet produced: 6 by default.  In the future there a per account attrib   -->  
+    <!-- can be used instead of this default value for account specific behavoir.       -->  
+    <!-- 
+      <init-param>
+        <param-name>otpLength</param-name>
+        <param-value>8</param-value>
+      </init-param>
+      -->  
+    <!-- Uncomment this to have the filter use an attribute within the user's entry to  -->  
+    <!-- get the name of the midlet for the user.  The first value of this attribute is -->  
+    <!-- used to set the name of the midlet suite within the MANIFEST and the JAD files -->  
+    <!-- If not set this defaults to the krb5PrincipalRealm for the users account.      -->  
+    <!-- 
+      <init-param>
+        <param-name>midletNameAttribute</param-name>
+        <param-value>safehausMidletName</param-value>
+      </init-param>
+      -->  
+    <!-- Uncomment this to override cleanup time for sweeper; this will be deprecated   -->  
+    <!-- The default is 90000 milliseconds or 90 seconds                                -->  
+    <!-- 
+      <init-param>
+        <param-name>cleanupAfterMillis</param-name>
+        <param-value>120000</param-value>
+      </init-param>
+      --> 
+  </filter>  
+  <filter-mapping> 
+    <filter-name>activation</filter-name>  
+    <url-pattern>/*</url-pattern> 
+  </filter-mapping> 
+</web-app>

Added: directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetInitParameterValueInitial.xml
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetInitParameterValueInitial.xml?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetInitParameterValueInitial.xml (added)
+++ directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetInitParameterValueInitial.xml Tue Dec 12 07:23:31 2006
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="WebApp_ID" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
+  <filter> 
+    <filter-name>activation</filter-name>  
+    <filter-class>org.safehaus.triplesec.activation.ActivateAccountFilter</filter-class>  
+    <init-param> 
+      <param-name>PROVIDER_URL</param-name>  
+      <param-value>ldap://localhost:10389/ou=users,dc=example,dc=com</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>SECURITY_PRINCIPAL</param-name>  
+      <param-value>uid=admin,ou=system</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>SECURITY_CREDENTIALS</param-name>  
+      <param-value>secret</param-value> 
+    </init-param>  
+    <!-- sms and smtp configuration -->  
+    <init-param> 
+      <param-name>smtpHost</param-name>  
+      <param-value>hertz</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>smtpSubject</param-name>  
+      <param-value>Triplesec account activated</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>smtpFrom</param-name>  
+      <param-value>dev@safehaus.org</param-value> 
+    </init-param>  
+    <!-- 
+      <init-param>
+          <param-name>smtpUsername</param-name>
+          <param-value>tsec</param-value>
+      </init-param>
+      <init-param>
+          <param-name>smtpPassword</param-name>
+          <param-value>secret</param-value>
+      </init-param>
+       -->  
+    <init-param> 
+      <param-name>smsUsername</param-name>  
+      <param-value>hauskeys</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>smsPassword</param-name>  
+      <param-value>*****</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>smsAccount</param-name>  
+      <param-value>demo</param-value> 
+    </init-param>  
+    <init-param> 
+      <param-name>smsNmsiHttpUrl</param-name>  
+      <param-value>http://www.nbroadcasting.com/customers/messages/Sender.asp</param-value> 
+    </init-param>  
+    <!-- optional parameter overrides -->  
+    <!-- Uncomment this to make the activation filter generate an error message instead -->  
+    <!-- of generating a decoy midlet for requests with unknown activation keys.  This  -->  
+    <!-- is done by default to prevent trolling applications/bots from being successful.-->  
+    <init-param> 
+      <param-name>doDecoyMidlet</param-name>  
+      <param-value>false</param-value> 
+    </init-param>  
+    <!-- Uncomment this to override the default length of the OTP values generated by   -->  
+    <!-- the midlet produced: 6 by default.  In the future there a per account attrib   -->  
+    <!-- can be used instead of this default value for account specific behavoir.       -->  
+    <!-- 
+      <init-param>
+        <param-name>otpLength</param-name>
+        <param-value>8</param-value>
+      </init-param>
+      -->  
+    <!-- Uncomment this to have the filter use an attribute within the user's entry to  -->  
+    <!-- get the name of the midlet for the user.  The first value of this attribute is -->  
+    <!-- used to set the name of the midlet suite within the MANIFEST and the JAD files -->  
+    <!-- If not set this defaults to the krb5PrincipalRealm for the users account.      -->  
+    <!-- 
+      <init-param>
+        <param-name>midletNameAttribute</param-name>
+        <param-value>safehausMidletName</param-value>
+      </init-param>
+      -->  
+    <!-- Uncomment this to override cleanup time for sweeper; this will be deprecated   -->  
+    <!-- The default is 90000 milliseconds or 90 seconds                                -->  
+    <!-- 
+      <init-param>
+        <param-name>cleanupAfterMillis</param-name>
+        <param-value>120000</param-value>
+      </init-param>
+      --> 
+  </filter>  
+  <filter-mapping> 
+    <filter-name>activation</filter-name>  
+    <url-pattern>/*</url-pattern> 
+  </filter-mapping> 
+</web-app>

Added: directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetServletInitParameterValue.xml
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetServletInitParameterValue.xml?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetServletInitParameterValue.xml (added)
+++ directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetServletInitParameterValue.xml Tue Dec 12 07:23:31 2006
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+  <display-name>Triplesec Configuration</display-name>
+  <servlet>
+    <servlet-name>TripleSecConfigApplication</servlet-name>
+    <servlet-class>wicket.protocol.http.WicketServlet</servlet-class>
+    <init-param>
+      <param-name>applicationClassName</param-name>
+      <param-value>blah blah bork bork</param-value>
+    </init-param>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>TripleSecConfigApplication</servlet-name>
+    <url-pattern>/config/*</url-pattern>
+  </servlet-mapping>
+</web-app>

Added: directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetServletInitParameterValueInitial.xml
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetServletInitParameterValueInitial.xml?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetServletInitParameterValueInitial.xml (added)
+++ directory/trunks/triplesec/configuration-io/src/test/resources/org/safehaus/triplesec/configuration/testSetServletInitParameterValueInitial.xml Tue Dec 12 07:23:31 2006
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app
+      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+      "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+  <display-name>Triplesec Configuration</display-name>
+  <servlet>
+    <servlet-name>TripleSecConfigApplication</servlet-name>
+    <servlet-class>wicket.protocol.http.WicketServlet</servlet-class>
+    <init-param>
+      <param-name>applicationClassName</param-name>
+      <param-value>org.safehaus.triplesec.configui.view.TripleSecConfigApplication</param-value>
+    </init-param>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>TripleSecConfigApplication</servlet-name>
+    <url-pattern>/config/*</url-pattern>
+  </servlet-mapping>
+</web-app>

Added: directory/trunks/triplesec/configuration/pom.xml
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration/pom.xml?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration/pom.xml (added)
+++ directory/trunks/triplesec/configuration/pom.xml Tue Dec 12 07:23:31 2006
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+   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. 
+-->
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.safehaus.triplesec</groupId>
+    <artifactId>build</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>triplesec-configuration</artifactId>
+  <name>Triplesec Configuration API</name>
+  <description>
+    Triplesec Configuration API
+  </description>
+  <packaging>jar</packaging>  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-server-jndi</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>nlog4j</artifactId>
+      <version>1.2.25</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+</project>

Added: directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/ActivationConfiguration.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/ActivationConfiguration.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/ActivationConfiguration.java (added)
+++ directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/ActivationConfiguration.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,87 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.triplesec.configuration;
+
+
+/**
+ * Configuration for activation application.
+ * 
+ * @author <a href="mailto:akarasulu@safehaus.org">Alex Karasulu</a>
+ * @version $Rev$
+ */
+public class ActivationConfiguration
+{
+    public static final boolean ENABLE_DECOY_MIDLET_DEFAULT = false;
+    public static final int OTP_LENGTH_DEFAULT = 6;
+    public static final String MIDLET_NAME_ATTRIBUTE_DEFAULT = "midletNameAttribute";
+    
+    private boolean enableDecoyMidlet = ENABLE_DECOY_MIDLET_DEFAULT;
+    private int otpLength = OTP_LENGTH_DEFAULT;
+    private String midletNameAttribute = MIDLET_NAME_ATTRIBUTE_DEFAULT;
+    private String activationBaseUrl = null;
+    
+    
+    public void setEnableDecoyMidlet( boolean enableDecoyMidlet )
+    {
+        this.enableDecoyMidlet = enableDecoyMidlet;
+    }
+    
+    
+    public boolean isEnableDecoyMidlet()
+    {
+        return enableDecoyMidlet;
+    }
+
+
+    public void setOtpLength( int otpLength )
+    {
+        this.otpLength = otpLength;
+    }
+
+
+    public int getOtpLength()
+    {
+        return otpLength;
+    }
+
+
+    public void setMidletNameAttribute( String midletNameAttribute )
+    {
+        this.midletNameAttribute = midletNameAttribute;
+    }
+
+
+    public String getMidletNameAttribute()
+    {
+        return midletNameAttribute;
+    }
+    
+    
+    public void setActivationBaseUrl( String activationBaseUrl )
+    {
+        this.activationBaseUrl = activationBaseUrl;
+    }
+    
+    
+    public String getActivationBaseUrl()
+    {
+        return activationBaseUrl;
+    }
+}

Added: directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/MutableTriplesecStartupConfiguration.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/MutableTriplesecStartupConfiguration.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/MutableTriplesecStartupConfiguration.java (added)
+++ directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/MutableTriplesecStartupConfiguration.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,205 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.triplesec.configuration;
+
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * 
+ * @author <a href="mailto:akarasulu@safehaus.org">Alex Karasulu</a>
+ * @version $Rev$
+ */
+public class MutableTriplesecStartupConfiguration extends TriplesecStartupConfiguration
+{
+    private static final long serialVersionUID = 515104910980600099L;
+
+
+    public MutableTriplesecStartupConfiguration()
+    {
+        super();
+    }
+    
+
+    public void setEnableHttp( boolean enableHttpService )
+    {
+        super.setEnableHttp( enableHttpService );
+    }
+
+
+    public void setHttpPort( int httpServicePort )
+    {
+        super.setHttpPort( httpServicePort );
+    }
+
+    
+    public void setActivationConfiguration( ActivationConfiguration activationConfiguration )
+    {
+        super.setActivationConfiguration( activationConfiguration );
+    }
+    
+    
+    public void setSmsConfiguration( SmsConfiguration smsConfiguration )
+    {
+        super.setSmsConfiguration( smsConfiguration );
+    }
+    
+    
+    public void setSmtpConfiguration( SmtpConfiguration smtpConfiguration )
+    {
+        super.setSmtpConfiguration( smtpConfiguration );
+    }
+
+
+    public void setAccessControlEnabled( boolean accessControlEnabled )
+    {
+        super.setAccessControlEnabled( accessControlEnabled );
+    }
+
+
+    public void setAllowAnonymousAccess( boolean arg0 )
+    {
+        super.setAllowAnonymousAccess( arg0 );
+    }
+
+
+    public void setAuthenticatorConfigurations( Set arg0 )
+    {
+        super.setAuthenticatorConfigurations( arg0 );
+    }
+
+
+    public void setBootstrapSchemas( Set arg0 )
+    {
+        super.setBootstrapSchemas( arg0 );
+    }
+
+
+    public void setContextPartitionConfigurations( Set arg0 )
+    {
+        super.setContextPartitionConfigurations( arg0 );
+    }
+
+
+    public void setInterceptorConfigurations( List arg0 )
+    {
+        super.setInterceptorConfigurations( arg0 );
+    }
+
+
+    public void setTestEntries( List arg0 )
+    {
+        super.setTestEntries( arg0 );
+    }
+
+
+    public void setWorkingDirectory( File arg0 )
+    {
+        super.setWorkingDirectory( arg0 );
+    }
+
+
+    public void setEnableKerberos( boolean enableKerberos )
+    {
+        super.setEnableKerberos( enableKerberos );
+    }
+
+
+    public void setEnableChangePassword( boolean enableChangePassword )
+    {
+        super.setEnableChangePassword( enableChangePassword );
+    }
+
+
+    public void setEnableNtp( boolean enableNtp )
+    {
+        super.setEnableNtp( enableNtp );
+    }
+
+
+    public void setLdapPort( int ldapPort )
+    {
+        super.setLdapPort( ldapPort );
+    }
+
+
+    public void setLdapsPort( int ldapsPort )
+    {
+        super.setLdapsPort( ldapsPort );
+    }
+
+
+    public void setExtendedOperationHandlers( Collection handlers )
+    {
+        super.setExtendedOperationHandlers( handlers );
+    }
+
+
+    public void setLdifDirectory( File ldifDirectory )
+    {
+        super.setLdifDirectory( ldifDirectory );
+    }
+
+
+    public void setLdifFilters( List ldifFilters )
+    {
+        super.setLdifFilters( ldifFilters );
+    }
+
+
+    public void setEnableLdaps( boolean enableLdaps )
+    {
+        super.setEnableLdaps( enableLdaps );
+    }
+
+
+    public void setLdapsCertificateFile( File ldapsCertificateFile )
+    {
+        super.setLdapsCertificateFile( ldapsCertificateFile );
+    }
+
+
+    public void setLdapsCertificatePassword( String ldapsCertificatePassword )
+    {
+        super.setLdapsCertificatePassword( ldapsCertificatePassword );
+    }
+
+
+    public void setShutdownHookEnabled( boolean shutdownHookEnabled )
+    {
+        super.setShutdownHookEnabled( shutdownHookEnabled );
+    }
+
+
+    public void setExitVmOnShutdown( boolean exitVmOnShutdown )
+    {
+        super.setExitVmOnShutdown( exitVmOnShutdown );
+    }
+    
+    
+    public void setPresentationBaseUrl( String presentationBaseUrl )
+    {
+        super.setPresentationBaseUrl( presentationBaseUrl );
+    }
+}

Added: directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/SmsConfiguration.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/SmsConfiguration.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/SmsConfiguration.java (added)
+++ directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/SmsConfiguration.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,83 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.triplesec.configuration;
+
+
+/**
+ * An SMS provider configuration.
+ * 
+ * @author <a href="mailto:akarasulu@safehaus.org">Alex Karasulu</a>
+ * @version $Rev$
+ */
+public class SmsConfiguration
+{
+    private String username;
+    private String password;
+    private String accountName;
+    private String transportUrl;
+    
+    
+    public void setSmsUsername( String username )
+    {
+        this.username = username;
+    }
+    
+    
+    public String getSmsUsername()
+    {
+        return username;
+    }
+
+
+    public void setSmsPassword( String password )
+    {
+        this.password = password;
+    }
+
+
+    public String getSmsPassword()
+    {
+        return password;
+    }
+
+
+    public void setSmsAccountName( String accountName )
+    {
+        this.accountName = accountName;
+    }
+
+
+    public String getSmsAccountName()
+    {
+        return accountName;
+    }
+
+
+    public void setSmsTransportUrl( String transportUrl )
+    {
+        this.transportUrl = transportUrl;
+    }
+
+
+    public String getSmsTransportUrl()
+    {
+        return transportUrl;
+    }
+}

Added: directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/SmtpConfiguration.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/SmtpConfiguration.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/SmtpConfiguration.java (added)
+++ directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/SmtpConfiguration.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,109 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.triplesec.configuration;
+
+
+/**
+ * The SMTP server configuration.
+ * 
+ * @author <a href="mailto:akarasulu@safehaus.org">Alex Karasulu</a>
+ * @version $Rev$
+ */
+public class SmtpConfiguration
+{
+    private boolean authenticate = false;
+    private String username;
+    private String password;
+    private String host = "localhost";
+    private String subject = "Triplesec account activated";
+    private String from = "dev@safehaus.org";
+    
+    
+    public void setSmtpAuthenticate( boolean authenticate )
+    {
+        this.authenticate = authenticate;
+    }
+    
+    
+    public boolean isSmtpAuthenticate()
+    {
+        return authenticate;
+    }
+
+
+    public void setSmtpUsername( String username )
+    {
+        this.username = username;
+    }
+
+
+    public String getSmtpUsername()
+    {
+        return username;
+    }
+
+
+    public void setSmtpPassword( String password )
+    {
+        this.password = password;
+    }
+
+
+    public String getSmtpPassword()
+    {
+        return password;
+    }
+
+
+    public void setSmtpHost( String host )
+    {
+        this.host = host;
+    }
+
+
+    public String getSmtpHost()
+    {
+        return host;
+    }
+
+
+    public void setSmtpSubject( String subject )
+    {
+        this.subject = subject;
+    }
+
+
+    public String getSmtpSubject()
+    {
+        return subject;
+    }
+
+
+    public void setSmtpFrom( String from )
+    {
+        this.from = from;
+    }
+
+
+    public String getSmtpFrom()
+    {
+        return from;
+    }
+}

Added: directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/TriplesecStartupConfiguration.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/TriplesecStartupConfiguration.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/TriplesecStartupConfiguration.java (added)
+++ directory/trunks/triplesec/configuration/src/main/java/org/safehaus/triplesec/configuration/TriplesecStartupConfiguration.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,118 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.triplesec.configuration;
+
+
+import org.apache.directory.server.configuration.ServerStartupConfiguration;
+
+
+/**
+ * 
+ * @author <a href="mailto:akarasulu@safehaus.org">Alex Karasulu</a>
+ * @version $Rev$
+ */
+public class TriplesecStartupConfiguration extends ServerStartupConfiguration
+{
+    private static final long serialVersionUID = -7138616822614155454L;
+
+    private boolean enableHttp = true;
+    private int httpPort = 8383;
+    private String presentationBaseUrl;
+    private ActivationConfiguration activationConfiguration = new ActivationConfiguration();
+    private SmsConfiguration smsConfiguration = new SmsConfiguration();
+    private SmtpConfiguration smtpConfiguration = new SmtpConfiguration();
+
+    
+    public TriplesecStartupConfiguration()
+    {
+    }
+    
+    
+    public SmsConfiguration getSmsConfiguration()
+    {
+        return smsConfiguration;
+    }
+    
+    
+    protected void setSmsConfiguration( SmsConfiguration smsConfiguration )
+    {
+        this.smsConfiguration = smsConfiguration;
+    }
+    
+    
+    public SmtpConfiguration getSmtpConfiguration()
+    {
+        return smtpConfiguration;
+    }
+    
+    
+    protected void setSmtpConfiguration( SmtpConfiguration smtpConfiguration )
+    {
+        this.smtpConfiguration = smtpConfiguration;
+    }
+
+
+    public ActivationConfiguration getActivationConfiguration()
+    {
+        return activationConfiguration;
+    }
+    
+    
+    protected void setActivationConfiguration( ActivationConfiguration activationConfiguration )
+    {
+        this.activationConfiguration = activationConfiguration;
+    }
+
+
+    protected void setEnableHttp( boolean enableHttpService )
+    {
+        this.enableHttp = enableHttpService;
+    }
+
+
+    public boolean isEnableHttp()
+    {
+        return enableHttp;
+    }
+
+
+    protected void setHttpPort( int httpServicePort )
+    {
+        this.httpPort = httpServicePort;
+    }
+
+
+    public int getHttpPort()
+    {
+        return httpPort;
+    }
+
+
+    protected void setPresentationBaseUrl( String presentationBaseUrl )
+    {
+        this.presentationBaseUrl = presentationBaseUrl;
+    }
+
+
+    public String getPresentationBaseUrl()
+    {
+        return presentationBaseUrl;
+    }
+}

Added: directory/trunks/triplesec/configuration/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration/src/test/resources/log4j.properties?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration/src/test/resources/log4j.properties (added)
+++ directory/trunks/triplesec/configuration/src/test/resources/log4j.properties Tue Dec 12 07:23:31 2006
@@ -0,0 +1,6 @@
+log4j.rootCategory=WARN, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+

Added: directory/trunks/triplesec/configuration/src/test/resources/org/safehaus/triplesec/configuration/testAddEnvironment0.xml
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration/src/test/resources/org/safehaus/triplesec/configuration/testAddEnvironment0.xml?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration/src/test/resources/org/safehaus/triplesec/configuration/testAddEnvironment0.xml (added)
+++ directory/trunks/triplesec/configuration/src/test/resources/org/safehaus/triplesec/configuration/testAddEnvironment0.xml Tue Dec 12 07:23:31 2006
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans>
+  <bean id="environment" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+    <property name="properties">
+      <props/>
+    </property>
+  </bean>
+</beans>

Added: directory/trunks/triplesec/configuration/src/test/resources/org/safehaus/triplesec/configuration/testAddEnvironment1.xml
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/configuration/src/test/resources/org/safehaus/triplesec/configuration/testAddEnvironment1.xml?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/configuration/src/test/resources/org/safehaus/triplesec/configuration/testAddEnvironment1.xml (added)
+++ directory/trunks/triplesec/configuration/src/test/resources/org/safehaus/triplesec/configuration/testAddEnvironment1.xml Tue Dec 12 07:23:31 2006
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans>
+  <bean id="environment" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+    <property name="properties">
+      <props>
+        <prop key="property1key">property1value</prop>
+      </props>
+    </property>
+  </bean>
+</beans>

Added: directory/trunks/triplesec/crypto/pom.xml
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/crypto/pom.xml?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/crypto/pom.xml (added)
+++ directory/trunks/triplesec/crypto/pom.xml Tue Dec 12 07:23:31 2006
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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. 
+-->
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.safehaus.triplesec</groupId>
+    <artifactId>build</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>triplesec-crypto</artifactId>
+  <name>Triplesec Crypto API</name>
+  <description>
+    Cryptography packages for various algorithms. 
+  </description>
+  <packaging>jar</packaging>  
+</project>

Added: directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/BlockCipher.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/BlockCipher.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/BlockCipher.java (added)
+++ directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/BlockCipher.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,75 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.crypto;
+
+
+/**
+ * Block cipher engines are expected to conform to this interface.
+ */
+public interface BlockCipher
+{
+    /**
+     * Initialise the cipher.
+     *
+     * @param forEncryption if true the cipher is initialised for
+     *  encryption, if false for decryption.
+     * @param params the key and other data required by the cipher.
+     * @exception IllegalArgumentException if the params argument is
+     * inappropriate.
+     */
+    public void init(boolean forEncryption, CipherParameters params)
+        throws IllegalArgumentException;
+
+    /**
+     * Return the name of the algorithm the cipher implements.
+     *
+     * @return the name of the algorithm the cipher implements.
+     */
+    public String getAlgorithmName();
+
+    /**
+     * Return the block size for this cipher (in bytes).
+     *
+     * @return the block size for this cipher in bytes.
+     */
+    public int getBlockSize();
+
+    /**
+     * Process one block of input from the array in and write it to
+     * the out array.
+     *
+     * @param in the array containing the input data.
+     * @param inOff offset into the in array the data starts at.
+     * @param out the array the output data will be copied into.
+     * @param outOff the offset into the out array the output will start at.
+     * @exception DataLengthException if there isn't enough data in in, or
+     * space in out.
+     * @exception IllegalStateException if the cipher isn't initialised.
+     * @return the number of bytes processed and produced.
+     */
+    public int processBlock(byte[] in, int inOff, byte[] out, int outOff)
+        throws DataLengthException, IllegalStateException;
+
+    /**
+     * Reset the cipher. After resetting the cipher is in the same state
+     * as it was after the last init (if there was one).
+     */
+    public void reset();
+}

Added: directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/BlockCipherWrapper.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/BlockCipherWrapper.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/BlockCipherWrapper.java (added)
+++ directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/BlockCipherWrapper.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,205 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.crypto;
+
+
+import java.io.UnsupportedEncodingException;
+
+
+/**
+ * Wraps a BlockCipher to simplify its use in encrypting/decrypting variable
+ * length inputs.
+ *
+ * @author <a href="mailto:akarasulu@safehaus.org">Alex Karasulu</a>
+ * @version $Rev$
+ */
+public class BlockCipherWrapper
+{
+    /** the underlying BlockCipher engine */
+    private final Class engineClass;
+
+
+    /**
+     * Creates a BlockCipherWrapper for an underlying BlockCipher.
+     *
+     * @param engineClass the class of the engine to wrap
+     */
+    public BlockCipherWrapper( Class engineClass )
+    {
+        this.engineClass = engineClass;
+    }
+
+
+    /**
+     * Encrypts a byte array using underlying engine with a password String.
+     * To generate the key bytes the UTF-8 encoding is presumed for the password.
+     * The generated bytes may be tail padded to reach a multiple of the block
+     * size.
+     *
+     * @param password the string representing the users password
+     * @param input the unpadded data to be encrypted
+     * @return the encrypted data padded to the nearest multiple of the block size
+     * @throws java.io.UnsupportedEncodingException if the UTF-8 encoding is not supported
+     */
+    public byte[] encrypt( String password, byte[] input ) throws UnsupportedEncodingException
+    {
+        KeyParameter key = generateKey( password );
+        return encrypt( key, input );
+    }
+
+
+    /**
+     * Encrypts the input with the supplied key.
+     *
+     * @param key the key to use for encrypting the input
+     * @param input the unpadded data to encrypt
+     * @return the encrypted data padded to the nearest multiple of the block size
+     */
+    public byte[] encrypt( KeyParameter key, byte[] input )
+    {
+        BlockCipher engine;
+
+        try
+        {
+            engine = ( BlockCipher ) engineClass.newInstance();
+        }
+        catch ( Exception e)
+        {
+            throw new RuntimeCryptoException( e.getMessage() );
+        }
+
+        engine.init( true, key );
+        int oriInputLength = input.length;
+        int paddedInputLength = ( input.length/engine.getBlockSize() + 1 ) * engine.getBlockSize();
+        byte[] paddedInput = new byte[paddedInputLength];
+        System.arraycopy( input, 0, paddedInput, 0, oriInputLength );
+        byte[] paddedOutput = new byte[paddedInputLength];
+
+        int pos = 0;
+        while ( pos < paddedInputLength )
+        {
+            pos += engine.processBlock( paddedInput, pos, paddedOutput, pos );
+        }
+
+        return paddedOutput;
+    }
+
+
+    /**
+     * Decrypts an encrypted input with the supplied key.
+     *
+     * @param password the string representing the users password
+     * @param input the unpadded data to be encrypted
+     * @return the decrypted data padded to the nearest multiple of the block size
+     * @throws UnsupportedEncodingException if the UTF-8 encoding is not supported
+     */
+    public byte[] decrypt( String password, byte[] input ) throws UnsupportedEncodingException
+    {
+        KeyParameter key = generateKey( password );
+        return decrypt( key, input );
+    }
+
+
+    /**
+     * Decrypts the input with the supplied key.
+     *
+     * @param key the key to use for decrypting the input
+     * @param input the padded cipher data to decrypt
+     * @return the decrypted data padded to the nearest multiple of the block size
+     */
+    public byte[] decrypt( KeyParameter key, byte[] input )
+    {
+        BlockCipher engine;
+
+        try
+        {
+            engine = ( BlockCipher ) engineClass.newInstance();
+        }
+        catch ( Exception e)
+        {
+            throw new RuntimeCryptoException( e.getMessage() );
+        }
+
+        engine.init( false, key );
+        int oriInputLength = input.length;
+        int adjInputLength = ( input.length/engine.getBlockSize() + 1 ) * engine.getBlockSize();
+        byte[] adjInput = new byte[adjInputLength];
+        System.arraycopy( input, 0, adjInput, 0, oriInputLength );
+        byte[] adjOutput = new byte[adjInputLength];
+
+        int pos = 0;
+        while ( pos < adjInputLength )
+        {
+            pos += engine.processBlock( adjInput, pos, adjOutput, pos );
+        }
+
+        byte[] output = new byte[oriInputLength];
+        System.arraycopy( adjOutput, 0, output, 0, oriInputLength );
+        return output;
+    }
+
+
+    public KeyParameter generateKey( String password ) throws UnsupportedEncodingException
+    {
+    	// commented out a bunch of stuff that caused failures when we obfuscated the app
+    	
+        byte[] passwordBytes = password.getBytes( "UTF-8" );
+//        int bits = passwordBytes.length << 3;
+        byte[] key;
+
+//        if ( engineClass.getName().equals( "org.safehaus.crypto.AESEngine" ) )
+//        {
+//            if ( bits < 128 )
+//            {
+//                key = new byte[16];
+//                System.arraycopy( passwordBytes, 0, key, 0, passwordBytes.length );
+//            }
+//            else if ( 128 < bits && bits < 192 )
+//            {
+//                key = new byte[24];
+//                System.arraycopy( passwordBytes, 0, key, 0, passwordBytes.length );
+//            }
+//            else
+//            {
+//                key = new byte[32];
+//                System.arraycopy( passwordBytes, 0, key, 0, passwordBytes.length );
+//            }
+//        }
+//        else if ( engineClass.getName().equals( "org.safehaus.crypto.DESEngine" ) )
+//        {
+            key = new byte[8];
+
+            if ( 8 > passwordBytes.length )
+            {
+                System.arraycopy( passwordBytes, 0, key, 0, passwordBytes.length );
+            }
+            else
+            {
+                System.arraycopy( passwordBytes, 0, key, 0, 8 );
+            }
+//        }
+//        else
+//        {
+//            throw new RuntimeCryptoException( "unrecognized engine class cannot generate key for it" );
+//        }
+
+        return new KeyParameter( key );
+    }
+}

Added: directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/CipherParameters.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/CipherParameters.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/CipherParameters.java (added)
+++ directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/CipherParameters.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,27 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.crypto;
+
+/**
+ * all parameter classes implement this.
+ */
+public interface CipherParameters
+{
+}

Added: directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/DESEngine.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/DESEngine.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/DESEngine.java (added)
+++ directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/DESEngine.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,509 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.crypto;
+
+
+/**
+ * a class that provides a basic DES engine.
+ */
+public class DESEngine
+    implements BlockCipher
+{
+    protected static final int  BLOCK_SIZE = 8;
+
+    private int[]               workingKey = null;
+
+    /**
+     * standard constructor.
+     */
+    public DESEngine()
+    {
+    }
+
+    /**
+     * initialise a DES cipher.
+     *
+     * @param encrypting whether or not we are for encryption.
+     * @param params the parameters required to set up the cipher.
+     * @exception IllegalArgumentException if the params argument is
+     * inappropriate.
+     */
+    public void init(
+        boolean           encrypting,
+        CipherParameters  params)
+    {
+        if (params instanceof KeyParameter)
+        {
+            if (((KeyParameter)params).getKey().length > 8)
+            {
+                throw new IllegalArgumentException("DES key too long - should be 8 bytes");
+            }
+            
+            workingKey = generateWorkingKey(encrypting,
+                                  ((KeyParameter)params).getKey());
+
+            return;
+        }
+
+        throw new IllegalArgumentException( "invalid parameter passed to DES init - " );
+    }
+
+    public String getAlgorithmName()
+    {
+        return "DES";
+    }
+
+    public int getBlockSize()
+    {
+        return BLOCK_SIZE;
+    }
+
+    public int processBlock(
+        byte[] in,
+        int inOff,
+        byte[] out,
+        int outOff)
+    {
+        if (workingKey == null)
+        {
+            throw new IllegalStateException("DES engine not initialised");
+        }
+
+        if ((inOff + BLOCK_SIZE) > in.length)
+        {
+            throw new DataLengthException("input buffer too short");
+        }
+
+        if ((outOff + BLOCK_SIZE) > out.length)
+        {
+            throw new DataLengthException("output buffer too short");
+        }
+
+        desFunc(workingKey, in, inOff, out, outOff);
+
+        return BLOCK_SIZE;
+    }
+
+    public void reset()
+    {
+    }
+
+    /**
+     * what follows is mainly taken from "Applied Cryptography", by
+     * Bruce Schneier, however it also bears great resemblance to Richard
+     * Outerbridge's D3DES...
+     */
+
+    static short[]    Df_Key =
+        {
+            0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
+            0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
+            0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67
+        };
+
+    static short[]    bytebit =
+        {
+            0200, 0100, 040, 020, 010, 04, 02, 01
+        };
+
+    static int[]    bigbyte =
+        {
+            0x800000, 0x400000, 0x200000, 0x100000,
+            0x80000,  0x40000,  0x20000,  0x10000,
+            0x8000,      0x4000,   0x2000,   0x1000,
+            0x800,    0x400,    0x200,    0x100,
+            0x80,      0x40,        0x20,     0x10,
+            0x8,      0x4,      0x2,      0x1
+        };
+
+    /*
+     * Use the key schedule specified in the Standard (ANSI X3.92-1981).
+     */
+
+    static byte[]    pc1 =
+        {
+            56, 48, 40, 32, 24, 16,  8,   0, 57, 49, 41, 33, 25, 17,
+             9,  1, 58, 50, 42, 34, 26,  18, 10,  2, 59, 51, 43, 35,
+            62, 54, 46, 38, 30, 22, 14,   6, 61, 53, 45, 37, 29, 21,
+            13,  5, 60, 52, 44, 36, 28,  20, 12,  4, 27, 19, 11,  3
+        };
+
+    static byte[] totrot =
+        {
+            1, 2, 4, 6, 8, 10, 12, 14,
+            15, 17, 19, 21, 23, 25, 27, 28
+        };
+
+    static byte[] pc2 =
+        {
+            13, 16, 10, 23,  0,  4,  2, 27, 14,  5, 20,  9,
+            22, 18, 11,  3, 25,  7, 15,  6, 26, 19, 12,  1,
+            40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
+            43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31
+        };
+
+    static int[] SP1 = {
+        0x01010400, 0x00000000, 0x00010000, 0x01010404,
+        0x01010004, 0x00010404, 0x00000004, 0x00010000,
+        0x00000400, 0x01010400, 0x01010404, 0x00000400,
+        0x01000404, 0x01010004, 0x01000000, 0x00000004,
+        0x00000404, 0x01000400, 0x01000400, 0x00010400,
+        0x00010400, 0x01010000, 0x01010000, 0x01000404,
+        0x00010004, 0x01000004, 0x01000004, 0x00010004,
+        0x00000000, 0x00000404, 0x00010404, 0x01000000,
+        0x00010000, 0x01010404, 0x00000004, 0x01010000,
+        0x01010400, 0x01000000, 0x01000000, 0x00000400,
+        0x01010004, 0x00010000, 0x00010400, 0x01000004,
+        0x00000400, 0x00000004, 0x01000404, 0x00010404,
+        0x01010404, 0x00010004, 0x01010000, 0x01000404,
+        0x01000004, 0x00000404, 0x00010404, 0x01010400,
+        0x00000404, 0x01000400, 0x01000400, 0x00000000,
+        0x00010004, 0x00010400, 0x00000000, 0x01010004
+    };
+
+    static int[] SP2 = {
+        0x80108020, 0x80008000, 0x00008000, 0x00108020,
+        0x00100000, 0x00000020, 0x80100020, 0x80008020,
+        0x80000020, 0x80108020, 0x80108000, 0x80000000,
+        0x80008000, 0x00100000, 0x00000020, 0x80100020,
+        0x00108000, 0x00100020, 0x80008020, 0x00000000,
+        0x80000000, 0x00008000, 0x00108020, 0x80100000,
+        0x00100020, 0x80000020, 0x00000000, 0x00108000,
+        0x00008020, 0x80108000, 0x80100000, 0x00008020,
+        0x00000000, 0x00108020, 0x80100020, 0x00100000,
+        0x80008020, 0x80100000, 0x80108000, 0x00008000,
+        0x80100000, 0x80008000, 0x00000020, 0x80108020,
+        0x00108020, 0x00000020, 0x00008000, 0x80000000,
+        0x00008020, 0x80108000, 0x00100000, 0x80000020,
+        0x00100020, 0x80008020, 0x80000020, 0x00100020,
+        0x00108000, 0x00000000, 0x80008000, 0x00008020,
+        0x80000000, 0x80100020, 0x80108020, 0x00108000
+    };
+
+    static int[] SP3 = {
+        0x00000208, 0x08020200, 0x00000000, 0x08020008,
+        0x08000200, 0x00000000, 0x00020208, 0x08000200,
+        0x00020008, 0x08000008, 0x08000008, 0x00020000,
+        0x08020208, 0x00020008, 0x08020000, 0x00000208,
+        0x08000000, 0x00000008, 0x08020200, 0x00000200,
+        0x00020200, 0x08020000, 0x08020008, 0x00020208,
+        0x08000208, 0x00020200, 0x00020000, 0x08000208,
+        0x00000008, 0x08020208, 0x00000200, 0x08000000,
+        0x08020200, 0x08000000, 0x00020008, 0x00000208,
+        0x00020000, 0x08020200, 0x08000200, 0x00000000,
+        0x00000200, 0x00020008, 0x08020208, 0x08000200,
+        0x08000008, 0x00000200, 0x00000000, 0x08020008,
+        0x08000208, 0x00020000, 0x08000000, 0x08020208,
+        0x00000008, 0x00020208, 0x00020200, 0x08000008,
+        0x08020000, 0x08000208, 0x00000208, 0x08020000,
+        0x00020208, 0x00000008, 0x08020008, 0x00020200
+    };
+
+    static int[] SP4 = {
+        0x00802001, 0x00002081, 0x00002081, 0x00000080,
+        0x00802080, 0x00800081, 0x00800001, 0x00002001,
+        0x00000000, 0x00802000, 0x00802000, 0x00802081,
+        0x00000081, 0x00000000, 0x00800080, 0x00800001,
+        0x00000001, 0x00002000, 0x00800000, 0x00802001,
+        0x00000080, 0x00800000, 0x00002001, 0x00002080,
+        0x00800081, 0x00000001, 0x00002080, 0x00800080,
+        0x00002000, 0x00802080, 0x00802081, 0x00000081,
+        0x00800080, 0x00800001, 0x00802000, 0x00802081,
+        0x00000081, 0x00000000, 0x00000000, 0x00802000,
+        0x00002080, 0x00800080, 0x00800081, 0x00000001,
+        0x00802001, 0x00002081, 0x00002081, 0x00000080,
+        0x00802081, 0x00000081, 0x00000001, 0x00002000,
+        0x00800001, 0x00002001, 0x00802080, 0x00800081,
+        0x00002001, 0x00002080, 0x00800000, 0x00802001,
+        0x00000080, 0x00800000, 0x00002000, 0x00802080
+    };
+
+    static int[] SP5 = {
+        0x00000100, 0x02080100, 0x02080000, 0x42000100,
+        0x00080000, 0x00000100, 0x40000000, 0x02080000,
+        0x40080100, 0x00080000, 0x02000100, 0x40080100,
+        0x42000100, 0x42080000, 0x00080100, 0x40000000,
+        0x02000000, 0x40080000, 0x40080000, 0x00000000,
+        0x40000100, 0x42080100, 0x42080100, 0x02000100,
+        0x42080000, 0x40000100, 0x00000000, 0x42000000,
+        0x02080100, 0x02000000, 0x42000000, 0x00080100,
+        0x00080000, 0x42000100, 0x00000100, 0x02000000,
+        0x40000000, 0x02080000, 0x42000100, 0x40080100,
+        0x02000100, 0x40000000, 0x42080000, 0x02080100,
+        0x40080100, 0x00000100, 0x02000000, 0x42080000,
+        0x42080100, 0x00080100, 0x42000000, 0x42080100,
+        0x02080000, 0x00000000, 0x40080000, 0x42000000,
+        0x00080100, 0x02000100, 0x40000100, 0x00080000,
+        0x00000000, 0x40080000, 0x02080100, 0x40000100
+    };
+
+    static int[] SP6 = {
+        0x20000010, 0x20400000, 0x00004000, 0x20404010,
+        0x20400000, 0x00000010, 0x20404010, 0x00400000,
+        0x20004000, 0x00404010, 0x00400000, 0x20000010,
+        0x00400010, 0x20004000, 0x20000000, 0x00004010,
+        0x00000000, 0x00400010, 0x20004010, 0x00004000,
+        0x00404000, 0x20004010, 0x00000010, 0x20400010,
+        0x20400010, 0x00000000, 0x00404010, 0x20404000,
+        0x00004010, 0x00404000, 0x20404000, 0x20000000,
+        0x20004000, 0x00000010, 0x20400010, 0x00404000,
+        0x20404010, 0x00400000, 0x00004010, 0x20000010,
+        0x00400000, 0x20004000, 0x20000000, 0x00004010,
+        0x20000010, 0x20404010, 0x00404000, 0x20400000,
+        0x00404010, 0x20404000, 0x00000000, 0x20400010,
+        0x00000010, 0x00004000, 0x20400000, 0x00404010,
+        0x00004000, 0x00400010, 0x20004010, 0x00000000,
+        0x20404000, 0x20000000, 0x00400010, 0x20004010
+    };
+
+    static int[] SP7 = {
+        0x00200000, 0x04200002, 0x04000802, 0x00000000,
+        0x00000800, 0x04000802, 0x00200802, 0x04200800,
+        0x04200802, 0x00200000, 0x00000000, 0x04000002,
+        0x00000002, 0x04000000, 0x04200002, 0x00000802,
+        0x04000800, 0x00200802, 0x00200002, 0x04000800,
+        0x04000002, 0x04200000, 0x04200800, 0x00200002,
+        0x04200000, 0x00000800, 0x00000802, 0x04200802,
+        0x00200800, 0x00000002, 0x04000000, 0x00200800,
+        0x04000000, 0x00200800, 0x00200000, 0x04000802,
+        0x04000802, 0x04200002, 0x04200002, 0x00000002,
+        0x00200002, 0x04000000, 0x04000800, 0x00200000,
+        0x04200800, 0x00000802, 0x00200802, 0x04200800,
+        0x00000802, 0x04000002, 0x04200802, 0x04200000,
+        0x00200800, 0x00000000, 0x00000002, 0x04200802,
+        0x00000000, 0x00200802, 0x04200000, 0x00000800,
+        0x04000002, 0x04000800, 0x00000800, 0x00200002
+    };
+
+    static int[] SP8 = {
+        0x10001040, 0x00001000, 0x00040000, 0x10041040,
+        0x10000000, 0x10001040, 0x00000040, 0x10000000,
+        0x00040040, 0x10040000, 0x10041040, 0x00041000,
+        0x10041000, 0x00041040, 0x00001000, 0x00000040,
+        0x10040000, 0x10000040, 0x10001000, 0x00001040,
+        0x00041000, 0x00040040, 0x10040040, 0x10041000,
+        0x00001040, 0x00000000, 0x00000000, 0x10040040,
+        0x10000040, 0x10001000, 0x00041040, 0x00040000,
+        0x00041040, 0x00040000, 0x10041000, 0x00001000,
+        0x00000040, 0x10040040, 0x00001000, 0x00041040,
+        0x10001000, 0x00000040, 0x10000040, 0x10040000,
+        0x10040040, 0x10000000, 0x00040000, 0x10001040,
+        0x00000000, 0x10041040, 0x00040040, 0x10000040,
+        0x10040000, 0x10001000, 0x10001040, 0x00000000,
+        0x10041040, 0x00041000, 0x00041000, 0x00001040,
+        0x00001040, 0x00040040, 0x10000000, 0x10041000
+    };
+
+    /**
+     * generate an integer based working key based on our secret key
+     * and what we processing we are planning to do.
+     *
+     * Acknowledgements for this routine go to James Gillogly & Phil Karn.
+     *         (whoever, and wherever they are!).
+     */
+    protected int[] generateWorkingKey(
+        boolean encrypting,
+        byte[]  key)
+    {
+        int[]       newKey = new int[32];
+        boolean[]   pc1m = new boolean[56],
+                    pcr = new boolean[56];
+
+        for (int j = 0; j < 56; j++ )
+        {
+            int    l = pc1[j];
+
+            pc1m[j] = ((key[l >>> 3] & bytebit[l & 07]) != 0);
+        }
+
+        for (int i = 0; i < 16; i++)
+        {
+            int    l, m, n;
+
+            if (encrypting)
+            {
+                m = i << 1;
+            }
+            else
+            {
+                m = (15 - i) << 1;
+            }
+
+            n = m + 1;
+            newKey[m] = newKey[n] = 0;
+
+            for (int j = 0; j < 28; j++)
+            {
+                l = j + totrot[i];
+                if ( l < 28 )
+                {
+                    pcr[j] = pc1m[l];
+                }
+                else
+                {
+                    pcr[j] = pc1m[l - 28];
+                }
+            }
+
+            for (int j = 28; j < 56; j++)
+            {
+                l = j + totrot[i];
+                if (l < 56 )
+                {
+                    pcr[j] = pc1m[l];
+                }
+                else
+                {
+                    pcr[j] = pc1m[l - 28];
+                }
+            }
+
+            for (int j = 0; j < 24; j++)
+            {
+                if (pcr[pc2[j]])
+                {
+                    newKey[m] |= bigbyte[j];
+                }
+
+                if (pcr[pc2[j + 24]])
+                {
+                    newKey[n] |= bigbyte[j];
+                }
+            }
+        }
+
+        //
+        // store the processed key
+        //
+        for (int i = 0; i != 32; i += 2)
+        {
+            int    i1, i2;
+
+            i1 = newKey[i];
+            i2 = newKey[i + 1];
+
+            newKey[i] = ((i1 & 0x00fc0000) << 6) | ((i1 & 0x00000fc0) << 10)
+                                   | ((i2 & 0x00fc0000) >>> 10) | ((i2 & 0x00000fc0) >>> 6);
+
+            newKey[i + 1] = ((i1 & 0x0003f000) << 12) | ((i1 & 0x0000003f) << 16)
+                                   | ((i2 & 0x0003f000) >>> 4) | (i2 & 0x0000003f);
+        }
+
+        return newKey;
+    }
+
+    /**
+     * the DES engine.
+     */
+    protected void desFunc(
+        int[]   wKey,
+        byte[]  in,
+        int     inOff,
+        byte[]  out,
+        int     outOff)
+    {
+        int     work, right, left;
+
+        left     = (in[inOff + 0] & 0xff) << 24;
+        left    |= (in[inOff + 1] & 0xff) << 16;
+        left    |= (in[inOff + 2] & 0xff) << 8;
+        left    |= (in[inOff + 3] & 0xff);
+
+        right     = (in[inOff + 4] & 0xff) << 24;
+        right    |= (in[inOff + 5] & 0xff) << 16;
+        right    |= (in[inOff + 6] & 0xff) << 8;
+        right    |= (in[inOff + 7] & 0xff);
+
+        work = ((left >>> 4) ^ right) & 0x0f0f0f0f;
+        right ^= work;
+        left ^= (work << 4);
+        work = ((left >>> 16) ^ right) & 0x0000ffff;
+        right ^= work;
+        left ^= (work << 16);
+        work = ((right >>> 2) ^ left) & 0x33333333;
+        left ^= work;
+        right ^= (work << 2);
+        work = ((right >>> 8) ^ left) & 0x00ff00ff;
+        left ^= work;
+        right ^= (work << 8);
+        right = ((right << 1) | ((right >>> 31) & 1)) & 0xffffffff;
+        work = (left ^ right) & 0xaaaaaaaa;
+        left ^= work;
+        right ^= work;
+        left = ((left << 1) | ((left >>> 31) & 1)) & 0xffffffff;
+
+        for (int round = 0; round < 8; round++)
+        {
+            int     fval;
+
+            work  = (right << 28) | (right >>> 4);
+            work ^= wKey[round * 4 + 0];
+            fval  = SP7[ work      & 0x3f];
+            fval |= SP5[(work >>>  8) & 0x3f];
+            fval |= SP3[(work >>> 16) & 0x3f];
+            fval |= SP1[(work >>> 24) & 0x3f];
+            work  = right ^ wKey[round * 4 + 1];
+            fval |= SP8[ work      & 0x3f];
+            fval |= SP6[(work >>>  8) & 0x3f];
+            fval |= SP4[(work >>> 16) & 0x3f];
+            fval |= SP2[(work >>> 24) & 0x3f];
+            left ^= fval;
+            work  = (left << 28) | (left >>> 4);
+            work ^= wKey[round * 4 + 2];
+            fval  = SP7[ work      & 0x3f];
+            fval |= SP5[(work >>>  8) & 0x3f];
+            fval |= SP3[(work >>> 16) & 0x3f];
+            fval |= SP1[(work >>> 24) & 0x3f];
+            work  = left ^ wKey[round * 4 + 3];
+            fval |= SP8[ work      & 0x3f];
+            fval |= SP6[(work >>>  8) & 0x3f];
+            fval |= SP4[(work >>> 16) & 0x3f];
+            fval |= SP2[(work >>> 24) & 0x3f];
+            right ^= fval;
+        }
+
+        right = (right << 31) | (right >>> 1);
+        work = (left ^ right) & 0xaaaaaaaa;
+        left ^= work;
+        right ^= work;
+        left = (left << 31) | (left >>> 1);
+        work = ((left >>> 8) ^ right) & 0x00ff00ff;
+        right ^= work;
+        left ^= (work << 8);
+        work = ((left >>> 2) ^ right) & 0x33333333;
+        right ^= work;
+        left ^= (work << 2);
+        work = ((right >>> 16) ^ left) & 0x0000ffff;
+        left ^= work;
+        right ^= (work << 16);
+        work = ((right >>> 4) ^ left) & 0x0f0f0f0f;
+        left ^= work;
+        right ^= (work << 4);
+
+        out[outOff + 0] = (byte)((right >>> 24) & 0xff);
+        out[outOff + 1] = (byte)((right >>> 16) & 0xff);
+        out[outOff + 2] = (byte)((right >>>  8) & 0xff);
+        out[outOff + 3] = (byte)( right         & 0xff);
+        out[outOff + 4] = (byte)((left >>> 24) & 0xff);
+        out[outOff + 5] = (byte)((left >>> 16) & 0xff);
+        out[outOff + 6] = (byte)((left >>>  8) & 0xff);
+        out[outOff + 7] = (byte)( left         & 0xff);
+    }
+}

Added: directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/DataLengthException.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/DataLengthException.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/DataLengthException.java (added)
+++ directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/DataLengthException.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,49 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.crypto;
+
+/**
+ * this exception is thrown if a buffer that is meant to have output
+ * copied into it turns out to be too short, or if we've been given 
+ * insufficient input. In general this exception will get thrown rather
+ * than an ArrayOutOfBounds exception.
+ */
+public class DataLengthException extends RuntimeCryptoException
+{
+	private static final long serialVersionUID = 7568808319792294601L;
+
+	/**
+     * base constructor.
+     */
+    public DataLengthException()
+    {
+    }
+
+    /**
+     * create a DataLengthException with the given message.
+     *
+     * @param message the message to be carried with the exception.
+     */
+    public DataLengthException(
+        String  message)
+    {
+        super(message);
+    }
+}

Added: directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/Digest.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/Digest.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/Digest.java (added)
+++ directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/Digest.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,70 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.crypto;
+
+/**
+ * interface that a message digest conforms to.
+ */
+public interface Digest
+{
+    /**
+     * return the algorithm name
+     *
+     * @return the algorithm name
+     */
+    public String getAlgorithmName();
+
+    /**
+     * return the size, in bytes, of the digest produced by this message digest.
+     *
+     * @return the size, in bytes, of the digest produced by this message digest.
+     */
+    public int getDigestSize();
+
+    /**
+     * update the message digest with a single byte.
+     *
+     * @param in the input byte to be entered.
+     */
+    public void update(byte in);
+
+    /**
+     * update the message digest with a block of bytes.
+     *
+     * @param in the byte array containing the data.
+     * @param inOff the offset into the byte array where the data starts.
+     * @param len the length of the data.
+     */
+    public void update(byte[] in, int inOff, int len);
+
+    /**
+     * close the digest, producing the final digest value. The doFinal
+     * call leaves the digest reset.
+     *
+     * @param out the array the digest is to be copied into.
+     * @param outOff the offset into the out array the digest is to start at.
+     */
+    public int doFinal(byte[] out, int outOff);
+
+    /**
+     * reset the digest back to it's initial state.
+     */
+    public void reset();
+}

Added: directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/GeneralDigest.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/GeneralDigest.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/GeneralDigest.java (added)
+++ directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/GeneralDigest.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,146 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.crypto;
+
+
+/**
+ * base implementation of MD4 family style digest as outlined in
+ * "Handbook of Applied Cryptography", pages 344 - 347.
+ */
+public abstract class GeneralDigest
+    implements Digest
+{
+    private byte[]  xBuf;
+    private int     xBufOff;
+
+    private long    byteCount;
+
+    /**
+     * Standard constructor
+     */
+    protected GeneralDigest()
+    {
+        xBuf = new byte[4];
+        xBufOff = 0;
+    }
+
+    /**
+     * Copy constructor.  We are using copy constructors in place
+     * of the Object.clone() interface as this interface is not
+     * supported by J2ME.
+     */
+    protected GeneralDigest(GeneralDigest t)
+    {
+        xBuf = new byte[t.xBuf.length];
+        System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length);
+
+        xBufOff = t.xBufOff;
+        byteCount = t.byteCount;
+    }
+
+    public void update(
+        byte in)
+    {
+        xBuf[xBufOff++] = in;
+
+        if (xBufOff == xBuf.length)
+        {
+            processWord(xBuf, 0);
+            xBufOff = 0;
+        }
+
+        byteCount++;
+    }
+
+    public void update(
+        byte[]  in,
+        int     inOff,
+        int     len)
+    {
+        //
+        // fill the current word
+        //
+        while ((xBufOff != 0) && (len > 0))
+        {
+            update(in[inOff]);
+
+            inOff++;
+            len--;
+        }
+
+        //
+        // process whole words.
+        //
+        while (len > xBuf.length)
+        {
+            processWord(in, inOff);
+
+            inOff += xBuf.length;
+            len -= xBuf.length;
+            byteCount += xBuf.length;
+        }
+
+        //
+        // load in the remainder.
+        //
+        while (len > 0)
+        {
+            update(in[inOff]);
+
+            inOff++;
+            len--;
+        }
+    }
+
+    public void finish()
+    {
+        long    bitLength = (byteCount << 3);
+
+        //
+        // add the pad bytes.
+        //
+        update((byte)128);
+
+        while (xBufOff != 0)
+        {
+            update((byte)0);
+        }
+
+        processLength(bitLength);
+
+        processBlock();
+    }
+
+    public void reset()
+    {
+        byteCount = 0;
+
+        xBufOff = 0;
+        for ( int i = 0; i < xBuf.length; i++ ) {
+            xBuf[i] = 0;
+        }
+    }
+
+    protected abstract void processWord(byte[] in, int inOff);
+
+    protected abstract void processLength(long bitLength);
+
+    protected abstract void processBlock();
+}

Added: directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/HMac.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/HMac.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/HMac.java (added)
+++ directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/HMac.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,153 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.crypto;
+
+
+/**
+ * HMAC implementation based on RFC2104
+ *
+ * H(K XOR opad, H(K XOR ipad, text))
+ */
+public class HMac
+implements Mac
+{
+    private final static int BLOCK_LENGTH = 64;
+
+    private final static byte IPAD = (byte)0x36;
+    private final static byte OPAD = (byte)0x5C;
+
+    private Digest digest;
+    private int digestSize;
+    private byte[] inputPad = new byte[BLOCK_LENGTH];
+    private byte[] outputPad = new byte[BLOCK_LENGTH];
+
+    public HMac(
+        Digest digest)
+    {
+        this.digest = digest;
+        digestSize = digest.getDigestSize();
+    }
+
+    public String getAlgorithmName()
+    {
+        StringBuffer buf = new StringBuffer();
+        buf.append( digest.getAlgorithmName() );
+        buf.append( "/HMAC" );
+        return buf.toString();
+    }
+
+    public Digest getUnderlyingDigest()
+    {
+        return digest;
+    }
+
+    public void init(
+        CipherParameters params)
+    {
+        digest.reset();
+
+        byte[] key = ((KeyParameter)params).getKey();
+
+        if (key.length > BLOCK_LENGTH)
+        {
+            digest.update(key, 0, key.length);
+            digest.doFinal(inputPad, 0);
+            for (int i = digestSize; i < inputPad.length; i++)
+            {
+                inputPad[i] = 0;
+            }
+        }
+        else
+        {
+            System.arraycopy(key, 0, inputPad, 0, key.length);
+            for (int i = key.length; i < inputPad.length; i++)
+            {
+                inputPad[i] = 0;
+            }
+        }
+
+        outputPad = new byte[inputPad.length];
+        System.arraycopy(inputPad, 0, outputPad, 0, inputPad.length);
+
+        for (int i = 0; i < inputPad.length; i++)
+        {
+            inputPad[i] ^= IPAD;
+        }
+
+        for (int i = 0; i < outputPad.length; i++)
+        {
+            outputPad[i] ^= OPAD;
+        }
+
+        digest.update(inputPad, 0, inputPad.length);
+    }
+
+    public int getMacSize()
+    {
+        return digestSize;
+    }
+
+    public void update(
+        byte in)
+    {
+        digest.update(in);
+    }
+
+    public void update(
+        byte[] in,
+        int inOff,
+        int len)
+    {
+        digest.update(in, inOff, len);
+    }
+
+    public int doFinal(
+        byte[] out,
+        int outOff)
+    {
+        byte[] tmp = new byte[digestSize];
+        digest.doFinal(tmp, 0);
+
+        digest.update(outputPad, 0, outputPad.length);
+        digest.update(tmp, 0, tmp.length);
+
+        int     len = digest.doFinal(out, outOff);
+
+        reset();
+
+        return len;
+    }
+
+    /**
+     * Reset the mac generator.
+     */
+    public void reset()
+    {
+        /*
+         * reset the underlying digest.
+         */
+        digest.reset();
+
+        /*
+         * reinitialize the digest.
+         */
+        digest.update(inputPad, 0, inputPad.length);
+    }
+}

Added: directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/KeyParameter.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/KeyParameter.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/KeyParameter.java (added)
+++ directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/KeyParameter.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,48 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.crypto;
+
+
+public class KeyParameter
+    implements CipherParameters
+{
+    private byte[]  key;
+
+    public KeyParameter(
+        byte[]  key)
+    {
+        this(key, 0, key.length);
+    }
+
+    public KeyParameter(
+        byte[]  key,
+        int     keyOff,
+        int     keyLen)
+    {
+        this.key = new byte[keyLen];
+
+        System.arraycopy(key, keyOff, this.key, 0, keyLen);
+    }
+
+    public byte[] getKey()
+    {
+        return key;
+    }
+}

Added: directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/Mac.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/Mac.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/Mac.java (added)
+++ directory/trunks/triplesec/crypto/src/main/java/org/safehaus/crypto/Mac.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,90 @@
+/*
+ *  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. 
+ *  
+ */
+package org.safehaus.crypto;
+
+
+/**
+ * The base interface for implementations of message authentication codes (MACs).
+ */
+public interface Mac
+{
+    /**
+     * Initialise the MAC.
+     *
+     * @param params the key and other data required by the MAC.
+     * @exception IllegalArgumentException if the params argument is
+     * inappropriate.
+     */
+    public void init(CipherParameters params)
+        throws IllegalArgumentException;
+
+    /**
+     * Return the name of the algorithm the MAC implements.
+     *
+     * @return the name of the algorithm the MAC implements.
+     */
+    public String getAlgorithmName();
+
+    /**
+     * Return the block size for this cipher (in bytes).
+     *
+     * @return the block size for this cipher in bytes.
+     */
+    public int getMacSize();
+
+    /**
+     * add a single byte to the mac for processing.
+     *
+     * @param in the byte to be processed.
+     * @exception IllegalStateException if the MAC is not initialised.
+     */
+    public void update(byte in)
+        throws IllegalStateException;
+
+    /**
+     * @param in the array containing the input.
+     * @param inOff the index in the array the data begins at.
+     * @param len the length of the input starting at inOff.
+     * @exception IllegalStateException if the MAC is not initialised.
+     * @exception DataLengthException if there isn't enough data in in.
+     */
+    public void update(byte[] in, int inOff, int len)
+        throws DataLengthException, IllegalStateException;
+
+    /**
+     * Compute the final statge of the MAC writing the output to the out
+     * parameter.
+     * <p>
+     * doFinal leaves the MAC in the same state it was after the last init.
+     *
+     * @param out the array the MAC is to be output to.
+     * @param outOff the offset into the out buffer the output is to start at.
+     * @exception org.cainenable.softcard.crypto.DataLengthException if there isn't enough space in out.
+     * @exception IllegalStateException if the MAC is not initialised.
+     */
+    public int doFinal(byte[] out, int outOff)
+        throws DataLengthException, IllegalStateException;
+
+    /**
+     * Reset the MAC. At the end of resetting the MAC should be in the
+     * in the same state it was after the last init (if there was one).
+     */
+    public void reset();
+}



Mime
View raw message