Skip to content

Commit 06d4a28

Browse files
author
almu
committed
Initial commit
0 parents  commit 06d4a28

107 files changed

Lines changed: 14280 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

nbactions.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<actions>
3+
<action>
4+
<actionName>run</actionName>
5+
<packagings>
6+
<packaging>jar</packaging>
7+
</packagings>
8+
<goals>
9+
<goal>process-classes</goal>
10+
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
11+
</goals>
12+
<properties>
13+
<exec.args>-classpath %classpath se.idsecurity.jldap.edirectoryjldapext.sample.SampleEdirTransaction cn=adminadmin,o=system n0v3ll4ever</exec.args>
14+
<exec.executable>java</exec.executable>
15+
</properties>
16+
</action>
17+
<action>
18+
<actionName>debug</actionName>
19+
<packagings>
20+
<packaging>jar</packaging>
21+
</packagings>
22+
<goals>
23+
<goal>process-classes</goal>
24+
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
25+
</goals>
26+
<properties>
27+
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath se.idsecurity.jldap.edirectoryjldapext.sample.SampleEdirTransaction cn=adminadmin,o=system n0v3ll4ever</exec.args>
28+
<exec.executable>java</exec.executable>
29+
<jpda.listen>true</jpda.listen>
30+
</properties>
31+
</action>
32+
<action>
33+
<actionName>profile</actionName>
34+
<packagings>
35+
<packaging>jar</packaging>
36+
</packagings>
37+
<goals>
38+
<goal>process-classes</goal>
39+
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
40+
</goals>
41+
<properties>
42+
<exec.args>-classpath %classpath se.idsecurity.jldap.edirectoryjldapext.sample.SampleEdirTransaction cn=adminadmin,o=system n0v3ll4ever</exec.args>
43+
<exec.executable>java</exec.executable>
44+
</properties>
45+
</action>
46+
</actions>

