directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r580197 - /directory/sandbox/erodriguez/kerberos-pkinit/src/test/java/org/apache/directory/server/kerberos/pkinit/JcePolicyTest.java
Date Fri, 28 Sep 2007 02:35:38 GMT
Author: erodriguez
Date: Thu Sep 27 19:35:37 2007
New Revision: 580197

URL: http://svn.apache.org/viewvc?rev=580197&view=rev
Log:
Added experimental TestCase for checking for installed strong crypto policy.

Added:
    directory/sandbox/erodriguez/kerberos-pkinit/src/test/java/org/apache/directory/server/kerberos/pkinit/JcePolicyTest.java
  (with props)

Added: directory/sandbox/erodriguez/kerberos-pkinit/src/test/java/org/apache/directory/server/kerberos/pkinit/JcePolicyTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/erodriguez/kerberos-pkinit/src/test/java/org/apache/directory/server/kerberos/pkinit/JcePolicyTest.java?rev=580197&view=auto
==============================================================================
--- directory/sandbox/erodriguez/kerberos-pkinit/src/test/java/org/apache/directory/server/kerberos/pkinit/JcePolicyTest.java
(added)
+++ directory/sandbox/erodriguez/kerberos-pkinit/src/test/java/org/apache/directory/server/kerberos/pkinit/JcePolicyTest.java
Thu Sep 27 19:35:37 2007
@@ -0,0 +1,77 @@
+/*
+ *  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.apache.directory.server.kerberos.pkinit;
+
+
+import java.security.NoSuchAlgorithmException;
+
+import javax.crypto.Cipher;
+
+import junit.framework.TestCase;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Tests the detection of installed unlimited strength policy.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class JcePolicyTest extends TestCase
+{
+    /** the logger for this class */
+    private static final Logger logger = LoggerFactory.getLogger( JcePolicyTest.class );
+
+
+    /**
+     * Tests the detection of installed unlimited strength policy.
+     */
+    public void testPolicy()
+    {
+        if ( !isStrongCryptoEnabled() )
+        {
+            assertFalse( isStrongCryptoEnabled() );
+            logger.warn( "Skipping AES tests in {} because unlimited strength policy is not
installed.",
+                JcePolicyTest.class.getSimpleName() );
+        }
+        else
+        {
+            assertTrue( isStrongCryptoEnabled() );
+        }
+    }
+
+
+    /**
+     * Will be 128 for AES weak crypto, "2147483647" for strong (unlimited strength).
+     */
+    protected boolean isStrongCryptoEnabled()
+    {
+        try
+        {
+            return ( Cipher.getMaxAllowedKeyLength( "AES" ) > 128 );
+        }
+        catch ( NoSuchAlgorithmException nsae )
+        {
+            return false;
+        }
+    }
+}

Propchange: directory/sandbox/erodriguez/kerberos-pkinit/src/test/java/org/apache/directory/server/kerberos/pkinit/JcePolicyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message