1 17 package org.alfresco.filesys.smb.dcerpc.server; 18 19 import java.io.IOException ; 20 21 import org.alfresco.filesys.server.config.ServerConfiguration; 22 import org.alfresco.filesys.smb.Dialect; 23 import org.alfresco.filesys.smb.SMBStatus; 24 import org.alfresco.filesys.smb.dcerpc.DCEBuffer; 25 import org.alfresco.filesys.smb.dcerpc.DCEBufferException; 26 import org.alfresco.filesys.smb.dcerpc.Wkssvc; 27 import org.alfresco.filesys.smb.dcerpc.info.ServerInfo; 28 import org.alfresco.filesys.smb.dcerpc.info.WorkstationInfo; 29 import org.alfresco.filesys.smb.server.SMBServer; 30 import org.alfresco.filesys.smb.server.SMBSrvException; 31 import org.alfresco.filesys.smb.server.SMBSrvSession; 32 import org.apache.commons.logging.Log; 33 import org.apache.commons.logging.LogFactory; 34 35 38 public class WkssvcDCEHandler implements DCEHandler 39 { 40 41 43 private static final Log logger = LogFactory.getLog("org.alfresco.smb.protocol"); 44 45 54 public void processRequest(SMBSrvSession sess, DCEBuffer inBuf, DCEPipeFile pipeFile) throws IOException , 55 SMBSrvException 56 { 57 58 60 int opNum = inBuf.getHeaderValue(DCEBuffer.HDR_OPCODE); 61 try 62 { 63 inBuf.skipBytes(DCEBuffer.OPERATIONDATA); 64 } 65 catch (DCEBufferException ex) 66 { 67 } 68 69 71 if (logger.isDebugEnabled() && sess.hasDebug(SMBSrvSession.DBG_DCERPC)) 72 logger.debug("DCE/RPC WksSvc request=" + Wkssvc.getOpcodeName(opNum)); 73 74 76 DCEBuffer outBuf = new DCEBuffer(); 77 outBuf.putResponseHeader(inBuf.getHeaderValue(DCEBuffer.HDR_CALLID), 0); 78 79 81 boolean processed = false; 82 83 switch (opNum) 84 { 85 86 88 case Wkssvc.NetWkstaGetInfo: 89 processed = netWkstaGetInfo(sess, inBuf, outBuf); 90 break; 91 92 94 default: 95 break; 96 } 97 98 100 if (processed == false) 101 { 102 sess.sendErrorResponseSMB(SMBStatus.SRVNotSupported, SMBStatus.ErrSrv); 103 return; 104 } 105 106 108 outBuf.setHeaderValue(DCEBuffer.HDR_ALLOCHINT, outBuf.getLength()); 109 110 112 pipeFile.setBufferedData(outBuf); 113 } 114 115 123 protected final boolean netWkstaGetInfo(SMBSrvSession sess, DCEBuffer inBuf, DCEBuffer outBuf) 124 { 125 126 128 String srvName = null; 129 int infoLevel = 0; 130 131 try 132 { 133 inBuf.skipPointer(); 134 srvName = inBuf.getString(DCEBuffer.ALIGN_INT); 135 infoLevel = inBuf.getInt(); 136 } 137 catch (DCEBufferException ex) 138 { 139 return false; 140 } 141 142 144 if (logger.isDebugEnabled() && sess.hasDebug(SMBSrvSession.DBG_DCERPC)) 145 logger.debug("NetWkstaGetInfo srvName=" + srvName + ", infoLevel=" + infoLevel); 146 147 149 WorkstationInfo wkstaInfo = new WorkstationInfo(infoLevel); 150 151 SMBServer srv = sess.getSMBServer(); 152 wkstaInfo.setWorkstationName(srv.getServerName()); 153 wkstaInfo.setDomain(srv.getConfiguration().getDomainName()); 154 155 157 ServerConfiguration srvConfig = sess.getServer().getConfiguration(); 158 if (srvConfig != null && srvConfig.getEnabledDialects().hasDialect(Dialect.NT) == true) 159 { 160 wkstaInfo.setPlatformId(ServerInfo.PLATFORM_NT); 161 wkstaInfo.setVersion(5, 1); 162 } 163 else 164 { 165 wkstaInfo.setPlatformId(ServerInfo.PLATFORM_OS2); 166 wkstaInfo.setVersion(4, 0); 167 } 168 169 171 wkstaInfo.writeObject(outBuf, outBuf); 172 outBuf.putInt(0); 173 174 176 return true; 177 } 178 } 179 | Popular Tags |