diff --git a/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/sessionsxml/CustomEncryption.java b/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/sessionsxml/CustomEncryption.java index 6c6c654857d..c538c29cc8a 100644 --- a/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/sessionsxml/CustomEncryption.java +++ b/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/sessionsxml/CustomEncryption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -14,7 +14,7 @@ // Oracle - initial API and implementation from Oracle TopLink package org.eclipse.persistence.testing.tests.sessionsxml; -import org.eclipse.persistence.internal.security.Securable; +import org.eclipse.persistence.security.Securable; public class CustomEncryption implements Securable { diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/config/PersistenceUnitProperties.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/config/PersistenceUnitProperties.java index 9ed49341c77..9b900a215c7 100644 --- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/config/PersistenceUnitProperties.java +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/config/PersistenceUnitProperties.java @@ -4167,6 +4167,24 @@ public class PersistenceUnitProperties { */ public static final String QUERY_RESULTS_CACHE_VALIDATION = "eclipselink.query-results-cache.validation"; + /** + * The "eclipselink.login.encryptor" property configures a custom implementation of + * {@link org.eclipse.persistence.security.Securable} class used to encrypt and decrypt database password + * loaded from "jakarta.persistence.jdbc.password" property. + * Usage of this property avoids limitation of {@link SessionCustomizer} which is called when all other + * properties have been processed (too late when database login needs to be configured). + * If this property is not specified {@link org.eclipse.persistence.internal.security.JCEEncryptor} as a default encryptor is used. + *

+ * Allowed Values: + *

+ * + * @see org.eclipse.persistence.security.Securable + * @see org.eclipse.persistence.internal.security.JCEEncryptor + */ + public static final String LOGIN_ENCRYPTOR = "eclipselink.login.encryptor"; + /** * INTERNAL: The following properties will not be displayed through logging * but instead have an alternate value shown in the log. diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/JCEEncryptor.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/JCEEncryptor.java index 0a2012d6bc1..2cbcb4db101 100644 --- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/JCEEncryptor.java +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/JCEEncryptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -36,7 +36,7 @@ * * @author Guy Pelletier */ -public class JCEEncryptor implements Securable { +public class JCEEncryptor implements org.eclipse.persistence.security.Securable { // Legacy DES ECB cipher used for backwards compatibility decryption only. private static final String DES_ECB = "DES/ECB/PKCS5Padding"; diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/SecurableObjectHolder.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/SecurableObjectHolder.java index 32d670e1273..9f35f452505 100644 --- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/SecurableObjectHolder.java +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/SecurableObjectHolder.java @@ -114,7 +114,7 @@ private void initSecurableObject() { * At runtime, no encryption will be made and the passwords will be assummed to * be clear text. */ - private static final class PassThroughEncryptor implements Securable { + private static final class PassThroughEncryptor implements org.eclipse.persistence.security.Securable { public String encryptPassword(String pswd) { return pswd; } diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/security/Securable.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/security/Securable.java new file mode 100644 index 00000000000..8c3387d599c --- /dev/null +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/security/Securable.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ + +// Contributors: +// Oracle - initial API and implementation from Oracle TopLink +package org.eclipse.persistence.security; + +/** + * EclipseLink encryption interface + */ +public interface Securable extends org.eclipse.persistence.internal.security.Securable { + + @Override + String encryptPassword(String pswd); + + @Override + String decryptPassword(String encryptedPswd); +} \ No newline at end of file diff --git a/jpa/eclipselink.jpa.test/resource/eclipselink-advanced-properties/persistence.xml b/jpa/eclipselink.jpa.test/resource/eclipselink-advanced-properties/persistence.xml index 518347e5709..8902bec9e83 100644 --- a/jpa/eclipselink.jpa.test/resource/eclipselink-advanced-properties/persistence.xml +++ b/jpa/eclipselink.jpa.test/resource/eclipselink-advanced-properties/persistence.xml @@ -1,6 +1,6 @@