1 20 21 package org.apache.directory.ldapstudio.browser.core.internal.model; 22 23 24 import java.net.URL ; 25 import java.util.Arrays ; 26 import java.util.Properties ; 27 28 import org.apache.directory.ldapstudio.browser.core.model.DN; 29 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 30 import org.apache.directory.ldapstudio.browser.core.model.IEntry; 31 import org.apache.directory.ldapstudio.browser.core.model.IRootDSE; 32 import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException; 33 34 35 public final class RootDSE extends BaseDNEntry implements IRootDSE 36 { 37 38 private static final long serialVersionUID = -8445018787232919754L; 39 40 public static Properties oidMap = new Properties (); 41 static 42 { 43 44 try 45 { 46 URL url = RootDSE.class.getClassLoader().getResource( 47 "org/apache/directory/ldapstudio/browser/core/model/ldap_oids.txt" ); if(url != null) 49 { 50 oidMap.load( url.openStream() ); 51 } 52 } 53 catch ( Exception e ) 54 { 55 e.printStackTrace(); 56 } 57 } 58 59 60 protected RootDSE() 61 { 62 } 63 64 65 public RootDSE( IConnection connection ) throws ModelModificationException 66 { 67 super( new DN(), connection ); 68 } 69 70 71 public IEntry getParententry() 72 { 73 return null; 74 } 75 76 77 public String [] getSupportedExtensions() 78 { 79 if ( getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDEXTENSION ) != null ) 80 { 81 return get( getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDEXTENSION ).getStringValues() ); 82 } 83 else 84 { 85 return new String [0]; 86 } 87 } 88 89 90 public String [] getSupportedControls() 91 { 92 if ( getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDCONTROL ) != null ) 93 { 94 return get( getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDCONTROL ).getStringValues() ); 95 } 96 else 97 { 98 return new String [0]; 99 } 100 } 101 102 103 public String [] getSupportedFeatures() 104 { 105 if ( getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDFEATURES ) != null ) 106 { 107 return get( getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDFEATURES ).getStringValues() ); 108 } 109 else 110 { 111 return new String [0]; 112 } 113 } 114 115 116 private String [] get( String [] a ) 117 { 118 for ( int i = 0; i < a.length; i++ ) 119 { 120 if ( oidMap.containsKey( a[i] ) ) 121 { 122 String s = ( String ) oidMap.get( a[i] ); 123 a[i] = s; 124 if ( s.matches( "^\".*\"" ) ) { a[i] = s.substring( 1, s.indexOf( "\"", 1 ) ); } 127 } 128 } 129 Arrays.sort( a ); 130 return a; 131 } 132 133 } 134 | Popular Tags |