|
Spring LDAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.ldap.support.LdapUtils
public final class LdapUtils
Generic utility methods for working with LDAP. Mainly for internal use within the framework, but also useful for custom code.
Method Summary | |
---|---|
static void |
closeContext(DirContext context)
Close the given JNDI Context and ignore any thrown exception. |
static void |
collectAttributeValues(Attributes attributes,
String name,
Collection collection)
Collect all the values of a the specified attribute from the supplied Attributes. |
static String |
convertBinarySidToString(byte[] sid)
Converts a binary SID to its String representation, according to the algorithm described here. |
static String |
convertCompositeNameToString(CompositeName compositeName)
Converts a CompositeName to a String in a way that avoids escaping problems, such as the dreaded "triple backslash" problem. |
static NamingException |
convertLdapException(NamingException ex)
Convert the specified checked NamingException to a Spring LDAP runtime
NamingException
equivalent. |
static byte[] |
convertStringSidToBinary(String string)
Converts a String SID to its binary representation, according to the algorithm described here. |
static Class |
getActualTargetClass(DirContext context)
Get the actual class of the supplied DirContext instance; LdapContext or DirContext. |
static void |
iterateAttributeValues(Attribute attribute,
AttributeValueCallbackHandler callbackHandler)
Iterate through all the values of the specified Attribute calling back to the specified callbackHandler. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void closeContext(DirContext context)
finally
blocks in JNDI code.
context
- the JNDI Context to close (may be null
)public static NamingException convertLdapException(NamingException ex)
NamingException
to a Spring LDAP runtime
NamingException
equivalent.
ex
- the original checked NamingException to convert
public static Class getActualTargetClass(DirContext context)
context
- the DirContext instance to check.
public static void collectAttributeValues(Attributes attributes, String name, Collection collection)
attributes
- The Attributes; not null
.name
- The name of the Attribute to get values for.collection
- the collection to collect the values in.
NoSuchAttributeException
- if no attribute with the specified name
exists.public static void iterateAttributeValues(Attribute attribute, AttributeValueCallbackHandler callbackHandler)
attribute
- the Attribute to work with; not null
.callbackHandler
- the callbackHandler; not null
.public static String convertCompositeNameToString(CompositeName compositeName)
compositeName
- The CompositeName to convert
name
public static String convertBinarySidToString(byte[] sid)
If you have a SID like S-a-b-c-d-e-f-g-... Then the bytes are a (revision) N (number of dashes minus two) bbbbbb (six bytes of "b" treated as a 48-bit number in big-endian format) cccc (four bytes of "c" treated as a 32-bit number in little-endian format) dddd (four bytes of "d" treated as a 32-bit number in little-endian format) eeee (four bytes of "e" treated as a 32-bit number in little-endian format) ffff (four bytes of "f" treated as a 32-bit number in little-endian format) etc. So for example, if your SID is S-1-5-21-2127521184-1604012920-1887927527-72713, then your raw hex SID is 010500000000000515000000A065CF7E784B9B5FE77C8770091C0100 This breaks down as follows: 01 S-1 05 (seven dashes, seven minus two = 5) 000000000005 (5 = 0x000000000005, big-endian) 15000000 (21 = 0x00000015, little-endian) A065CF7E (2127521184 = 0x7ECF65A0, little-endian) 784B9B5F (1604012920 = 0x5F9B4B78, little-endian) E77C8770 (1887927527 = 0X70877CE7, little-endian) 091C0100 (72713 = 0x00011c09, little-endian) S-1- version number (SID_REVISION) -5- SECURITY_NT_AUTHORITY -21- SECURITY_NT_NON_UNIQUE -...-...-...- these identify the machine that issued the SID 72713 unique user id on the machine
sid
- binary SID in byte array format
public static byte[] convertStringSidToBinary(String string)
string
- SID in readable format
convertBinarySidToString(byte[])
|
Spring LDAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |