Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to new Runtime APIs #70

Merged
merged 38 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2107827
Delete stale bot
anupama-pathirage Sep 29, 2024
f4c5e93
Merge pull request #64 from ballerina-platform/anupama-pathirage-patch-2
NipunaRanasinghe Sep 29, 2024
8437462
[Automated] Update the toml files
DaAlbrecht Oct 11, 2024
ecdf17b
[Automated] Update the toml files
DaAlbrecht Oct 13, 2024
e9a7ced
[Automated] Update the toml files
DaAlbrecht Oct 13, 2024
67da384
[Automated] Update the toml files
DaAlbrecht Oct 13, 2024
5c7d1d4
feat: provide option to configure tls, chore: update ballerina module…
DaAlbrecht Oct 13, 2024
ac18bfa
chore: fix naming to be ALL_CAPS
DaAlbrecht Oct 21, 2024
358e93d
chore: remove useless if expression
DaAlbrecht Oct 21, 2024
5d7aa89
chore: return directly
DaAlbrecht Oct 21, 2024
eb6dcfd
chore: use getStringArray method
DaAlbrecht Oct 21, 2024
e75ac56
fix: remove hardcoded tls version
DaAlbrecht Oct 21, 2024
5743752
chore: merge exceptions
DaAlbrecht Oct 21, 2024
a5681f8
feat: update license
DaAlbrecht Oct 21, 2024
0fbfb9a
chore: remove Dependencies.toml
DaAlbrecht Oct 22, 2024
17b38dc
Fix syntax errors in the native code
Nuvindu Oct 22, 2024
ae984d0
Merge branch 'master' of https://github.com/DaAlbrecht/module-balleri…
Nuvindu Oct 22, 2024
aa44260
Add time module dependency
Nuvindu Oct 22, 2024
1b989e0
Fix variable names in constants
Nuvindu Oct 22, 2024
b1b6c81
chore: shorten the test
DaAlbrecht Oct 25, 2024
393d95e
chore: use objects.notNull
DaAlbrecht Oct 25, 2024
39022ec
chore: use Objects.nonNull
DaAlbrecht Oct 25, 2024
4d31d8d
chore: move resources to tests/resources, chore: use field init short…
DaAlbrecht Oct 27, 2024
8ed1460
Merge pull request #66 from DaAlbrecht/master
Nuvindu Oct 28, 2024
e6e638f
Change the lang version to 2201.9.0
Nuvindu Oct 28, 2024
56d612d
Bump the module version to 1.1.0
Nuvindu Oct 28, 2024
4a929b2
[Automated] Update the toml files
Nuvindu Oct 28, 2024
6056165
Add constants for keywords and error messages
Nuvindu Oct 28, 2024
36ce3db
Merge pull request #67 from Nuvindu/review-fix
Nuvindu Oct 28, 2024
41fed3e
[Automated] Update the toml files
Nuvindu Oct 28, 2024
95b5d59
Update Ballerina distribution in Ballerina.toml
Nuvindu Oct 28, 2024
38bf71f
Merge pull request #68 from Nuvindu/review-fix
NipunaRanasinghe Oct 29, 2024
edb8acc
Migrate to new Runtime APIs
warunalakshitha Nov 12, 2024
97bcb5c
Sync with master
warunalakshitha Nov 12, 2024
a2bf29a
Bump crypto version
warunalakshitha Nov 13, 2024
37e4b39
Bump time version
warunalakshitha Nov 13, 2024
f4a3d04
[Automated] Update the toml files
warunalakshitha Nov 13, 2024
ea581b7
Bump io version
warunalakshitha Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/stale_check.yml

This file was deleted.

8 changes: 4 additions & 4 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[package]
org = "ballerina"
name = "ldap"
version = "1.0.1"
version = "1.1.0"
authors = ["Ballerina"]
export=["ldap"]
keywords = ["ldap"]
repository = "https://github.com/ballerina-platform/module-ballerina-ldap"
license = ["Apache-2.0"]
distribution = "2201.8.0"
distribution = "2201.9.0"

