Lines 1340-1346
Link Here
|
1340 |
|
1340 |
|
1341 |
// Set up parameters for an appropriate search |
1341 |
// Set up parameters for an appropriate search |
1342 |
String filter = roleFormat.format(new String[] { dn, username }); |
1342 |
String filter = roleFormat.format(new String[] { dn, username }); |
1343 |
filter = doRFC2254Encoding(filter); |
|
|
1344 |
SearchControls controls = new SearchControls(); |
1343 |
SearchControls controls = new SearchControls(); |
1345 |
if (roleSubtree) |
1344 |
if (roleSubtree) |
1346 |
controls.setSearchScope(SearchControls.SUBTREE_SCOPE); |
1345 |
controls.setSearchScope(SearchControls.SUBTREE_SCOPE); |
Lines 1672-1721
Link Here
|
1672 |
return null; |
1671 |
return null; |
1673 |
|
1672 |
|
1674 |
} |
1673 |
} |
1675 |
|
|
|
1676 |
/** |
1677 |
* Given an LDAP search string, returns the string with certain characters |
1678 |
* escaped according to RFC 2254 guidelines. |
1679 |
* The character mapping is as follows: |
1680 |
* char -> Replacement |
1681 |
* --------------------------- |
1682 |
* * -> \2a |
1683 |
* ( -> \28 |
1684 |
* ) -> \29 |
1685 |
* \ -> \5c |
1686 |
* \0 -> \00 |
1687 |
* @param inString string to escape according to RFC 2254 guidelines |
1688 |
* @return |
1689 |
*/ |
1690 |
public String doRFC2254Encoding(String inString) { |
1691 |
StringBuffer buf = new StringBuffer(inString.length()); |
1692 |
for (int i = 0; i < inString.length(); i++) |
1693 |
{ |
1694 |
char theChar =inString.charAt(i); |
1695 |
switch (theChar) |
1696 |
{ |
1697 |
case '\\': |
1698 |
buf.append("\\5c"); |
1699 |
break; |
1700 |
case '*': |
1701 |
buf.append("\\2a"); |
1702 |
break; |
1703 |
case '(': |
1704 |
buf.append("\\28"); |
1705 |
break; |
1706 |
case ')': |
1707 |
buf.append("\\29"); |
1708 |
break; |
1709 |
case '\0': |
1710 |
buf.append("\\00"); |
1711 |
break; |
1712 |
default: |
1713 |
buf.append(theChar); |
1714 |
break; |
1715 |
} |
1716 |
} |
1717 |
return buf.toString(); |
1718 |
} |
1719 |
} |
1674 |
} |
1720 |
|
1675 |
|
1721 |
// ------------------------------------------------------ Private Classes |
1676 |
// ------------------------------------------------------ Private Classes |