This is an automated email from the ASF dual-hosted git repository. gk pushed a commit to tag FULCRUM_CRYPTO_1_0_6 in repository https://gitbox.apache.org/repos/asf/turbine-fulcrum-crypto.git
commit 3cf47c20d7c4abd18b480315e708ca8d68ce08de Author: Siegfried Goeschl <[email protected]> AuthorDate: Tue Nov 13 23:11:06 2007 +0000 Mhmm, getting rid of the undesired "crypto" folder did not work due to a SVN error message - try it again git-svn-id: https://svn.apache.org/repos/asf/turbine/fulcrum/tags/FULCRUM_CRYPTO_1_0_6@594698 13f79535-47bb-0310-9956-ffa450edef68 --- crypto/.cvsignore | 8 - crypto/maven.xml | 26 -- crypto/project.xml | 56 --- .../org/apache/fulcrum/crypto/CryptoAlgorithm.java | 84 ----- .../org/apache/fulcrum/crypto/CryptoService.java | 50 --- .../fulcrum/crypto/DefaultCryptoService.java | 147 -------- .../fulcrum/crypto/DefaultCryptoService.xconfig | 10 - .../org/apache/fulcrum/crypto/impl/Base64.java | 294 --------------- .../org/apache/fulcrum/crypto/impl/UnixCrypt.java | 410 --------------------- .../java/org/apache/fulcrum/crypto/package.html | 29 -- .../apache/fulcrum/crypto/provider/ClearCrypt.java | 94 ----- .../apache/fulcrum/crypto/provider/JavaCrypt.java | 122 ------ .../fulcrum/crypto/provider/OldJavaCrypt.java | 125 ------- .../apache/fulcrum/crypto/provider/UnixCrypt.java | 108 ------ .../apache/fulcrum/crypto/provider/package.html | 29 -- crypto/src/test/TestComponentConfig.xml | 29 -- crypto/src/test/TestRoleConfig.xml | 26 -- .../apache/fulcrum/crypto/CryptoServiceTest.java | 129 ------- crypto/xdocs/changes.xml | 66 ---- crypto/xdocs/index.xml | 167 --------- crypto/xdocs/navigation.xml | 37 -- 21 files changed, 2046 deletions(-) diff --git a/crypto/.cvsignore b/crypto/.cvsignore deleted file mode 100644 index 57831dc..0000000 --- a/crypto/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -target -maven.log -*.log -*.merlin -*.ser -.classpath -.project -junit*.properties diff --git a/crypto/maven.xml b/crypto/maven.xml deleted file mode 100644 index 8c6e127..0000000 --- a/crypto/maven.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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 default="jar:jar" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:util="jelly:util"> - - <!--preGoal name="java:compile"> - <attainGoal name="avalon:meta"/> - </preGoal--> - -</project> diff --git a/crypto/project.xml b/crypto/project.xml deleted file mode 100644 index d6ad169..0000000 --- a/crypto/project.xml +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0"?> -<!-- - 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> - - <id>fulcrum-crypto</id> - <extend>${basedir}/../project.xml</extend> - <name>Fulcrum Crypto Component</name> - <currentVersion>1.0.6</currentVersion> - <package>org.apache.fulcrum.crypto</package> - <versions> - <version> - <id>1.0.6</id> - <name>1.0.6</name> - <tag>FULCRUM_CRYPTO_1_0_6</tag> - </version> - <version> - <id>1.0.5</id> - <name>1.0.5</name> - <tag>FULCRUM_CRYPTO_1_0_5</tag> - </version> - </versions> - - <dependencies> - <!-- Needed only for testing --> - <dependency> - <groupId>fulcrum</groupId> - <artifactId>fulcrum-testcontainer</artifactId> - <version>1.0.5</version> - </dependency> - <dependency> - <groupId>fulcrum</groupId> - <artifactId>fulcrum-yaafi</artifactId> - <version>1.0.5</version> - </dependency> - </dependencies> - -</project> - diff --git a/crypto/src/java/org/apache/fulcrum/crypto/CryptoAlgorithm.java b/crypto/src/java/org/apache/fulcrum/crypto/CryptoAlgorithm.java deleted file mode 100644 index 0891e28..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/CryptoAlgorithm.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.apache.fulcrum.crypto; - - -/* - * 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. - */ - - -/** - * This interface describes the various Crypto Algorithms that are - * handed out by the Crypto Service. - * - * @author <a href="mailto:[email protected]">Henning P. Schmiedehausen</a> - * @version $Id$ - */ - -public interface CryptoAlgorithm -{ - /** - * Allows the user to set a salt value whenever the - * algorithm is used. Setting a new salt should invalidate - * all internal state of this object. - * <p> - * Algorithms that do not use a salt are allowed to ignore - * this parameter. - * <p> - * Algorithms must be able to deal with the null value as salt. - * They should treat it as "use a random salt". - * - * @param salt The salt value - * - */ - - void setSeed(String salt); - - /** - * Performs the actual encryption. - * - * @param value The value to be encrypted - * - * @return The encrypted value - * - * @throws Exception various errors from the underlying ciphers. - * The caller should catch them and report accordingly. - * - */ - - String encrypt(String value) - throws Exception; - - /** - * Algorithms that perform multiple ciphers get told - * with setCipher, which cipher to use. This should be - * called before any other method call. - * - * If called after any call to encrypt or setSeed, the - * CryptoAlgorithm may choose to ignore this or to reset - * and use the new cipher. - * - * If any other call is used before this, the algorithm - * should use a default cipher and not throw an error. - * - * @param cipher The cipher to use. - * - */ - - void setCipher(String cipher); - -} diff --git a/crypto/src/java/org/apache/fulcrum/crypto/CryptoService.java b/crypto/src/java/org/apache/fulcrum/crypto/CryptoService.java deleted file mode 100644 index 3e79c83..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/CryptoService.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.fulcrum.crypto; - - -/* - * 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 java.security.NoSuchAlgorithmException; - -/** - * An implementation of CryptoService that uses either supplied crypto - * Algorithms (provided in Fulcrum.properties) or tries to get them via - * the normal java mechanisms if this fails. - * - * @author <a href="mailto:[email protected]">Eric Pugh</a> - * @author <a href="mailto:[email protected]">Stephen McConnell</a> - */ -public interface CryptoService -{ - String ROLE = CryptoService.class.getName(); - - /** - * Returns a CryptoAlgorithm Object which represents the requested - * crypto algorithm. - * - * @param algo Name of the requested algorithm - * - * @return An Object representing the algorithm - * - * @throws NoSuchAlgorithmException Requested algorithm is not available - * - */ - public CryptoAlgorithm getCryptoAlgorithm(String algo) throws NoSuchAlgorithmException; -} diff --git a/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.java b/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.java deleted file mode 100644 index 264504e..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.apache.fulcrum.crypto; - -/* - * 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 java.security.NoSuchAlgorithmException; -import java.util.Hashtable; - -import org.apache.avalon.framework.activity.Initializable; -import org.apache.avalon.framework.configuration.Configurable; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.logger.AbstractLogEnabled; -import org.apache.avalon.framework.thread.ThreadSafe; - -/** - * An implementation of CryptoService that uses either supplied crypto - * Algorithms (provided in the component config xml file) or tries to get them via - * the normal java mechanisms if this fails. - * - * @author <a href="mailto:[email protected]">Eric Pugh</a> - * @author <a href="mailto:[email protected]">Henning P. Schmiedehausen</a> - * @version $Id$ - * - * @avalon.component name="crypto" lifestyle="singleton" - * @avalon.service type="org.apache.fulcrum.crypto.CryptoService" - */ -public class DefaultCryptoService - extends AbstractLogEnabled - implements CryptoService, Configurable, Initializable, ThreadSafe -{ - // - // SJM: removed Component and Contextualizable, Startable - // - - /** Key Prefix for our algorithms */ - private static final String ALGORITHM = "algorithm"; - /** Default Key */ - private static final String DEFAULT_KEY = "default"; - /** Default Encryption Class */ - private static final String DEFAULT_CLASS = - "org.apache.fulcrum.crypto.provider.JavaCrypt"; - /** Names of the registered algorithms and the wanted classes */ - private Hashtable algos = null; - - /** - * Returns a CryptoAlgorithm Object which represents the requested - * crypto algorithm. - * - * @param algo Name of the requested algorithm - * - * @return An Object representing the algorithm - * - * @throws NoSuchAlgorithmException Requested algorithm is not available - * - */ - public CryptoAlgorithm getCryptoAlgorithm( String algo ) - throws NoSuchAlgorithmException - { - String cryptoClass = (String) algos.get(algo); - CryptoAlgorithm ca = null; - if (cryptoClass == null) - { - cryptoClass = (String) algos.get(DEFAULT_KEY); - } - if (cryptoClass == null || cryptoClass.equalsIgnoreCase("none")) - { - throw new NoSuchAlgorithmException( - "TurbineCryptoService: No Algorithm for " + algo + " found"); - } - try - { - //@todo should be created via factory service. - //Just trying to get something to work. - //ca = (CryptoAlgorithm) factoryService.getInstance(cryptoClass); - ca = (CryptoAlgorithm) Class.forName(cryptoClass).newInstance(); - } - catch (Exception e) - { - throw new NoSuchAlgorithmException( - "TurbineCryptoService: Error instantiating " - + cryptoClass + " for " + algo); - } - ca.setCipher(algo); - return ca; - } - - // ---------------- Avalon Lifecycle Methods --------------------- - - /** - * Avalon component lifecycle method - */ - public void configure(Configuration conf) throws ConfigurationException - { - this.algos = new Hashtable(); - // Set up default (Can be overridden by default key - // from the properties - algos.put(DEFAULT_KEY, DEFAULT_CLASS); - final Configuration algorithms = conf.getChild(ALGORITHM, false); - if (algorithms != null) - { - Configuration[] nameVal = algorithms.getChildren(); - for (int i = 0; i < nameVal.length; i++) - { - String key = nameVal[i].getName(); - String val = nameVal[i].getValue(); - // getLogger.debug("Registered " + val - // + " for Crypto Algorithm " + key); - algos.put(key, val); - } - } - } - - /** - * @see org.apache.avalon.framework.activity.Initializable#initialize() - */ - public void initialize() - throws Exception - { - getLogger().debug("initialize()"); - } - - /** - * Avalon component lifecycle method - */ - public void dispose() - { - algos = null; - } - -} diff --git a/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.xconfig b/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.xconfig deleted file mode 100644 index e851d1b..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.xconfig +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> - -<configuration> - <algorithm> - <unix>org.apache.fulcrum.crypto.provider.UnixCrypt</unix> - <clear>org.apache.fulcrum.crypto.provider.ClearCrypt</clear> - <java>org.apache.fulcrum.crypto.provider.JavaCrypt</java> - <oldjava>org.apache.fulcrum.crypto.provider.OldJavaCrypt</oldjava> - </algorithm> -</configuration> diff --git a/crypto/src/java/org/apache/fulcrum/crypto/impl/Base64.java b/crypto/src/java/org/apache/fulcrum/crypto/impl/Base64.java deleted file mode 100644 index 9606d29..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/impl/Base64.java +++ /dev/null @@ -1,294 +0,0 @@ -package org.apache.fulcrum.crypto.impl; - -/* - * 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. - */ - -/** - * Base64 encoder/decoder taken from commons-codec. Copying - * and wasting the code allows to minimize the dependencies. - * - * @author Siegfried Goeschl - */ -public class Base64 -{ - - public Base64() { - } - - private static boolean isBase64(byte octect) { - if(octect == 61) - return true; - return base64Alphabet[octect] != -1; - } - - public static boolean isArrayByteBase64(byte arrayOctect[]) { - arrayOctect = discardWhitespace(arrayOctect); - int length = arrayOctect.length; - if(length == 0) - return true; - for(int i = 0; i < length; i++) - if(!isBase64(arrayOctect[i])) - return false; - - return true; - } - - public static byte[] encodeBase64(byte binaryData[]) { - return encodeBase64(binaryData, false); - } - - public static byte[] encodeBase64Chunked(byte binaryData[]) { - return encodeBase64(binaryData, true); - } - - public Object decode(Object pObject) - throws Exception { - if(!(pObject instanceof byte[])) - throw new Exception("Parameter supplied to Base64 decode is not a byte[]"); - else - return decode((byte[])pObject); - } - - public byte[] decode(byte pArray[]) { - return decodeBase64(pArray); - } - - public static byte[] encodeBase64(byte binaryData[], boolean isChunked) { - int lengthDataBits = binaryData.length * 8; - int fewerThan24bits = lengthDataBits % 24; - int numberTriplets = lengthDataBits / 24; - byte encodedData[] = null; - int encodedDataLength = 0; - int nbrChunks = 0; - if(fewerThan24bits != 0) - encodedDataLength = (numberTriplets + 1) * 4; - else - encodedDataLength = numberTriplets * 4; - if(isChunked) { - nbrChunks = CHUNK_SEPARATOR.length != 0 ? (int)Math.ceil((float)encodedDataLength / 76F) : 0; - encodedDataLength += nbrChunks * CHUNK_SEPARATOR.length; - } - encodedData = new byte[encodedDataLength]; - byte k = 0; - byte l = 0; - byte b1 = 0; - byte b2 = 0; - byte b3 = 0; - int encodedIndex = 0; - int dataIndex = 0; - int i = 0; - int nextSeparatorIndex = 76; - int chunksSoFar = 0; - for(i = 0; i < numberTriplets; i++) { - dataIndex = i * 3; - b1 = binaryData[dataIndex]; - b2 = binaryData[dataIndex + 1]; - b3 = binaryData[dataIndex + 2]; - l = (byte)(b2 & 0xf); - k = (byte)(b1 & 3); - byte val1 = (b1 & 0xffffff80) != 0 ? (byte)(b1 >> 2 ^ 0xc0) : (byte)(b1 >> 2); - byte val2 = (b2 & 0xffffff80) != 0 ? (byte)(b2 >> 4 ^ 0xf0) : (byte)(b2 >> 4); - byte val3 = (b3 & 0xffffff80) != 0 ? (byte)(b3 >> 6 ^ 0xfc) : (byte)(b3 >> 6); - encodedData[encodedIndex] = lookUpBase64Alphabet[val1]; - encodedData[encodedIndex + 1] = lookUpBase64Alphabet[val2 | k << 4]; - encodedData[encodedIndex + 2] = lookUpBase64Alphabet[l << 2 | val3]; - encodedData[encodedIndex + 3] = lookUpBase64Alphabet[b3 & 0x3f]; - encodedIndex += 4; - if(isChunked && encodedIndex == nextSeparatorIndex) { - System.arraycopy(CHUNK_SEPARATOR, 0, encodedData, encodedIndex, CHUNK_SEPARATOR.length); - chunksSoFar++; - nextSeparatorIndex = 76 * (chunksSoFar + 1) + chunksSoFar * CHUNK_SEPARATOR.length; - encodedIndex += CHUNK_SEPARATOR.length; - } - } - - dataIndex = i * 3; - if(fewerThan24bits == 8) { - b1 = binaryData[dataIndex]; - k = (byte)(b1 & 3); - byte val1 = (b1 & 0xffffff80) != 0 ? (byte)(b1 >> 2 ^ 0xc0) : (byte)(b1 >> 2); - encodedData[encodedIndex] = lookUpBase64Alphabet[val1]; - encodedData[encodedIndex + 1] = lookUpBase64Alphabet[k << 4]; - encodedData[encodedIndex + 2] = 61; - encodedData[encodedIndex + 3] = 61; - } else - if(fewerThan24bits == 16) { - b1 = binaryData[dataIndex]; - b2 = binaryData[dataIndex + 1]; - l = (byte)(b2 & 0xf); - k = (byte)(b1 & 3); - byte val1 = (b1 & 0xffffff80) != 0 ? (byte)(b1 >> 2 ^ 0xc0) : (byte)(b1 >> 2); - byte val2 = (b2 & 0xffffff80) != 0 ? (byte)(b2 >> 4 ^ 0xf0) : (byte)(b2 >> 4); - encodedData[encodedIndex] = lookUpBase64Alphabet[val1]; - encodedData[encodedIndex + 1] = lookUpBase64Alphabet[val2 | k << 4]; - encodedData[encodedIndex + 2] = lookUpBase64Alphabet[l << 2]; - encodedData[encodedIndex + 3] = 61; - } - if(isChunked && chunksSoFar < nbrChunks) - System.arraycopy(CHUNK_SEPARATOR, 0, encodedData, encodedDataLength - CHUNK_SEPARATOR.length, CHUNK_SEPARATOR.length); - return encodedData; - } - - public static byte[] decodeBase64(byte base64Data[]) { - base64Data = discardNonBase64(base64Data); - if(base64Data.length == 0) - return new byte[0]; - int numberQuadruple = base64Data.length / 4; - byte decodedData[] = null; - byte b1 = 0; - byte b2 = 0; - byte b3 = 0; - byte b4 = 0; - byte marker0 = 0; - byte marker1 = 0; - int encodedIndex = 0; - int dataIndex = 0; - int lastData; - for(lastData = base64Data.length; base64Data[lastData - 1] == 61;) - if(--lastData == 0) - return new byte[0]; - - decodedData = new byte[lastData - numberQuadruple]; - for(int i = 0; i < numberQuadruple; i++) { - dataIndex = i * 4; - marker0 = base64Data[dataIndex + 2]; - marker1 = base64Data[dataIndex + 3]; - b1 = base64Alphabet[base64Data[dataIndex]]; - b2 = base64Alphabet[base64Data[dataIndex + 1]]; - if(marker0 != 61 && marker1 != 61) { - b3 = base64Alphabet[marker0]; - b4 = base64Alphabet[marker1]; - decodedData[encodedIndex] = (byte)(b1 << 2 | b2 >> 4); - decodedData[encodedIndex + 1] = (byte)((b2 & 0xf) << 4 | b3 >> 2 & 0xf); - decodedData[encodedIndex + 2] = (byte)(b3 << 6 | b4); - } else - if(marker0 == 61) - decodedData[encodedIndex] = (byte)(b1 << 2 | b2 >> 4); - else - if(marker1 == 61) { - b3 = base64Alphabet[marker0]; - decodedData[encodedIndex] = (byte)(b1 << 2 | b2 >> 4); - decodedData[encodedIndex + 1] = (byte)((b2 & 0xf) << 4 | b3 >> 2 & 0xf); - } - encodedIndex += 3; - } - - return decodedData; - } - - static byte[] discardWhitespace(byte data[]) { - byte groomedData[] = new byte[data.length]; - int bytesCopied = 0; - int i = 0; - do - if(i < data.length) { - switch(data[i]) { - default: - groomedData[bytesCopied++] = data[i]; - // fall through - - case 9: // '\t' - case 10: // '\n' - case 13: // '\r' - case 32: // ' ' - i++; - break; - } - } else { - byte packedData[] = new byte[bytesCopied]; - System.arraycopy(groomedData, 0, packedData, 0, bytesCopied); - return packedData; - } - while(true); - } - - static byte[] discardNonBase64(byte data[]) { - byte groomedData[] = new byte[data.length]; - int bytesCopied = 0; - for(int i = 0; i < data.length; i++) - if(isBase64(data[i])) - groomedData[bytesCopied++] = data[i]; - - byte packedData[] = new byte[bytesCopied]; - System.arraycopy(groomedData, 0, packedData, 0, bytesCopied); - return packedData; - } - - public Object encode(Object pObject) - throws Exception { - if(!(pObject instanceof byte[])) - throw new Exception("Parameter supplied to Base64 encode is not a byte[]"); - else - return encode((byte[])pObject); - } - - public byte[] encode(byte pArray[]) { - return encodeBase64(pArray, false); - } - - static final int CHUNK_SIZE = 76; - static final byte CHUNK_SEPARATOR[] = "\r\n".getBytes(); - static final int BASELENGTH = 255; - static final int LOOKUPLENGTH = 64; - static final int EIGHTBIT = 8; - static final int SIXTEENBIT = 16; - static final int TWENTYFOURBITGROUP = 24; - static final int FOURBYTE = 4; - static final int SIGN = -128; - static final byte PAD = 61; - private static byte base64Alphabet[]; - private static byte lookUpBase64Alphabet[]; - - static { - base64Alphabet = new byte[255]; - lookUpBase64Alphabet = new byte[64]; - int i; - for(i = 0; i < 255; i++) - base64Alphabet[i] = -1; - - for(i = 90; i >= 65; i--) - base64Alphabet[i] = (byte)(i - 65); - - for(i = 122; i >= 97; i--) - base64Alphabet[i] = (byte)((i - 97) + 26); - - for(i = 57; i >= 48; i--) - base64Alphabet[i] = (byte)((i - 48) + 52); - - base64Alphabet[43] = 62; - base64Alphabet[47] = 63; - for(i = 0; i <= 25; i++) - lookUpBase64Alphabet[i] = (byte)(65 + i); - - i = 26; - for(int j = 0; i <= 51; j++) { - lookUpBase64Alphabet[i] = (byte)(97 + j); - i++; - } - - i = 52; - for(int j = 0; i <= 61; j++) { - lookUpBase64Alphabet[i] = (byte)(48 + j); - i++; - } - - lookUpBase64Alphabet[62] = 43; - lookUpBase64Alphabet[63] = 47; - } -} diff --git a/crypto/src/java/org/apache/fulcrum/crypto/impl/UnixCrypt.java b/crypto/src/java/org/apache/fulcrum/crypto/impl/UnixCrypt.java deleted file mode 100644 index 784af75..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/impl/UnixCrypt.java +++ /dev/null @@ -1,410 +0,0 @@ -package org.apache.fulcrum.crypto.impl; - -/* - * 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 java.util.Random; - -/** - * Unix crypt (3) algorithm implementation. The java - * implementation was taken from the JetSpeed Portal project - * (see org.apache.jetspeed.services.security.ldap.UnixCrypt). - * - * @author Siegfried Goeschl - */ -public class UnixCrypt -{ - private static final char saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./".toCharArray(); - private static final int ITERATIONS = 16; - private static final int con_salt[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 0, 0, 0, 0, 0 - }; - private static final boolean shifts2[] = { - false, false, true, true, true, true, true, true, false, true, - true, true, true, true, true, false - }; - private static final int skb[][] = { - { - 0, 16, 0x20000000, 0x20000010, 0x10000, 0x10010, 0x20010000, 0x20010010, 2048, 2064, - 0x20000800, 0x20000810, 0x10800, 0x10810, 0x20010800, 0x20010810, 32, 48, 0x20000020, 0x20000030, - 0x10020, 0x10030, 0x20010020, 0x20010030, 2080, 2096, 0x20000820, 0x20000830, 0x10820, 0x10830, - 0x20010820, 0x20010830, 0x80000, 0x80010, 0x20080000, 0x20080010, 0x90000, 0x90010, 0x20090000, 0x20090010, - 0x80800, 0x80810, 0x20080800, 0x20080810, 0x90800, 0x90810, 0x20090800, 0x20090810, 0x80020, 0x80030, - 0x20080020, 0x20080030, 0x90020, 0x90030, 0x20090020, 0x20090030, 0x80820, 0x80830, 0x20080820, 0x20080830, - 0x90820, 0x90830, 0x20090820, 0x20090830 - }, { - 0, 0x2000000, 8192, 0x2002000, 0x200000, 0x2200000, 0x202000, 0x2202000, 4, 0x2000004, - 8196, 0x2002004, 0x200004, 0x2200004, 0x202004, 0x2202004, 1024, 0x2000400, 9216, 0x2002400, - 0x200400, 0x2200400, 0x202400, 0x2202400, 1028, 0x2000404, 9220, 0x2002404, 0x200404, 0x2200404, - 0x202404, 0x2202404, 0x10000000, 0x12000000, 0x10002000, 0x12002000, 0x10200000, 0x12200000, 0x10202000, 0x12202000, - 0x10000004, 0x12000004, 0x10002004, 0x12002004, 0x10200004, 0x12200004, 0x10202004, 0x12202004, 0x10000400, 0x12000400, - 0x10002400, 0x12002400, 0x10200400, 0x12200400, 0x10202400, 0x12202400, 0x10000404, 0x12000404, 0x10002404, 0x12002404, - 0x10200404, 0x12200404, 0x10202404, 0x12202404 - }, { - 0, 1, 0x40000, 0x40001, 0x1000000, 0x1000001, 0x1040000, 0x1040001, 2, 3, - 0x40002, 0x40003, 0x1000002, 0x1000003, 0x1040002, 0x1040003, 512, 513, 0x40200, 0x40201, - 0x1000200, 0x1000201, 0x1040200, 0x1040201, 514, 515, 0x40202, 0x40203, 0x1000202, 0x1000203, - 0x1040202, 0x1040203, 0x8000000, 0x8000001, 0x8040000, 0x8040001, 0x9000000, 0x9000001, 0x9040000, 0x9040001, - 0x8000002, 0x8000003, 0x8040002, 0x8040003, 0x9000002, 0x9000003, 0x9040002, 0x9040003, 0x8000200, 0x8000201, - 0x8040200, 0x8040201, 0x9000200, 0x9000201, 0x9040200, 0x9040201, 0x8000202, 0x8000203, 0x8040202, 0x8040203, - 0x9000202, 0x9000203, 0x9040202, 0x9040203 - }, { - 0, 0x100000, 256, 0x100100, 8, 0x100008, 264, 0x100108, 4096, 0x101000, - 4352, 0x101100, 4104, 0x101008, 4360, 0x101108, 0x4000000, 0x4100000, 0x4000100, 0x4100100, - 0x4000008, 0x4100008, 0x4000108, 0x4100108, 0x4001000, 0x4101000, 0x4001100, 0x4101100, 0x4001008, 0x4101008, - 0x4001108, 0x4101108, 0x20000, 0x120000, 0x20100, 0x120100, 0x20008, 0x120008, 0x20108, 0x120108, - 0x21000, 0x121000, 0x21100, 0x121100, 0x21008, 0x121008, 0x21108, 0x121108, 0x4020000, 0x4120000, - 0x4020100, 0x4120100, 0x4020008, 0x4120008, 0x4020108, 0x4120108, 0x4021000, 0x4121000, 0x4021100, 0x4121100, - 0x4021008, 0x4121008, 0x4021108, 0x4121108 - }, { - 0, 0x10000000, 0x10000, 0x10010000, 4, 0x10000004, 0x10004, 0x10010004, 0x20000000, 0x30000000, - 0x20010000, 0x30010000, 0x20000004, 0x30000004, 0x20010004, 0x30010004, 0x100000, 0x10100000, 0x110000, 0x10110000, - 0x100004, 0x10100004, 0x110004, 0x10110004, 0x20100000, 0x30100000, 0x20110000, 0x30110000, 0x20100004, 0x30100004, - 0x20110004, 0x30110004, 4096, 0x10001000, 0x11000, 0x10011000, 4100, 0x10001004, 0x11004, 0x10011004, - 0x20001000, 0x30001000, 0x20011000, 0x30011000, 0x20001004, 0x30001004, 0x20011004, 0x30011004, 0x101000, 0x10101000, - 0x111000, 0x10111000, 0x101004, 0x10101004, 0x111004, 0x10111004, 0x20101000, 0x30101000, 0x20111000, 0x30111000, - 0x20101004, 0x30101004, 0x20111004, 0x30111004 - }, { - 0, 0x8000000, 8, 0x8000008, 1024, 0x8000400, 1032, 0x8000408, 0x20000, 0x8020000, - 0x20008, 0x8020008, 0x20400, 0x8020400, 0x20408, 0x8020408, 1, 0x8000001, 9, 0x8000009, - 1025, 0x8000401, 1033, 0x8000409, 0x20001, 0x8020001, 0x20009, 0x8020009, 0x20401, 0x8020401, - 0x20409, 0x8020409, 0x2000000, 0xa000000, 0x2000008, 0xa000008, 0x2000400, 0xa000400, 0x2000408, 0xa000408, - 0x2020000, 0xa020000, 0x2020008, 0xa020008, 0x2020400, 0xa020400, 0x2020408, 0xa020408, 0x2000001, 0xa000001, - 0x2000009, 0xa000009, 0x2000401, 0xa000401, 0x2000409, 0xa000409, 0x2020001, 0xa020001, 0x2020009, 0xa020009, - 0x2020401, 0xa020401, 0x2020409, 0xa020409 - }, { - 0, 256, 0x80000, 0x80100, 0x1000000, 0x1000100, 0x1080000, 0x1080100, 16, 272, - 0x80010, 0x80110, 0x1000010, 0x1000110, 0x1080010, 0x1080110, 0x200000, 0x200100, 0x280000, 0x280100, - 0x1200000, 0x1200100, 0x1280000, 0x1280100, 0x200010, 0x200110, 0x280010, 0x280110, 0x1200010, 0x1200110, - 0x1280010, 0x1280110, 512, 768, 0x80200, 0x80300, 0x1000200, 0x1000300, 0x1080200, 0x1080300, - 528, 784, 0x80210, 0x80310, 0x1000210, 0x1000310, 0x1080210, 0x1080310, 0x200200, 0x200300, - 0x280200, 0x280300, 0x1200200, 0x1200300, 0x1280200, 0x1280300, 0x200210, 0x200310, 0x280210, 0x280310, - 0x1200210, 0x1200310, 0x1280210, 0x1280310 - }, { - 0, 0x4000000, 0x40000, 0x4040000, 2, 0x4000002, 0x40002, 0x4040002, 8192, 0x4002000, - 0x42000, 0x4042000, 8194, 0x4002002, 0x42002, 0x4042002, 32, 0x4000020, 0x40020, 0x4040020, - 34, 0x4000022, 0x40022, 0x4040022, 8224, 0x4002020, 0x42020, 0x4042020, 8226, 0x4002022, - 0x42022, 0x4042022, 2048, 0x4000800, 0x40800, 0x4040800, 2050, 0x4000802, 0x40802, 0x4040802, - 10240, 0x4002800, 0x42800, 0x4042800, 10242, 0x4002802, 0x42802, 0x4042802, 2080, 0x4000820, - 0x40820, 0x4040820, 2082, 0x4000822, 0x40822, 0x4040822, 10272, 0x4002820, 0x42820, 0x4042820, - 10274, 0x4002822, 0x42822, 0x4042822 - } - }; - private static final int SPtrans[][] = { - { - 0x820200, 0x20000, 0x80800000, 0x80820200, 0x800000, 0x80020200, 0x80020000, 0x80800000, 0x80020200, 0x820200, - 0x820000, 0x80000200, 0x80800200, 0x800000, 0, 0x80020000, 0x20000, 0x80000000, 0x800200, 0x20200, - 0x80820200, 0x820000, 0x80000200, 0x800200, 0x80000000, 512, 0x20200, 0x80820000, 512, 0x80800200, - 0x80820000, 0, 0, 0x80820200, 0x800200, 0x80020000, 0x820200, 0x20000, 0x80000200, 0x800200, - 0x80820000, 512, 0x20200, 0x80800000, 0x80020200, 0x80000000, 0x80800000, 0x820000, 0x80820200, 0x20200, - 0x820000, 0x80800200, 0x800000, 0x80000200, 0x80020000, 0, 0x20000, 0x800000, 0x80800200, 0x820200, - 0x80000000, 0x80820000, 512, 0x80020200 - }, { - 0x10042004, 0, 0x42000, 0x10040000, 0x10000004, 8196, 0x10002000, 0x42000, 8192, 0x10040004, - 4, 0x10002000, 0x40004, 0x10042000, 0x10040000, 4, 0x40000, 0x10002004, 0x10040004, 8192, - 0x42004, 0x10000000, 0, 0x40004, 0x10002004, 0x42004, 0x10042000, 0x10000004, 0x10000000, 0x40000, - 8196, 0x10042004, 0x40004, 0x10042000, 0x10002000, 0x42004, 0x10042004, 0x40004, 0x10000004, 0, - 0x10000000, 8196, 0x40000, 0x10040004, 8192, 0x10000000, 0x42004, 0x10002004, 0x10042000, 8192, - 0, 0x10000004, 4, 0x10042004, 0x42000, 0x10040000, 0x10040004, 0x40000, 8196, 0x10002000, - 0x10002004, 4, 0x10040000, 0x42000 - }, { - 0x41000000, 0x1010040, 64, 0x41000040, 0x40010000, 0x1000000, 0x41000040, 0x10040, 0x1000040, 0x10000, - 0x1010000, 0x40000000, 0x41010040, 0x40000040, 0x40000000, 0x41010000, 0, 0x40010000, 0x1010040, 64, - 0x40000040, 0x41010040, 0x10000, 0x41000000, 0x41010000, 0x1000040, 0x40010040, 0x1010000, 0x10040, 0, - 0x1000000, 0x40010040, 0x1010040, 64, 0x40000000, 0x10000, 0x40000040, 0x40010000, 0x1010000, 0x41000040, - 0, 0x1010040, 0x10040, 0x41010000, 0x40010000, 0x1000000, 0x41010040, 0x40000000, 0x40010040, 0x41000000, - 0x1000000, 0x41010040, 0x10000, 0x1000040, 0x41000040, 0x10040, 0x1000040, 0, 0x41010000, 0x40000040, - 0x41000000, 0x40010040, 64, 0x1010000 - }, { - 0x100402, 0x4000400, 2, 0x4100402, 0, 0x4100000, 0x4000402, 0x100002, 0x4100400, 0x4000002, - 0x4000000, 1026, 0x4000002, 0x100402, 0x100000, 0x4000000, 0x4100002, 0x100400, 1024, 2, - 0x100400, 0x4000402, 0x4100000, 1024, 1026, 0, 0x100002, 0x4100400, 0x4000400, 0x4100002, - 0x4100402, 0x100000, 0x4100002, 1026, 0x100000, 0x4000002, 0x100400, 0x4000400, 2, 0x4100000, - 0x4000402, 0, 1024, 0x100002, 0, 0x4100002, 0x4100400, 1024, 0x4000000, 0x4100402, - 0x100402, 0x100000, 0x4100402, 2, 0x4000400, 0x100402, 0x100002, 0x100400, 0x4100000, 0x4000402, - 1026, 0x4000000, 0x4000002, 0x4100400 - }, { - 0x2000000, 16384, 256, 0x2004108, 0x2004008, 0x2000100, 16648, 0x2004000, 16384, 8, - 0x2000008, 16640, 0x2000108, 0x2004008, 0x2004100, 0, 16640, 0x2000000, 16392, 264, - 0x2000100, 16648, 0, 0x2000008, 8, 0x2000108, 0x2004108, 16392, 0x2004000, 256, - 264, 0x2004100, 0x2004100, 0x2000108, 16392, 0x2004000, 16384, 8, 0x2000008, 0x2000100, - 0x2000000, 16640, 0x2004108, 0, 16648, 0x2000000, 256, 16392, 0x2000108, 256, - 0, 0x2004108, 0x2004008, 0x2004100, 264, 16384, 16640, 0x2004008, 0x2000100, 264, - 8, 16648, 0x2004000, 0x2000008 - }, { - 0x20000010, 0x80010, 0, 0x20080800, 0x80010, 2048, 0x20000810, 0x80000, 2064, 0x20080810, - 0x80800, 0x20000000, 0x20000800, 0x20000010, 0x20080000, 0x80810, 0x80000, 0x20000810, 0x20080010, 0, - 2048, 16, 0x20080800, 0x20080010, 0x20080810, 0x20080000, 0x20000000, 2064, 16, 0x80800, - 0x80810, 0x20000800, 2064, 0x20000000, 0x20000800, 0x80810, 0x20080800, 0x80010, 0, 0x20000800, - 0x20000000, 2048, 0x20080010, 0x80000, 0x80010, 0x20080810, 0x80800, 16, 0x20080810, 0x80800, - 0x80000, 0x20000810, 0x20000010, 0x20080000, 0x80810, 0, 2048, 0x20000010, 0x20000810, 0x20080800, - 0x20080000, 2064, 16, 0x20080010 - }, { - 4096, 128, 0x400080, 0x400001, 0x401081, 4097, 4224, 0, 0x400000, 0x400081, - 129, 0x401000, 1, 0x401080, 0x401000, 129, 0x400081, 4096, 4097, 0x401081, - 0, 0x400080, 0x400001, 4224, 0x401001, 4225, 0x401080, 1, 4225, 0x401001, - 128, 0x400000, 4225, 0x401000, 0x401001, 129, 4096, 128, 0x400000, 0x401001, - 0x400081, 4225, 4224, 0, 128, 0x400001, 1, 0x400080, 0, 0x400081, - 0x400080, 4224, 129, 4096, 0x401081, 0x400000, 0x401080, 1, 4097, 0x401081, - 0x400001, 0x401080, 0x401000, 4097 - }, { - 0x8200020, 0x8208000, 32800, 0, 0x8008000, 0x200020, 0x8200000, 0x8208020, 32, 0x8000000, - 0x208000, 32800, 0x208020, 0x8008020, 0x8000020, 0x8200000, 32768, 0x208020, 0x200020, 0x8008000, - 0x8208020, 0x8000020, 0, 0x208000, 0x8000000, 0x200000, 0x8008020, 0x8200020, 0x200000, 32768, - 0x8208000, 32, 0x200000, 32768, 0x8000020, 0x8208020, 32800, 0x8000000, 0, 0x208000, - 0x8200020, 0x8008020, 0x8008000, 0x200020, 0x8208000, 32, 0x200020, 0x8008000, 0x8208020, 0x200000, - 0x8200000, 0x8000020, 0x208000, 32800, 0x8008020, 0x8200000, 32, 0x8208000, 0x208020, 0, - 0x8000000, 0x8200020, 32768, 0x208020 - } - }; - private static final int cov_2char[] = { - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, - 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, - 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, - 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, - 119, 120, 121, 122 - }; - - private UnixCrypt() {} - - private static final int D_ENCRYPT(int L, int R, int S, int E0, int E1, int s[]) - { - int v = R ^ R >>> 16; - int u = v & E0; - v &= E1; - u = u ^ u << 16 ^ R ^ s[S]; - int t = v ^ v << 16 ^ R ^ s[S + 1]; - t = t >>> 4 | t << 28; - L ^= SPtrans[1][t & 0x3f] | SPtrans[3][t >>> 8 & 0x3f] | SPtrans[5][t >>> 16 & 0x3f] | SPtrans[7][t >>> 24 & 0x3f] | SPtrans[0][u & 0x3f] | SPtrans[2][u >>> 8 & 0x3f] | SPtrans[4][u >>> 16 & 0x3f] | SPtrans[6][u >>> 24 & 0x3f]; - return L; - } - - private static final int HPERM_OP(int a, int n, int m) - { - int t = (a << 16 - n ^ a) & m; - a = a ^ t ^ t >>> 16 - n; - return a; - } - - private static final void PERM_OP(int a, int b, int n, int m, int results[]) - { - int t = (a >>> n ^ b) & m; - a ^= t << n; - b ^= t; - results[0] = a; - results[1] = b; - } - - private static final int[] body(int schedule[], int Eswap0, int Eswap1) - { - int left = 0; - int right = 0; - int t = 0; - for(int j = 0; j < 25; j++) - { - for(int i = 0; i < 32; i += 4) - { - left = D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule); - right = D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule); - } - - t = left; - left = right; - right = t; - } - - t = right; - right = left >>> 1 | left << 31; - left = t >>> 1 | t << 31; - left &= 0xffffffff; - right &= 0xffffffff; - int results[] = new int[2]; - PERM_OP(right, left, 1, 0x55555555, results); - right = results[0]; - left = results[1]; - PERM_OP(left, right, 8, 0xff00ff, results); - left = results[0]; - right = results[1]; - PERM_OP(right, left, 2, 0x33333333, results); - right = results[0]; - left = results[1]; - PERM_OP(left, right, 16, 65535, results); - left = results[0]; - right = results[1]; - PERM_OP(right, left, 4, 0xf0f0f0f, results); - right = results[0]; - left = results[1]; - int out[] = new int[2]; - out[0] = left; - out[1] = right; - return out; - } - - private static final int byteToUnsigned(byte b) - { - int value = b; - return value < 0 ? value + 256 : value; - } - - public static final String crypt(String original) - { - Random randomGenerator = new Random(); - int numSaltChars = saltChars.length; - String salt = "" + saltChars[Math.abs(randomGenerator.nextInt()) % numSaltChars] + saltChars[Math.abs(randomGenerator.nextInt()) % numSaltChars]; - return crypt(salt, original); - } - - public static final String crypt(String salt, String original) - { - for(; salt.length() < 2; salt = salt + "A"); - StringBuffer buffer = new StringBuffer(" "); - char charZero = salt.charAt(0); - char charOne = salt.charAt(1); - buffer.setCharAt(0, charZero); - buffer.setCharAt(1, charOne); - int Eswap0 = con_salt[charZero]; - int Eswap1 = con_salt[charOne] << 4; - byte key[] = new byte[8]; - for(int i = 0; i < key.length; i++) - key[i] = 0; - - for(int i = 0; i < key.length && i < original.length(); i++) - { - int iChar = original.charAt(i); - key[i] = (byte)(iChar << 1); - } - - int schedule[] = des_set_key(key); - int out[] = body(schedule, Eswap0, Eswap1); - byte b[] = new byte[9]; - intToFourBytes(out[0], b, 0); - intToFourBytes(out[1], b, 4); - b[8] = 0; - int i = 2; - int y = 0; - int u = 128; - for(; i < 13; i++) - { - int j = 0; - int c = 0; - for(; j < 6; j++) - { - c <<= 1; - if((b[y] & u) != 0) - c |= 0x1; - u >>>= 1; - if(u == 0) - { - y++; - u = 128; - } - buffer.setCharAt(i, (char) cov_2char[c]); - } - - } - - return buffer.toString(); - } - - private static int[] des_set_key(byte key[]) - { - int schedule[] = new int[32]; - int c = fourBytesToInt(key, 0); - int d = fourBytesToInt(key, 4); - int results[] = new int[2]; - PERM_OP(d, c, 4, 0xf0f0f0f, results); - d = results[0]; - c = results[1]; - c = HPERM_OP(c, -2, 0xcccc0000); - d = HPERM_OP(d, -2, 0xcccc0000); - PERM_OP(d, c, 1, 0x55555555, results); - d = results[0]; - c = results[1]; - PERM_OP(c, d, 8, 0xff00ff, results); - c = results[0]; - d = results[1]; - PERM_OP(d, c, 1, 0x55555555, results); - d = results[0]; - c = results[1]; - d = (d & 0xff) << 16 | d & 0xff00 | (d & 0xff0000) >>> 16 | (c & 0xf0000000) >>> 4; - c &= 0xfffffff; - int j = 0; - for(int i = 0; i < 16; i++) - { - if(shifts2[i]) - { - c = c >>> 2 | c << 26; - d = d >>> 2 | d << 26; - } else - { - c = c >>> 1 | c << 27; - d = d >>> 1 | d << 27; - } - c &= 0xfffffff; - d &= 0xfffffff; - int s = skb[0][c & 0x3f] | skb[1][c >>> 6 & 0x3 | c >>> 7 & 0x3c] | skb[2][c >>> 13 & 0xf | c >>> 14 & 0x30] | skb[3][c >>> 20 & 0x1 | c >>> 21 & 0x6 | c >>> 22 & 0x38]; - int t = skb[4][d & 0x3f] | skb[5][d >>> 7 & 0x3 | d >>> 8 & 0x3c] | skb[6][d >>> 15 & 0x3f] | skb[7][d >>> 21 & 0xf | d >>> 22 & 0x30]; - schedule[j++] = (t << 16 | s & 0xffff) & 0xffffffff; - s = s >>> 16 | t & 0xffff0000; - s = s << 4 | s >>> 28; - schedule[j++] = s & 0xffffffff; - } - - return schedule; - } - - private static int fourBytesToInt(byte b[], int offset) - { - int value = byteToUnsigned(b[offset++]); - value |= byteToUnsigned(b[offset++]) << 8; - value |= byteToUnsigned(b[offset++]) << 16; - value |= byteToUnsigned(b[offset++]) << 24; - return value; - } - - private static final void intToFourBytes(int iValue, byte b[], int offset) - { - b[offset++] = (byte)(iValue & 0xff); - b[offset++] = (byte)(iValue >>> 8 & 0xff); - b[offset++] = (byte)(iValue >>> 16 & 0xff); - b[offset++] = (byte)(iValue >>> 24 & 0xff); - } - - public static final boolean matches(String encryptedPassword, String enteredPassword) - { - String salt = encryptedPassword.substring(0, 3); - String newCrypt = crypt(salt, enteredPassword); - return newCrypt.equals(encryptedPassword); - } - -} diff --git a/crypto/src/java/org/apache/fulcrum/crypto/package.html b/crypto/src/java/org/apache/fulcrum/crypto/package.html deleted file mode 100644 index d1d1cc6..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/package.html +++ /dev/null @@ -1,29 +0,0 @@ -<!-- - 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. ---> -<html> -<head> -<!-- head part is ignored --> -</head> - -<body> -Contains the Crypto Service providing you with a variety of Crypto algorithms. -<br> -<font size="-2">$Id$</font> -</body> -</html> diff --git a/crypto/src/java/org/apache/fulcrum/crypto/provider/ClearCrypt.java b/crypto/src/java/org/apache/fulcrum/crypto/provider/ClearCrypt.java deleted file mode 100644 index a9cba70..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/provider/ClearCrypt.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.apache.fulcrum.crypto.provider; - - -/* - * 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.fulcrum.crypto.CryptoAlgorithm; - -/** - * This is a dummy for "cleartext" encryption. It goes through - * the notions of the CryptoAlgorithm interface but actually does - * nothing. It can be used as a replacement for the "encrypt = no" - * setting in TurbineResources. - * - * Can be used as the default crypto algorithm - * - * @author <a href="mailto:[email protected]">Henning P. Schmiedehausen</a> - * @version $Id$ - */ - -public class ClearCrypt - implements CryptoAlgorithm -{ - /** - * C'tor - * - */ - - public ClearCrypt() - { - } - - /** - * This class never uses an algorithm, so this is - * just a dummy. - * - * @param cipher Cipher (ignored) - */ - - public void setCipher(String cipher) - { - /* dummy */ - } - - /** - * This class never uses a seed, so this is - * just a dummy. - * - * @param seed Seed (ignored) - */ - - public void setSeed(String seed) - { - /* dummy */ - } - - /** - * encrypt the supplied string with the requested cipher - * - * @param value The value to be encrypted - * - * @return The encrypted value - * - * @throws Exception An Exception of the underlying implementation. - * - */ - - public String encrypt(String value) - throws Exception - { - /* - * Ultra-clever implementation. ;-) - */ - - return value; - } -} diff --git a/crypto/src/java/org/apache/fulcrum/crypto/provider/JavaCrypt.java b/crypto/src/java/org/apache/fulcrum/crypto/provider/JavaCrypt.java deleted file mode 100644 index 5972ddc..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/provider/JavaCrypt.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.apache.fulcrum.crypto.provider; - - -/* - * 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 java.security.MessageDigest; - -import org.apache.fulcrum.crypto.CryptoAlgorithm; -import org.apache.fulcrum.crypto.impl.Base64; - -/** - * Implements the normal java.security.MessageDigest stream cipers. - * Base64 strings returned by this provider are correctly padded to - * multiples of four bytes. If you run into interoperability problems - * with other languages, especially perl and the Digest::MD5 module, - * note that the md5_base64 function from this package incorrectly drops - * the pad bytes. Use the MIME::Base64 package instead. - * - * If you upgrade from Turbine 2.1 and suddently your old stored passwords - * no longer work, please take a look at the OldJavaCrypt provider for - * bug-to-bug compatibility. - * - * This provider can be used as the default crypto algorithm provider. - * - * @author <a href="mailto:[email protected]">Henning P. Schmiedehausen</a> - * @version $Id$ - */ - -public class JavaCrypt - implements CryptoAlgorithm -{ - - /** The default cipher */ - public static final String DEFAULT_CIPHER = "SHA"; - - /** The cipher to use for encryption */ - private String cipher = null; - - - /** - * C'tor - * - */ - - public JavaCrypt() - { - this.cipher = DEFAULT_CIPHER; - } - - /** - * Setting the actual cipher requested. If not - * called, then the default cipher (SHA) is used. - * - * This will never throw an error even if there is no - * provider for this cipher. The error will be thrown - * by encrypt() (Fixme?) - * - * @param cipher The cipher to use. - * - */ - - public void setCipher(String cipher) - { - this.cipher = cipher; - } - - /** - * This class never uses a seed, so this is - * just a dummy. - * - * @param seed Seed (ignored) - * - */ - - public void setSeed(String seed) - { - /* dummy */ - } - - /** - * encrypt the supplied string with the requested cipher - * - * @param value The value to be encrypted - * - * @return The encrypted value - * - * @throws Exception An Exception of the underlying implementation. - */ - - public String encrypt(String value) - throws Exception - { - MessageDigest md = MessageDigest.getInstance(cipher); - - // We need to use unicode here, to be independent of platform's - // default encoding. Thanks to SGawin for spotting this. - byte[] digest = md.digest(value.getBytes("UTF-8")); - - // Base64-encode the digest. - byte[] encodedDigest = Base64.encodeBase64(digest); - return (encodedDigest == null ? null : - new String(encodedDigest)); - } -} diff --git a/crypto/src/java/org/apache/fulcrum/crypto/provider/OldJavaCrypt.java b/crypto/src/java/org/apache/fulcrum/crypto/provider/OldJavaCrypt.java deleted file mode 100644 index 6580443..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/provider/OldJavaCrypt.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.apache.fulcrum.crypto.provider; - - -/* - * 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 java.security.MessageDigest; - -import org.apache.fulcrum.crypto.CryptoAlgorithm; -import org.apache.fulcrum.crypto.impl.Base64; - -/** - * This is the Message Digest Implementation of Turbine 2.1. It does - * not pad the Base64 encryption of the Message Digests correctly but - * truncates after 20 chars. This leads to interoperability problems - * if you want to use e.g. database columns between two languages. - * - * If you upgrade an application from Turbine 2.1 and have already used - * the Security Service with encrypted passwords and no way to rebuild - * your databases, use this provider. It is bug-compatible. - * - * DO NOT USE THIS PROVIDER FOR ANY NEW APPLICATION! - * - * Nevertheless it can be used as the default crypto algorithm . - * - * @author <a href="mailto:[email protected]">Henning P. Schmiedehausen</a> - * @version $Id$ - */ - -public class OldJavaCrypt - implements CryptoAlgorithm -{ - - /** The default cipher */ - public static final String DEFAULT_CIPHER = "SHA"; - - /** The cipher to use for encryption */ - private String cipher = null; - - - /** - * C'tor - * - */ - - public OldJavaCrypt() - { - this.cipher = DEFAULT_CIPHER; - } - - /** - * Setting the actual cipher requested. If not - * called, then the default cipher (SHA) is used. - * - * This will never throw an error even if there is no - * provider for this cipher. The error will be thrown - * by encrypt() (Fixme?) - * - * @param cipher The cipher to use. - * - */ - - public void setCipher(String cipher) - { - this.cipher = cipher; - } - - /** - * This class never uses a seed, so this is - * just a dummy. - * - * @param seed Seed (ignored) - * - */ - - public void setSeed(String seed) - { - /* dummy */ - } - - /** - * encrypt the supplied string with the requested cipher - * - * @param value The value to be encrypted - * - * @return The encrypted value - * - * @throws Exception An Exception of the underlying implementation. - */ - - public String encrypt(String value) - throws Exception - { - MessageDigest md = MessageDigest.getInstance(cipher); - - // We need to use unicode here, to be independent of platform's - // default encoding. Thanks to SGawin for spotting this. - - byte[] digest = md.digest(value.getBytes("UTF-8")); - byte[] base64 = Base64.encodeBase64(digest); - // from MD5 the digest has 16 bytes but for SHA1 it contains 20 bytes - // depending on the digest lenght the result is truncated - int len = (digest.length == 16 ? 20 : 24 ); - byte[] result = new byte[len]; - System.arraycopy(base64, 0, result, 0, result.length); - return new String(result); - } -} diff --git a/crypto/src/java/org/apache/fulcrum/crypto/provider/UnixCrypt.java b/crypto/src/java/org/apache/fulcrum/crypto/provider/UnixCrypt.java deleted file mode 100644 index ac1675d..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/provider/UnixCrypt.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.apache.fulcrum.crypto.provider; - -/* - * 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.fulcrum.crypto.CryptoAlgorithm; - -import java.util.Random; - -/** - * Implements Standard Unix crypt(3) for use with the Crypto Service. - * - * @author <a href="mailto:[email protected]">Henning P. Schmiedehausen</a> - * @version $Id$ - */ - -public class UnixCrypt - implements CryptoAlgorithm -{ - - /** The seed to use */ - private String seed = null; - - /** standard Unix crypt chars (64) */ - private static final char[] SALT_CHARS = - (("abcdefghijklmnopqrstuvwxyz" + - "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./").toCharArray()); - - - /** - * C'tor - * - */ - - public UnixCrypt() - { - } - - /** - * This class never uses anything but - * UnixCrypt, so it is just a dummy - * (Fixme: Should we throw an exception if - * something is requested that we don't support? - * - * @param cipher Cipher (ignored) - */ - - public void setCipher(String cipher) - { - /* dummy */ - } - - /** - * Setting the seed for the UnixCrypt - * algorithm. If a null value is supplied, - * or no seed is set, then a random seed is used. - * - * @param seed The seed value to use. - */ - - public void setSeed(String seed) - { - this.seed = seed; - } - - /** - * encrypt the supplied string with the requested cipher - * - * @param value The value to be encrypted - * @return The encrypted value - * @throws Exception An Exception of the underlying implementation. - */ - public String encrypt(String value) - throws Exception - { - if (seed == null) - { - Random randomGenerator = new java.util.Random(); - int numSaltChars = SALT_CHARS.length; - - seed = (new StringBuffer()) - .append(SALT_CHARS[Math.abs(randomGenerator.nextInt()) - % numSaltChars]) - .append(SALT_CHARS[Math.abs(randomGenerator.nextInt()) - % numSaltChars]) - .toString(); - } - - return org.apache.fulcrum.crypto.impl.UnixCrypt.crypt(seed, value); - } -} diff --git a/crypto/src/java/org/apache/fulcrum/crypto/provider/package.html b/crypto/src/java/org/apache/fulcrum/crypto/provider/package.html deleted file mode 100644 index 5a84cef..0000000 --- a/crypto/src/java/org/apache/fulcrum/crypto/provider/package.html +++ /dev/null @@ -1,29 +0,0 @@ -<!-- - 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. ---> -<html> -<head> -<!-- head part is ignored --> -</head> - -<body> -Algorithm providers for the Crypto Service. -<br> -<font size="-2">$Id$</font> -</body> -</html> diff --git a/crypto/src/test/TestComponentConfig.xml b/crypto/src/test/TestComponentConfig.xml deleted file mode 100644 index e8493f5..0000000 --- a/crypto/src/test/TestComponentConfig.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<componentConfig> - <crypto> - <algorithm> - <unix>org.apache.fulcrum.crypto.provider.UnixCrypt</unix> - <clear>org.apache.fulcrum.crypto.provider.ClearCrypt</clear> - <java>org.apache.fulcrum.crypto.provider.JavaCrypt</java> - <oldjava>org.apache.fulcrum.crypto.provider.OldJavaCrypt</oldjava> - </algorithm> - </crypto> -</componentConfig> diff --git a/crypto/src/test/TestRoleConfig.xml b/crypto/src/test/TestRoleConfig.xml deleted file mode 100644 index e463898..0000000 --- a/crypto/src/test/TestRoleConfig.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<!-- This configuration file for Avalon components is used for testing the TestComponent --> -<role-list> - <role - name="org.apache.fulcrum.crypto.CryptoService" - shorthand="crypto" - default-class="org.apache.fulcrum.crypto.DefaultCryptoService"/> -</role-list> diff --git a/crypto/src/test/org/apache/fulcrum/crypto/CryptoServiceTest.java b/crypto/src/test/org/apache/fulcrum/crypto/CryptoServiceTest.java deleted file mode 100644 index 16fc367..0000000 --- a/crypto/src/test/org/apache/fulcrum/crypto/CryptoServiceTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.apache.fulcrum.crypto; - -/* - * 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.fulcrum.testcontainer.BaseUnitTest; - -/** - * Basic testing of the Container - * - * @author <a href="mailto:[email protected]">Eric Pugh</a> - * @author <a href="mailto:[email protected]">Stephen McConnell</a> - * @version $Id$ - */ -public class CryptoServiceTest extends BaseUnitTest -{ - private CryptoService sc = null; - private static final String preDefinedInput = "Oeltanks"; - - /** - * Constructor for test. - * - * @param testName name of the test being executed - */ - public CryptoServiceTest(String testName) - { - super(testName); - } - - - public void setUp() throws Exception - { - super.setUp(); - sc = (CryptoService) this.lookup( CryptoService.ROLE ); - - } - - public void testUnixCrypt() throws Exception - { - String preDefinedSeed = "z5"; - String preDefinedResult = "z5EQaXpuu059c"; - - CryptoAlgorithm ca = sc.getCryptoAlgorithm("unix"); - /* - * Test predefined Seed - */ - ca.setSeed(preDefinedSeed); - String output = ca.encrypt(preDefinedInput); - assertEquals("Encryption failed ", preDefinedResult, output); - /* - * Test random Seed - * - */ - ca.setSeed(null); - String result = ca.encrypt(preDefinedInput); - ca.setSeed(result); - output = ca.encrypt(preDefinedInput); - assertEquals("Encryption failed ", output, result); - - - - } - - public void testClearCrypt() throws Exception - { - String preDefinedResult = "Oeltanks"; - - CryptoAlgorithm ca = sc.getCryptoAlgorithm("clear"); - String output = ca.encrypt(preDefinedInput); - assertEquals("Encryption failed ", preDefinedResult, output); - - } - - public void testOldJavaCryptMd5() throws Exception - { - String preDefinedResult = "XSop0mncK19Ii2r2CUe2"; - - CryptoAlgorithm ca = sc.getCryptoAlgorithm("oldjava"); - ca.setCipher("MD5"); - String output = ca.encrypt(preDefinedInput); - assertEquals("MD5 Encryption failed ", preDefinedResult, output); - - } - public void testOldJavaCryptSha1() throws Exception - { - String preDefinedResult = "uVDiJHaavRYX8oWt5ctkaa7j"; - - CryptoAlgorithm ca = sc.getCryptoAlgorithm("oldjava"); - ca.setCipher("SHA1"); - String output = ca.encrypt(preDefinedInput); - assertEquals("SHA1 Encryption failed ", preDefinedResult, output); - - } - public void testJavaCryptMd5() throws Exception - { - String preDefinedResult = "XSop0mncK19Ii2r2CUe29w=="; - CryptoAlgorithm ca = sc.getCryptoAlgorithm("java"); - ca.setCipher("MD5"); - String output = ca.encrypt(preDefinedInput); - assertEquals("MD5 Encryption failed ", preDefinedResult, output); - } - - public void testJavaCryptSha1() throws Exception - { - String preDefinedResult = "uVDiJHaavRYX8oWt5ctkaa7j1cw="; - CryptoAlgorithm ca = sc.getCryptoAlgorithm("java"); - ca.setCipher("SHA1"); - String output = ca.encrypt(preDefinedInput); - assertEquals("SHA1 Encryption failed ", preDefinedResult, output); - - } -} diff --git a/crypto/xdocs/changes.xml b/crypto/xdocs/changes.xml deleted file mode 100644 index af79c89..0000000 --- a/crypto/xdocs/changes.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0"?> -<!-- - 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. ---> -<document> - <properties> - <title>Fulcrum Crypto</title> - <author email="[email protected]">Eric Pugh</author> - </properties> - - <body> - <release version="1.0.6" date="as in SVN"> - <action dev="sgoeschl" type="update"> - Getting rid of all external dependencies - in particular - the crytptix library. The cryptix library contains strong - encyryption algorithm causing problems using the software - outside of the US (ECCN). Copy and wasted some source from - JetSpeed (UnixCrpyt) and commons-codec (Base64). - </action> - <action dev="sgoeschl" type="update"> - Upgrading to javamail-1.3.2 - </action> - </release> - <release version="1.0.5" date="2004-11-24"> - <action dev="epugh" type="update" due-to="Kostyantyn Shchekotykhin"> - Merge api and impl jars into one project. - </action> - <action dev="epugh" type="update"> - Add ECM based tests. - </action> - <action dev="epugh" type="update" due-to="Youngho Cho"> - Update to use commons-codec-1.3 - </action> - </release> - <release version="1.0.4" date=""> - <action dev="epugh" type="update"> - Update to use Merlin 3.3.0 - </action> - <action dev="epugh" type="add"> - Implementing the merlinized code. - </action> - </release> - <release version="1.0-alpha-3" date="11-18-2003"> - <action dev="epugh" type="add"> - Integrated howto documentation on main page. - </action> - </release> - - </body> -</document> - diff --git a/crypto/xdocs/index.xml b/crypto/xdocs/index.xml deleted file mode 100644 index 79d9cc5..0000000 --- a/crypto/xdocs/index.xml +++ /dev/null @@ -1,167 +0,0 @@ -<?xml version="1.0"?> -<!-- - 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. ---> - -<document> - - <properties> - <title>Crypto Component</title> - <author email="[email protected]">Eric PUgh</author> - </properties> - - <body> - - <section name="Overview"> - <p> - The Crypto Service allows an application to request various encryption - algorithms. - </p> - - <p> - It is written for use in Turbine but it can be used in any container compatible - with Avalon's ECM container. - </p> - </section> - -<section name="Configuration"> - - <p> - First, here is the role configuration. - </p> - -<source> -<![CDATA[ - <role - name="org.apache.fulcrum.crypto.CryptoService" - shorthand="crypto" - default-class="org.apache.fulcrum.crypto.DefaultCryptoService"/> -]]> -</source> - - <p> - Now comes the basic configuration of the component. Here will will - configure the various encryption providers - </p> -<source> - -<![CDATA[ - <crypto> - <algorithm> - <unix>org.apache.fulcrum.crypto.provider.UnixCrypt</unix> - <clear>org.apache.fulcrum.crypto.provider.ClearCrypt</clear> - <java>org.apache.fulcrum.crypto.provider.JavaCrypt</java> - <oldjava>org.apache.fulcrum.crypto.provider.OldJavaCrypt</oldjava> - - </algorithm> - </crypto> -]]> -</source> - - </section> - -<section name="Usage"> - -<p> -If you want to encrypt a clear text with a MessageDigest Cipher, you can -do it like this: -</p> - -<source><![CDATA[ -import org.apache.fulcrum.crypto.CryptoAlgorithm; -import org.apache.fulcrum.crypto.CryptoService; - -public class CryptoExample -{ - public String doMD5Encryption(String input) - { - CryptoService cs = (CryptoService) avalonComponentService.lookup(CryptoService.ROLE); - CryptoAlgorithm ca = CryptoService.getCryptoAlgorithm("default"); - - ca.setCipher("MD5"); - - return ca.encrypt(input); - } -} -]]></source> - -<p> -To see an example, look at the test case -<a href="xref-test/org/apache/fulcrum/crypto/CryptoServiceTest.html">CryptoServiceTest</a>. -</p> - -</section> - - <section name="Default Provider"> - - <p> - In the source code and the example above, there is talk about a - "default" provider which is used if no encryption algorithm is - specifically requested. The reason for this comes from the first user - of the crypto service, the <a href="security-service.html">Security - Service</a>. It gives you the ability to select an encryption - algorithm like MD5 or SHA1 which is in turn used with the normal java - crypto providers. As we just wanted to "add" new algorithms and still - be able to use the old java.security names like MD5 and SHA1, we - decided to add a "catchall" algorithm to the crypto service. - </p> - <p> - If you don't set the default provider explicitly, the - org.apache.fulcrum.crypto.provider.JavaCrypt class is used. If you - don't set the Cipher of this class explicitly, then SHA is used. - </p> - - </section> - - <section name="Included Providers"> - <p>The following algorithm providers are included in the Cryptoservice:</p> - - <p> - <ol> - <li> - <b>ClearCrypt</b> (org.apache.fulcrum.crypto.provider.ClearCrypt). This is - the simplest algorithm which does nothing. It is still useful because - you can use the Crypto Service all the time even if you don't want to - actually encrypt something. Just request the "cleartext" algorithm. - </li> - <li> - <b>UnixCrypt</b> (org.apache.fulcrum.crypto.provider.UnixCrypt). This is an - implementation of the Unix crypt(3) algorithm. Its main use is when - you need to access legacy information or databases which already - contain crypted passwords. - </li> - <li> - <b>JavaCrypt</b> (org.apache.fulcrum.crypto.provider.JavaCrypt). This is the - default crypto provider. It implements the normal Java MessageDigest ciphers - You need not to have this, it is the default if no algorithms are given. The default - provider gives you all the Java MessageDigest Ciphers including MD5, and SHA1. - </li> - <li> - <b>OldJavaCrypt</b> (org.apache.fulcrum.crypto.provider.OldJavaCrypt). Accessing - the MessageDigest functions from java.security was buggy in Turbine 2.1, because - the Security Service didn't pad the base64 values correctly but simply cut them - off after 20 bytes. If you're stuck with an old database full of passwords and can't - upgrade, please use this provider to keep going. DO NOT USE THIS PROVIDER FOR NEW - APPLICATIONS!. - </li> - </ol> - </p> - </section> - -</body> -</document> diff --git a/crypto/xdocs/navigation.xml b/crypto/xdocs/navigation.xml deleted file mode 100644 index c06b5e4..0000000 --- a/crypto/xdocs/navigation.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?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. ---> - -<!DOCTYPE project [ -<!ENTITY site-nav SYSTEM "../../incl_site_nav.xml"> -]> - -<project - name="Fulcrum Crypto" - href="http://turbine.apache.org/fulcrum/fulcrum-crypto/"> - - <body> - -&site-nav; - - <menu name="Overview"> - <item name="Main" href="/index.html"/> - </menu> - </body> -</project>
