Skip to content

Commit

Permalink
Merge pull request #70 from warunalakshitha/updateLang
Browse files Browse the repository at this point in the history
Migrate to new Runtime APIs
  • Loading branch information
warunalakshitha authored Nov 13, 2024
2 parents 90d3e1f + ea581b7 commit d6cc91d
Show file tree
Hide file tree
Showing 19 changed files with 432 additions and 46 deletions.
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
HTAbBgkqhkiG9w0BCQEWDnRlc3RAbG9jYWxob3N0MIICIj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nPyAN1DexwibfHSd3NIBBIbRE99cBGp0qlm4gaAFz/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

0 comments on commit d6cc91d

Please sign in to comment.