You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2019/04/20 15:44:33 UTC
[directory-studio] branch remove-jndi-provider-and-jndi-layer
updated: Update for server master changes and mina 2.1.2
This is an automated email from the ASF dual-hosted git repository.
seelmann pushed a commit to branch remove-jndi-provider-and-jndi-layer
in repository https://gitbox.apache.org/repos/asf/directory-studio.git
The following commit(s) were added to refs/heads/remove-jndi-provider-and-jndi-layer by this push:
new a77d5a5 Update for server master changes and mina 2.1.2
a77d5a5 is described below
commit a77d5a58a25a4abc9fbc20f4f86c1c0385ea87cf
Author: Stefan Seelmann <ma...@stefan-seelmann.de>
AuthorDate: Sat Apr 20 17:44:17 2019 +0200
Update for server master changes and mina 2.1.2
---
...directory.studio.eclipse-trgt-platform.template | 2 +-
pom.xml | 4 +-
tests/test.integration.core/pom-first.xml | 2 +-
.../core/ConnectionWrapperTestBase.java | 13 ++--
tests/test.integration.ui/pom-first.xml | 2 +-
.../test/integration/ui/CertificateUtils.java | 80 ----------------------
.../test/integration/ui/EntryEditorTest.java | 27 +++++++-
.../test/integration/ui/PreferencesTest.java | 15 ++--
8 files changed, 44 insertions(+), 101 deletions(-)
diff --git a/eclipse-trgt-platform/template/org.apache.directory.studio.eclipse-trgt-platform.template b/eclipse-trgt-platform/template/org.apache.directory.studio.eclipse-trgt-platform.template
index 0cec0ff..3315823 100644
--- a/eclipse-trgt-platform/template/org.apache.directory.studio.eclipse-trgt-platform.template
+++ b/eclipse-trgt-platform/template/org.apache.directory.studio.eclipse-trgt-platform.template
@@ -19,7 +19,7 @@
@author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
-->
<?pde version="3.8"?>
-<target name="Apache Directory Studio Platform" sequenceNumber="411">
+<target name="Apache Directory Studio Platform" sequenceNumber="423">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
diff --git a/pom.xml b/pom.xml
index 62497a3..f441d6a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,8 +90,8 @@
<org.apache.commons.pool.bundleversion>2.6.1</org.apache.commons.pool.bundleversion>
<org.apache.directory.api.version>2.0.0.AM3-SNAPSHOT</org.apache.directory.api.version>
<org.apache.directory.server.version>2.0.0.AM26-SNAPSHOT</org.apache.directory.server.version>
- <org.apache.mina.version>2.1.0</org.apache.mina.version>
- <org.apache.mina.bundleversion>2.1.0</org.apache.mina.bundleversion>
+ <org.apache.mina.version>2.1.2</org.apache.mina.version>
+ <org.apache.mina.bundleversion>2.1.2</org.apache.mina.bundleversion>
<org.apache.poi.version>3.9</org.apache.poi.version>
<org.apache.poi.bundleversion>3.9.0</org.apache.poi.bundleversion>
<org.apache.xmlgraphics.fop.version>1.0</org.apache.xmlgraphics.fop.version>
diff --git a/tests/test.integration.core/pom-first.xml b/tests/test.integration.core/pom-first.xml
index 4556c4d..192aa87 100644
--- a/tests/test.integration.core/pom-first.xml
+++ b/tests/test.integration.core/pom-first.xml
@@ -61,7 +61,7 @@
org.apache.directory.api.ldap.model;bundle-version="${org.apache.directory.api.version}",
org.apache.directory.api.ldap.net.mina;bundle-version="${org.apache.directory.api.version}",
org.apache.directory.api.util;bundle-version="${org.apache.directory.api.version}",
- org.apache.mina.core;bundle-version="${org.apache.mina.version}",
+ org.apache.mina.core;bundle-version="${org.apache.mina.bundleversion}",
org.apache.directory.studio.connection.core,
org.apache.directory.studio.common.core,
org.apache.directory.studio.ldapbrowser.core,
diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ConnectionWrapperTestBase.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ConnectionWrapperTestBase.java
index 481b538..886d16b 100644
--- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ConnectionWrapperTestBase.java
+++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ConnectionWrapperTestBase.java
@@ -33,6 +33,7 @@ import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.net.ConnectException;
import java.nio.channels.UnresolvedAddressException;
+import java.nio.charset.StandardCharsets;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
@@ -75,6 +76,7 @@ import org.apache.mina.util.AvailablePortFinder;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -323,14 +325,9 @@ public abstract class ConnectionWrapperTestBase extends AbstractLdapTestUnit
StudioSearchResult entry = result.next();
assertNotNull( entry );
- Object userCertificateValue = entry.getEntry().get( "userCertificate" ).getBytes();
- assertEquals( byte[].class, userCertificateValue.getClass() );
-
- CertificateFactory cf = CertificateFactory.getInstance( "X.509" ); //$NON-NLS-1$
- Certificate certificate = cf.generateCertificate( new ByteArrayInputStream( ( byte[] ) userCertificateValue ) );
- assertTrue( certificate instanceof X509Certificate );
- X509Certificate x509Certificate = ( X509Certificate ) certificate;
- assertTrue( x509Certificate.getIssuerDN().getName().contains( "ApacheDS" ) );
+ Object userPasswordValue = entry.getEntry().get( "userPassword" ).getBytes();
+ assertEquals( byte[].class, userPasswordValue.getClass() );
+ assertEquals( "secret", new String( ( byte[] ) userPasswordValue, StandardCharsets.UTF_8 ) );
}
diff --git a/tests/test.integration.ui/pom-first.xml b/tests/test.integration.ui/pom-first.xml
index a18c69c..e049513 100644
--- a/tests/test.integration.ui/pom-first.xml
+++ b/tests/test.integration.ui/pom-first.xml
@@ -71,7 +71,7 @@
org.apache.directory.api.ldap.model;bundle-version="${org.apache.directory.api.version}",
org.apache.directory.api.ldap.net.mina;bundle-version="${org.apache.directory.api.version}",
org.apache.directory.api.util;bundle-version="${org.apache.directory.api.version}",
- org.apache.mina.core;bundle-version="${org.apache.mina.version}",
+ org.apache.mina.core;bundle-version="${org.apache.mina.bundleversion}",
org.apache.directory.studio.aciitemeditor,
org.apache.directory.studio.apacheds.configuration,
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateUtils.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateUtils.java
deleted file mode 100644
index f21eb7d..0000000
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateUtils.java
+++ /dev/null
@@ -1,80 +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.
- *
- */
-
-package org.apache.directory.studio.test.integration.ui;
-
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.KeyStore;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.SignatureException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.X509Certificate;
-import java.util.Date;
-
-import javax.security.auth.x500.X500Principal;
-
-import org.bouncycastle.x509.X509V1CertificateGenerator;
-
-
-/**
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-public class CertificateUtils
-{
-
-
- public static X509Certificate createCertificate( String issuerDN, String subjectDN, Date startDate, Date expiryDate,
- KeyPair keypair ) throws CertificateEncodingException, NoSuchProviderException, NoSuchAlgorithmException,
- SignatureException, InvalidKeyException
- {
- BigInteger serialNumber = BigInteger.valueOf( System.currentTimeMillis() );
- X509V1CertificateGenerator certGen = new X509V1CertificateGenerator();
- X500Principal issuerName = new X500Principal( issuerDN );
- X500Principal subjectName = new X500Principal( subjectDN );
- certGen.setSerialNumber( serialNumber );
- certGen.setIssuerDN( issuerName );
- certGen.setNotBefore( startDate );
- certGen.setNotAfter( expiryDate );
- certGen.setSubjectDN( subjectName );
- certGen.setPublicKey( keypair.getPublic() );
- certGen.setSignatureAlgorithm( "SHA1WithRSA" );
- X509Certificate cert = certGen.generate( keypair.getPrivate(), "BC" );
- return cert;
- }
-
-
- public static KeyPair createKeyPair( int keysize ) throws NoSuchAlgorithmException
- {
- KeyPairGenerator generator = KeyPairGenerator.getInstance( "RSA" );
- generator.initialize( keysize );
- KeyPair keypair = generator.genKeyPair();
- return keypair;
- }
-
-}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
index 2098487..52c9e27 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
@@ -31,11 +31,16 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.cert.X509Certificate;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.directory.api.ldap.model.constants.LdapSecurityConstants;
+import org.apache.directory.api.ldap.model.entry.DefaultModification;
import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.entry.ModificationOperation;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.password.PasswordUtil;
import org.apache.directory.api.util.FileUtils;
@@ -45,9 +50,11 @@ import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.annotations.ApplyLdifFiles;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.security.CertificateUtil;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.ldifparser.LdifFormatParameters;
import org.apache.directory.studio.ldifparser.model.lines.LdifAttrValLine;
+import org.apache.directory.studio.test.integration.ui.bots.BotUtils;
import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot;
import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
import org.apache.directory.studio.test.integration.ui.bots.DnEditorDialogBot;
@@ -70,6 +77,8 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import sun.security.x509.X500Name;
+
/**
* Tests the entry editor.
@@ -469,13 +478,25 @@ public class EntryEditorTest extends AbstractLdapTestUnit
@Test
public void testCertificateValueEditor() throws Exception
{
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "uid=admin" );
+ X500Name issuer = new X500Name( "Foo", "Bar", "Baz", "US" );
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance( "EC" );
+ keyPairGenerator.initialize( 256 );
+ KeyPair keyPair = keyPairGenerator.generateKeyPair();
+ X509Certificate certificate = CertificateUtil.generateSelfSignedCertificate( issuer, keyPair, 365,
+ "SHA256WithECDSA" );
+ getService().getAdminSession().modify( new Dn( "cn=Barbara Jensen,ou=users,ou=system" ),
+ new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "userCertificate",
+ certificate.getEncoded() ) );
+
+ browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=Barbara Jensen" );
- EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( "uid=admin,ou=system" );
+ EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( "cn=Barbara Jensen,ou=users,ou=system" );
entryEditorBot.activate();
+ BotUtils.sleep( 10000 );
+
assertTrue( entryEditorBot.getAttributeValues()
- .contains( "userCertificate: X.509v1: CN=ApacheDS,OU=Directory,O=ASF,C=US" ) );
+ .contains( "userCertificate: X.509v3: CN=Foo,OU=Bar,O=Baz,C=US" ) );
}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java
index 5e300f0..44a3346 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java
@@ -28,14 +28,16 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.net.URL;
import java.nio.charset.StandardCharsets;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
import java.security.cert.X509Certificate;
-import java.util.Date;
import java.util.List;
import org.apache.directory.api.util.FileUtils;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.security.CertificateUtil;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.connection.core.PasswordsKeyStoreManager;
@@ -56,6 +58,8 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import sun.security.x509.X500Name;
+
/**
* Tests the preferences.
@@ -153,10 +157,11 @@ public class PreferencesTest extends AbstractLdapTestUnit
preferencesBot.clickCancelButton();
// add a certificate (not possible via native file dialog)
- Date startDate = new Date( System.currentTimeMillis() - 1000 );
- Date endDate = new Date( System.currentTimeMillis() + 1000 );
- X509Certificate certificate = CertificateUtils.createCertificate( "cn=localhost", "cn=localhost", startDate,
- endDate, CertificateUtils.createKeyPair( 1024 ) );
+ X500Name issuer = new X500Name( "apacheds", "directory", "apache", "US" );
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance( "EC" );
+ keyPairGenerator.initialize( 256 );
+ KeyPair keyPair = keyPairGenerator.generateKeyPair();
+ X509Certificate certificate = CertificateUtil.generateSelfSignedCertificate( issuer, keyPair, 365, "SHA256WithECDSA" );
ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().addCertificate( certificate );
// verify there is one certificate now