[platform.java21]
graalvmCompatible = true

[[platform.java21.dependency]]
groupId = "io.ballerina.lib"
artifactId = "ldap-native"
version = "1.0.1"
path = "../native/build/libs/ldap-native-1.0.1.jar"
version = "1.1.0-SNAPSHOT"
path = "../native/build/libs/ldap-native-1.1.0-SNAPSHOT.jar"

[[platform.java21.dependency]]
groupId = "com.unboundid"
Expand Down
52 changes: 50 additions & 2 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.8.0"
distribution-version = "2201.11.0-20241112-214900-6b80ab87"

[[package]]
org = "ballerina"
name = "crypto"
version = "2.7.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
]
modules = [
{org = "ballerina", packageName = "crypto", moduleName = "crypto"}
]

[[package]]
org = "ballerina"
Expand All @@ -15,6 +27,26 @@ modules = [
{org = "ballerina", packageName = "jballerina.java", moduleName = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.__internal"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
]

[[package]]
org = "ballerina"
name = "lang.array"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.__internal"}
]

[[package]]
org = "ballerina"
name = "lang.error"
Expand All @@ -24,11 +56,18 @@ dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.object"
version = "0.0.0"
scope = "testOnly"

[[package]]
org = "ballerina"
name = "ldap"
version = "1.0.1"
version = "1.1.0"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "test"}
]
Expand All @@ -43,9 +82,18 @@ version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.array"},
{org = "ballerina", name = "lang.error"}
]
modules = [
{org = "ballerina", packageName = "test", moduleName = "test"}
]

[[package]]
org = "ballerina"
name = "time"
version = "2.6.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