pom.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>se.idsecurity</groupId>
5+
<artifactId>eDirectoryJLdapExt</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
<maven.compiler.source>1.8</maven.compiler.source>
11+
<maven.compiler.target>1.8</maven.compiler.target>
12+
</properties>
13+
<name>eDirectoryJLdapExt</name>
14+
<dependencies>
15+
<dependency>
16+
<groupId>com.novell.ldap</groupId>
17+
<artifactId>jldap</artifactId>
18+
<version>2009-10-07</version>
19+
</dependency>
20+
</dependencies>
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.apache.maven.plugins</groupId>
25+
<artifactId>maven-javadoc-plugin</artifactId>
26+
<version>3.0.0-M1</version>
27+
</plugin>
28+
</plugins>
29+
</build>
30+
</project>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* MIT License
3+
4+
Copyright (c) [2018] [almu]
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
package se.idsecurity.jldap.edirectoryjldapext.common;
25+
26+
/**
27+
* OID's used for LDAP transactions
28+
*/
29+
public enum OID {
30+
31+
CreateGroupingRequest("2.16.840.1.113719.1.27.103.1"),
32+
CreateGroupingResponse("2.16.840.1.113719.1.27.103.1"),
33+
EndGroupingRequest("2.16.840.1.113719.1.27.103.2"),
34+
EndGroupingResponse("2.16.840.1.113719.1.27.103.2"),
35+
GroupingControl("2.16.840.1.113719.1.27.103.7");
36+
37+
private final String oid;
38+
39+
OID(String oid) {
40+
this.oid = oid;
41+
}
42+
43+
/**
44+
* Get the OID for the LDAP extension/control
45+
*
46+
* @return
47+
*/
48+
public String getOID() {
49+
return oid;
50+
}
51+
52+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/**
2+
* MIT License
3+
4+
Copyright (c) [2018] [almu]
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
package se.idsecurity.jldap.edirectoryjldapext.controls;
25+
26+
import com.novell.ldap.LDAPControl;
27+
import com.novell.ldap.asn1.ASN1Integer;
28+
import com.novell.ldap.asn1.ASN1Sequence;
29+
import com.novell.ldap.asn1.LBEREncoder;
30+
import java.io.ByteArrayOutputStream;
31+
import java.io.IOException;
32+
import se.idsecurity.jldap.edirectoryjldapext.common.OID;
33+
34+
/**
35+
* GroupingControl ( 2.16.840.1.113719.1.27.103.7 ) - This is used to indicate
36+
* association of an operation to a grouping via the groupCookie which is the
37+
* value carried by this control.
38+
*
39+
* @see
40+
* <a href="https://www.netiq.com/documentation/edirectory-9/edir_admin/data/b4r36pg.html">Documentation</a>
41+
*
42+
*/
43+
public final class GroupingControl extends LDAPControl {
44+
45+
private final LBEREncoder encoder = new LBEREncoder();
46+
47+
private final ByteArrayOutputStream encodedData = new ByteArrayOutputStream();
48+
49+
private final ASN1Sequence groupingControlValue = new ASN1Sequence();
50+
51+
/**
52+
* Creates a new GroupingControl using the cookie received in a
53+
* CreateGroupingResponse in response to CreateGroupingRequest
54+
*
55+
* @param groupCookie The cookie from the CreateGroupingResponse
56+
* @param critial True if the LDAP operation should be discarded if the
57+
* control is not supported. False if the operation can be processed without
58+
* the control.
59+
*/
60+
public GroupingControl(ASN1Integer groupCookie, boolean critial) {
61+
super(OID.GroupingControl.getOID(), critial, null);
62+
63+
groupingControlValue.add(groupCookie);
64+
65+
try {
66+
groupingControlValue.encode(encoder, encodedData);
67+
setValue(encodedData.toByteArray());
68+
} catch (IOException e) {
69+
//Shouldn't occur unless there is a serious failure
70+
throw new AssertionError("Unable to create instance of GroupingControl", e);
71+
}
72+
73+
}
74+
75+
/**
76+
* Get the control as a byte array
77+
*
78+
* @return The control with the group cookie as encoded byte array
79+
*/
80+
public byte[] getEncoded() {
81+
return encodedData.toByteArray();
82+
}
83+
84+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* MIT License
3+
4+
Copyright (c) [2018] [almu]
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
package se.idsecurity.jldap.edirectoryjldapext.extensions;
25+
26+
import com.novell.ldap.LDAPExtendedOperation;
27+
import com.novell.ldap.LDAPExtendedResponse;
28+
import com.novell.ldap.asn1.ASN1OctetString;
29+
import com.novell.ldap.asn1.ASN1Sequence;
30+
import com.novell.ldap.asn1.LBEREncoder;
31+
import java.io.ByteArrayOutputStream;
32+
import java.io.IOException;
33+
import se.idsecurity.jldap.edirectoryjldapext.common.OID;
34+
35+
/**
36+
* CreateGroupingRequest ( 2.16.840.1.113719.1.27.103.1 ) – This is LDAP
37+
* extended operation which allows grouping of related operations. The extended
38+
* operation carries a value – createGroupType which identifies the type of
39+
* grouping requested. For LDAP transactions, the grouping type is
40+
* transactionGroupingType. ( 2.16.840.1.113719.1.27.103.7)
41+
*
42+
* @see
43+
* <a href="https://www.netiq.com/documentation/edirectory-9/edir_admin/data/b4r36pg.html">Documentation</a>
44+
*
45+
*/
46+
public final class CreateGroupingRequest extends LDAPExtendedOperation {
47+
48+
private final ByteArrayOutputStream encodedData = new ByteArrayOutputStream();
49+
private final LBEREncoder encoder = new LBEREncoder();
50+
private final ASN1OctetString createGroupType = new ASN1OctetString(OID.GroupingControl.getOID());
51+
private final ASN1Sequence sequence = new ASN1Sequence(1);
52+
53+
/**
54+
* Creates an extended operations object for retrieving a group cookie for
55+
* use with the LDAP transactions GroupingControl
56+
*/
57+
public CreateGroupingRequest() {
58+
super(OID.CreateGroupingRequest.getOID(), null);
59+
60+
LDAPExtendedResponse.register(OID.CreateGroupingResponse.getOID(), CreateGroupingResponse.class);
61+
62+
try {
63+
sequence.add(createGroupType);
64+
sequence.encode(encoder, encodedData);
65+
} catch (IOException e) {
66+
//Shouldn't occur unless there is a serious failure
67+
throw new AssertionError("Could not create instance of CreateGroupingRequest", e);
68+
}
69+
setValue(encodedData.toByteArray());
70+
}
71+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
* MIT License
3+
4+
Copyright (c) [2018] [almu]
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
package se.idsecurity.jldap.edirectoryjldapext.extensions;
25+
26+
import se.idsecurity.jldap.edirectoryjldapext.controls.GroupingControl;
27+
import com.novell.ldap.LDAPExtendedResponse;
28+
import com.novell.ldap.asn1.ASN1Integer;
29+
import com.novell.ldap.asn1.ASN1Object;
30+
import com.novell.ldap.asn1.ASN1Sequence;
31+
import com.novell.ldap.asn1.LBERDecoder;
32+
import com.novell.ldap.rfc2251.RfcLDAPMessage;
33+
34+
/**
35+
* CreateGroupingResponse ( 2.16.840.1.113719.1.27.103.1 ) – This is the
36+
* response of the LDAP server to the createGroupingRequest and contains 2
37+
* response fields – groupCookie and an optional createGroupValue.
38+
*
39+
* @see
40+
* <a href="https://www.netiq.com/documentation/edirectory-9/edir_admin/data/b4r36pg.html">Documentation</a>
41+
*
42+
*/
43+
public final class CreateGroupingResponse extends LDAPExtendedResponse {
44+
45+
private final ASN1Integer groupCookie;
46+
47+
/**
48+
* Creates an response containing the GroupingControl needed for performing
49+
* LDAP operations
50+
*
51+
* @param rfcMessage
52+
*/
53+
public CreateGroupingResponse(RfcLDAPMessage rfcMessage) {
54+
super(rfcMessage);
55+
56+
byte[] value = getValue();
57+
LBERDecoder dec = new LBERDecoder();
58+
ASN1Sequence decode = (ASN1Sequence) dec.decode(value);
59+
ASN1Object first = decode.get(0);
60+
groupCookie = (ASN1Integer) first;
61+
62+
}
63+
64+
/**
65+
* Get the group cookie
66+
*
67+
* @return The group cookie
68+
*/
69+
public ASN1Integer getGroupCookie() {
70+
return groupCookie;
71+
}
72+
73+
/**
74+
* Get the GroupingControl for use with the LDAPConstraints object
75+
*
76+
* @param critical True if the LDAP operation should be discarded if the
77+
* control is not supported. False if the operation can be processed without
78+
* the control.
79+
* @return The GroupingControl containing the group cookie needed for
80+
* transactions.
81+
*/
82+
public GroupingControl getControl(boolean critical) {
83+
GroupingControl gc = new GroupingControl(groupCookie, critical);
84+
return gc;
85+
}
86+
87+
}

0 commit comments

Comments
 (0)