1 19 20 package jcifs.dcerpc; 21 22 import java.util.HashMap ; 23 import java.util.Iterator ; 24 25 import jcifs.dcerpc.msrpc.*; 26 27 class DcerpcBinding { 28 29 private static HashMap INTERFACES; 30 31 static { 32 INTERFACES = new HashMap (); 33 INTERFACES.put("srvsvc", srvsvc.getSyntax()); 34 INTERFACES.put("lsarpc", lsarpc.getSyntax()); 35 INTERFACES.put("samr", samr.getSyntax()); 36 } 37 38 String proto; 39 String server; 40 String endpoint = null; 41 HashMap options = null; 42 UUID uuid = null; 43 int major; 44 int minor; 45 46 DcerpcBinding(String proto, String server) { 47 this.proto = proto; 48 this.server = server; 49 } 50 51 void setOption(String key, Object val) throws DcerpcException { 52 if (key.equals("endpoint")) { 53 endpoint = val.toString().toLowerCase(); 54 if (endpoint.startsWith("\\pipe\\")) { 55 String iface = (String )INTERFACES.get(endpoint.substring(6)); 56 if (iface != null) { 57 int c, p; 58 c = iface.indexOf(':'); 59 p = iface.indexOf('.', c + 1); 60 uuid = new UUID(iface.substring(0, c)); 61 major = Integer.parseInt(iface.substring(c + 1, p)); 62 minor = Integer.parseInt(iface.substring(p + 1)); 63 return; 64 } 65 } 66 throw new DcerpcException("Bad endpoint: " + endpoint); 67 } 68 if (options == null) 69 options = new HashMap (); 70 options.put(key, val); 71 } 72 Object getOption(String key) { 73 if (key.equals("endpoint")) 74 return endpoint; 75 return options.get(key); 76 } 77 78 public String toString() { 79 String ret = proto + ":" + server + "[" + endpoint; 80 if (options != null) { 81 Iterator iter = options.keySet().iterator(); 82 while (iter.hasNext()) { 83 Object key = iter.next(); 84 Object val = options.get(key); 85 ret += "," + key + "=" + val; 86 } 87 } 88 ret += "]"; 89 return ret; 90 } 91 } 92 | Popular Tags |