2 changes: 1 addition & 1 deletion ballerina/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ task startLdapServer() {
if (!stdOut.toString().contains("my-openldap-container")) {
println "Starting LDAP server."
exec {
commandLine 'sh', '-c', "docker compose -f $project.projectDir/tests/resources/openldap/compose.yml up -d"
commandLine 'sh', '-c', "docker compose -f $project.projectDir/tests/resources/server/compose.yml up -d"
standardOutput = stdOut
}
println stdOut.toString()
Expand Down
12 changes: 0 additions & 12 deletions ballerina/tests/resources/openldap/compose.yml

This file was deleted.

12 changes: 12 additions & 0 deletions ballerina/tests/resources/server/certs/ca.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-----BEGIN CERTIFICATE-----
MIIB1TCCAXqgAwIBAgIUBRWemdC/fCcrBTHz38nqiMyh5EkwCgYIKoZIzj0EAwIw
SDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1TYW4gRnJhbmNp
c2NvMRQwEgYDVQQDEwtleGFtcGxlLm5ldDAeFw0yMjA3MjYxMTAwMDBaFw0yNzA3
MjUxMTAwMDBaMEgxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMN
U2FuIEZyYW5jaXNjbzEUMBIGA1UEAxMLZXhhbXBsZS5uZXQwWTATBgcqhkjOPQIB
BggqhkjOPQMBBwNCAARkG6xkTUGFjSyTJCo1Ioq+ESJwuxBCvPFxz2hjYB/rOinH
rdZ/hXvNtylbzxO4KWQPxIMVAARTDE6AXqxffimno0IwQDAOBgNVHQ8BAf8EBAMC
AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU/XH2rrWqxj17DMkRe213pKgf
EkgwCgYIKoZIzj0EAwIDSQAwRgIhALfiAHDDTAMMWXBdkksB9Vwww8vY4ocnX1gY
TKVyQIhvAiEArQS/Vc+WP3dpXfoBCBatPzCuQakAu4QeWe9WH36OJq4=
-----END CERTIFICATE-----
32 changes: 32 additions & 0 deletions ballerina/tests/resources/server/certs/invalid.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-----BEGIN CERTIFICATE-----
MIIFdDCCA1wCCQDmVAk1spgkaTANBgkqhkiG9w0BAQUFADB8MQswCQYDVQQGEwJM
SzENMAsGA1UECAwEVGVzdDENMAsGA1UEBwwEVGVzdDENMAsGA1UECgwEVGVzdDEN
MAsGA1UECwwEVGVzdDESMBAGA1UEAwwJbG9jYWxob3N0MR0wGwYJKoZIhvcNAQkB
Fg50ZXN0QGxvY2FsaG9zdDAeFw0yMTA3MTUwNDU1NDVaFw0zMTA3MTMwNDU1NDVa
MHwxCzAJBgNVBAYTAkxLMQ0wCwYDVQQIDARUZXN0MQ0wCwYDVQQHDARUZXN0MQ0w
CwYDVQQKDARUZXN0MQ0wCwYDVQQLDARUZXN0MRIwEAYDVQQDDAlsb2NhbGhvc3Qx
HTAbBgkqhkiG9w0BCQEWDnRlc3RAbG9jYWxob3N0MIICIjANBgkqhkiG9w0BAQEF
AAOCAg8AMIICCgKCAgEAxBw4LW+IX7mb5H9TPoSKh+pBX5vmcBOnyFBTd1Rdli3B
AIBb6BgUTQIQWYcmGuQIt94OiyyDOujTrJmQLoeMfOLIQ/UiXWg0TmD/dn8vRJDB
AoDVKQRpeGVy88J8gaPs7siGnGxHdRBgrINpjLlC+iec8JATlescXKdx0vW2ZNht
t4vpj+QM54QofAE0X0dwi4Y+zfeMV/RFF70kCX85HoPrla2yvJywMsdc7AoS/OKZ
/i65yLr91hAaCEXkU0VDgz9sX7bqBPt/7u7R3VrvbvEmu7H7x+ozrddNIsA3PrU6
29nraxR89vTXnSxj8yUXWEMsc/j+zYNhod+8oupAXpqLW6naDQ7hpA8M+dGPiyTj
8dpbkeVbAXmJy7iwGIgUGntBVXPhOvYOFwTurxl51OPReioQ+L05sFf0nEmLL4uW
RSENAEYYexMBqCynoi3qvF4Qqq8bhbjKsq/d7U9RlCtLE/0/aVYri4Odk6vOcTGw
yWlXiGNSlEjWxx5YzlDCPYECWc5qu94RfFsotqVd1YSaWAtacLra913XHBuzkXxC
cnbAFmCQXXW3Ef4Aymf5mnLwArM376F1txkbMtj+SwTYsu9cxS/oM4tHxVMfjUHS
xAJ1q9s/yDLA9L3Ny+b2r6NxkYlCOdz7Gz7cDM3r3hKXwyknfIXHMI1rgtcYpycC
AwEAATANBgkqhkiG9w0BAQUFAAOCAgEAOPjaVDyZX/gocSS1ehHxYFLG+WOCVpaN
/k8+YY1lRQDjDS2yxOJ8AC++lV66fY7Uyqwdh4vhnN5TPY3Zx2LHQoyK9eqGRS5y
zSuyweBz8yRgEyHX6I/FGR8Pjal+60/kYNQ7IQfEvjrOTZm3ixxUVyWpcHYqNRyt
bkL2umCSRRDEAQuahV9mSuW/X0qtZcleXpGqF+tNdjxWyVWBQ1BuVHYe6NuyvY2P
ClBuoB5ci2Yl7BQYjbESZSOzxHFExjn13k2aCKTStyUu6eJgttnHSbbXbkWbfQ0I
CKVw8utNppqp8WnPyAN1DexwibfHSd3NIBBIbRE99cBGp0qlm4gaAFz/Br5WvcCB
1I0g5CVzCHVbcGUrju+XTpu5Q1XpANCPbbypvfNm7BRFpqPEKbIT8+RZggreRsDn
SsBRfyQ6We1Y32dxIH7zXkegSZ56BwoJK0NAnRY4jGiFWAfvmJGfOsPR2UvwIh+s
CobykJ1ElgV84aGfeOjyz8PZ2px0VwlQ+1EDPNCn4dAkbcnRFK4Gtr6kZzYLOCVQ
eWZDsQ/5+PZxkzCq3D6PnFEO0tKVODIuEXjPNYzqjhR0GqYCJPdCe10snIzu497H
ZBYJqdpwTbFxyHrk+9+IWtosMZhbfPuR2JDw9EPRvHCwf7gBPSO4HBatRwsUSnpb
BXtJUH8iMO4=
-----END CERTIFICATE-----
13 changes: 13 additions & 0 deletions ballerina/tests/resources/server/certs/server.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-----BEGIN CERTIFICATE-----
MIIB8zCCAZigAwIBAgIUG+X4UsMlTRYdOr5qhM5r42NMdpIwCgYIKoZIzj0EAwIw
SDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1TYW4gRnJhbmNp
c2NvMRQwEgYDVQQDEwtleGFtcGxlLm5ldDAeFw0yMjA3MjYxMTA5MDBaFw0zMjA3
MjMxMTA5MDBaMAAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASWwlOAru9lwJti
94TSukA4m+T/lmCldTDp+eDQFkuau+troON4kZ1RHxH017csGa3Vm00j5UR6O+SU
43FzAzhvo4GnMIGkMA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcD
ATAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBQRCBy4ZEhht96frjrz/UXep3oG3jAf
BgNVHSMEGDAWgBT9cfautarGPXsMyRF7bXekqB8SSDAvBgNVHREBAf8EJTAjghBs
ZGFwLmV4YW1wbGUub3Jngglsb2NhbGhvc3SHBH8AAAEwCgYIKoZIzj0EAwIDSQAw
RgIhAKZNvMbRuI6V0g5rMdHjTHc4+toPn3VjkGYMpIr34AUZAiEA3dTYcKVL0Wc+
4OZhAcfSe2PLDHL/Z7MeM6f/mrMJ8gI=
-----END CERTIFICATE-----
5 changes: 5 additions & 0 deletions ballerina/tests/resources/server/certs/server.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIFExcME6ak1+/RxHbHuDQ80y57bXRvB+YFpfXE3fwkKOoAoGCCqGSM49
AwEHoUQDQgAElsJTgK7vZcCbYveE0rpAOJvk/5ZgpXUw6fng0BZLmrvra6DjeJGd
UR8R9Ne3LBmt1ZtNI+VEejvklONxcwM4bw==
-----END EC PRIVATE KEY-----
Binary file not shown.
18 changes: 18 additions & 0 deletions ballerina/tests/resources/server/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
services:
ldap_server:
image: osixia/openldap:latest
container_name: my-openldap-container
environment:
LDAP_ORGANISATION: "My Company"
LDAP_DOMAIN: "mycompany.com"
LDAP_ADMIN_PASSWORD: "adminpassword"
LDAP_TLS_CRT_FILENAME: "server.crt"
LDAP_TLS_KEY_FILENAME: "server.key"
LDAP_TLS_CA_CRT_FILENAME: "ca.crt"
LDAP_TLS_VERIFY_CLIENT: try
ports:
- "389:389"
- "636:636"
volumes:
- ./certs:/container/service/slapd/assets/certs
command: --copy-service
57 changes: 57 additions & 0 deletions ballerina/tests/test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,60 @@ public function testSearchWithInvalidType() returns error? {
LdapResponse delete = check ldapClient->delete("CN=Test User1,dc=mycompany,dc=com");
test:assertEquals(delete.resultCode, SUCCESS);
}

@test:Config{}
public function testTlsConnection() returns error? {
ClientSecureSocket clientSecureSocket = {
cert: "tests/resources/server/certs/server.crt",
enable: true
};

Client ldapClient = check new ({
port: 636,
hostName,
password,
domainName,
clientSecureSocket}
);

ldapClient->close();
}

@test:Config{}
public function testTlsConnectionWithInvalidCert() returns error? {
ClientSecureSocket clientSecureSocket = {
cert: "tests/resources/server/certs/invalid.crt",
enable: true
};

Client|Error ldapClient = new ({
port: 636,
hostName,
password,
domainName,
clientSecureSocket}
);

test:assertTrue(ldapClient is Error);
}

@test:Config{}
public function testTlsConnectionWithTrustStore() returns error? {
ClientSecureSocket clientSecureSocket = {
cert: {
path: "tests/resources/server/certs/truststore.p12",
password: "password"
}
};

Client ldapClient = check new ({
port: 636,
hostName,
password,
domainName,
clientSecureSocket}
);

ldapClient->close();
}

18 changes: 18 additions & 0 deletions ballerina/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,35 @@
// specific language governing permissions and limitations
// under the License.

import ballerina/crypto;

# Provides a set of configurations to connect with a directory server.
#
# + hostName - The host name of the Active Directory server
# + port - The port of the Active Directory server
# + domainName - The domain name of the Active Directory
# + password - The password of the Active Directory
# + clientSecureSocket - Client secure socket configurations
public type ConnectionConfig record {|
string hostName;
int port;
string domainName;
string password;
ClientSecureSocket clientSecureSocket?;
|};


# Provides configurations for facilitating secure communication with a remote ldap server.
#
# + enable - Enable SSL validation
# + cert - Configurations associated with `crypto:TrustStore` or single certificate file that the client trusts
# + verifyHostName - Enable/disable host name verification
# + tlsVersions - The TLS versions to be used
public type ClientSecureSocket record {|
boolean enable = true;
crypto:TrustStore|string cert?;
boolean verifyHostName = true;
string[] tlsVersions = [];
|};

# LDAP response type.
Expand Down
2 changes: 1 addition & 1 deletion build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export=["ldap"]
keywords = ["ldap"]
repository = "https://github.com/ballerina-platform/module-ballerina-ldap"
license = ["Apache-2.0"]
distribution = "2201.8.0"
distribution = "2201.9.0"

[platform.java21]
graalvmCompatible = true
Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ plugins {
id "net.researchgate.release"
}

ext.stdlibCryptoVersion = project.stdlibCryptoVersion

description = 'Ballerina - LDAP'

allprojects {
Expand Down Expand Up @@ -74,8 +76,11 @@ subprojects {
jbalTools ("org.ballerinalang:jballerina-tools:${ballerinaLangVersion}") {
transitive = false
}

/* Standard libraries */
ballerinaStdLibs "io.ballerina.stdlib:io-ballerina:${stdlibIoVersion}"
ballerinaStdLibs "io.ballerina.stdlib:crypto-ballerina:${stdlibCryptoVersion}"
ballerinaStdLibs "io.ballerina.stdlib:time-ballerina:${stdlibTimeVersion}"
}
}

Expand Down
9 changes: 6 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.caching=true
group=io.ballerina.lib
version=1.0.2-SNAPSHOT
ballerinaLangVersion=2201.10.0-20241011-161100-51978649
version=1.1.0-SNAPSHOT
ballerinaLangVersion=2201.11.0-20241112-214900-6b80ab87

checkstylePluginVersion=10.12.0
spotbugsPluginVersion=6.0.18
Expand All @@ -10,5 +10,8 @@ downloadPluginVersion=5.4.0
releasePluginVersion=2.8.0
ballerinaGradlePluginVersion=2.2.4

stdlibIoVersion=1.6.2-20240928-084100-656404f
unboundIdLdapVersion=7.0.0

stdlibIoVersion=1.6.2-20240928-084100-656404f
stdlibCryptoVersion=2.7.3-20241113-081400-d015a39
stdlibTimeVersion=2.6.0-20241113-073800-201b904
Loading
Loading