blob: 87ff89071a43d13447a1cf5149d8462a31bbaa3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package org.apache.tuscany.das.ldap.util;
import org.eclipse.emf.common.util.URI;
/**
* The Class XSDNamespaceToInitialContextTransformer.
*
* Takes the XSD Namespace used by the DataObjects
* and transforms it into the DN of the initial context
* used for the root DataObject entry.
*/
public class XSDNamespaceToInitialContextTransformer
{
/**
* Transform.
*
* @param namespaceURIString the namespace URI string
*
* @return the DN of the initial context
*
* @throws Exception the exception
*/
public static String transform(String namespaceURIString) throws Exception
{
URI namespaceURI = URI.createURI(namespaceURIString);
String authority = namespaceURI.authority();
String path = namespaceURI.path();
String[] authorityTokens = authority.split( "[.]" );
String[] pathTokens = path.split("[/]");
String DN = new String("");
for (int i = (pathTokens.length-1); i > 0; i--)
{
DN = DN + "cn=" + pathTokens[i] + ", ";
}
for (int i = 0; i <= (authorityTokens.length-2); i++)
{
DN = DN + "cn=" + authorityTokens[i] + ", ";
}
DN = DN + "ou=" + authorityTokens[authorityTokens.length-1];
return DN;
}
}
|