public MSExcel2_Test(String address, String[] args) throws JIException, UnknownHostException { session = JISession.createSession(args[1],args[2],args[3]); session.useSessionSecurity(true); comServer = new JIComServer(JIProgId.valueOf("Excel.Application"),address,session); }
public MSWMI(String address, String[] args) throws JIException, UnknownHostException { this.address = address; session = JISession.createSession(args[1],args[2],args[3]); session.useSessionSecurity(true); session.setGlobalSocketTimeout(5000); comStub = new JIComServer(JIProgId.valueOf("WbemScripting.SWbemLocator"),address,session); IJIComObject unknown = comStub.createInstance(); comObject = (IJIComObject)unknown.queryInterface("76A6415B-CB41-11d1-8B02-00600806D9B6");//ISWbemLocator //This will obtain the dispatch interface dispatch = (IJIDispatch)JIObjectFactory.narrowObject(comObject.queryInterface(IJIDispatch.IID)); }
@Override protected void finalize () { try { destroySession ( this ); } catch ( final JIException e ) { logger.warn ( "Exception in finalize when destroying session", e ); } }
/** Creates a new session using credentials of the <code>session</code>parameter. The new session is not yet attached to a * COM server. * * @param session * @return * @see JIComServer#JIComServer(JIClsid, JISession) * @see JIComServer#JIComServer(JIProgId, JISession) */ public static JISession createSession(JISession session) { JISession newSession = createSession(session.getDomain(),session.getUserName(),session.getPassword()); newSession.authInfo = session.authInfo; return newSession; }
private JIStruct prepareForReleaseRef ( final String IPID, final int numInstancesfirsttime ) throws JIException { final JIStruct remInterface = new JIStruct (); remInterface.addMember ( new rpc.core.UUID ( IPID ) ); remInterface.addMember ( new Integer ( numInstancesfirsttime + 5 ) ); // numInstancesfirsttime of the original and 5 for the addRef done later on. remInterface.addMember ( new Integer ( 0 ) );//private refs = 0 logger.warn ( "prepareForReleaseRef: Releasing numInstancesfirsttime + 5 references of IPID: {} session: {} , numInstancesfirsttime is {}", new Object[] { IPID, getSessionIdentifier (), numInstancesfirsttime } ); debug_delIpids ( IPID, numInstancesfirsttime + 5 ); return remInterface; }
newsession = JISession.createSession ( session ); newsession.setGlobalSocketTimeout ( session.getGlobalSocketTimeout () ); newsession.useSessionSecurity ( session.isSessionSecurityEnabled () ); newsession.useNTLMv2 ( session.isNTLMv2Enabled () ); final JIComServer comServer = new JIComServer ( newsession, ptr, null ); retval = comServer.getInstance ();
if (session.getStub() != null) super.getProperties().setProperty("rpc.security.username", session.getUserName()); super.getProperties().setProperty("rpc.security.password", session.getPassword()); super.getProperties().setProperty("rpc.ntlm.domain", session.getDomain()); super.getProperties().setProperty("rpc.socketTimeout", new Integer(session.getGlobalSocketTimeout()).toString()); if (session.isNTLMv2Enabled()) if (session.isSSOEnabled()) this.session.setTargetServer(getAddress().substring(getAddress().indexOf(":") + 1,getAddress().indexOf("["))); oxidResolver = new JIOxidResolver(((JIStdObjRef)interfacePointer.getObjectReference(JIInterfacePointer.OBJREF_STANDARD)).getOxid()); try { if (session.isSessionSecurityEnabled()) remunknownIPID = oxidResolver.getIPID(); interfacePtrCtor = interfacePointer; this.session.setStub(this); this.session.setStub2(new JIRemUnknownServer(session, remunknownIPID, getAddress()));
super.getProperties ().setProperty ( "rpc.socketTimeout", new Integer ( session.getGlobalSocketTimeout () ).toString () ); super.setAddress ( address ); if ( session.isNTLMv2Enabled () ) if ( session.isSSOEnabled () ) super.getProperties ().setProperty ( "rpc.security.username", session.getUserName () ); super.getProperties ().setProperty ( "rpc.security.password", session.getPassword () ); super.getProperties ().setProperty ( "rpc.ntlm.domain", session.getDomain () ); this.session.setTargetServer ( address.substring ( address.indexOf ( ":" ) + 1, address.indexOf ( "[" ) ) ); try if ( session.isSSOEnabled () ) registry = JIWinRegFactory.getSingleTon ().getWinreg ( session.getTargetServer (), true ); registry = JIWinRegFactory.getSingleTon ().getWinreg ( new JIDefaultAuthInfoImpl ( session.getDomain (), session.getUserName (), session.getPassword () ), session.getTargetServer (), true ); this.session.setStub ( this ); this.session.setStub2 ( new JIRemUnknownServer ( session, this.remunknownIPID, getAddress () ) );
newsession = JISession.createSession(session); newsession.setGlobalSocketTimeout(session.getGlobalSocketTimeout()); newsession.useSessionSecurity(session.isSessionSecurityEnabled()); JIComServer comServer = new JIComServer(newsession,ptr,null); retval = comServer.getInstance();
try { m_Session = JISession.createSession(domain, username, password); m_Session.useSessionSecurity(true); m_Session.setGlobalSocketTimeout(5000); if (m_Session != null) { try { JISession.destroySession(m_Session); } catch (JIException e1) { LOG.error("Failed to destroy session after incomplete connect with host '{}'.", m_Address, e1); if (m_Session != null) { try { JISession.destroySession(m_Session); } catch (JIException e1) { LOG.error("Failed to destroy session after unknown host '{}'.", m_Address, e1);
super.setTransportFactory(JIComTransportFactory.getSingleTon()); super.setProperties(new Properties(defaults)); super.getProperties().setProperty("rpc.socketTimeout", new Integer(session.getGlobalSocketTimeout()).toString()); if (session.isNTLMv2Enabled()) if (session.isSSOEnabled()) super.getProperties().setProperty("rpc.security.username", session.getUserName()); super.getProperties().setProperty("rpc.security.password", session.getPassword()); super.getProperties().setProperty("rpc.ntlm.domain", session.getDomain()); if (session.isSessionSecurityEnabled()) this.session.setStub2(this);
super.getProperties().setProperty("rpc.security.username", session.getUserName()); super.getProperties().setProperty("rpc.security.password", session.getPassword()); super.getProperties().setProperty("rpc.ntlm.domain", session.getDomain()); super.getProperties().setProperty("rpc.socketTimeout", new Integer(session.getGlobalSocketTimeout()).toString()); super.setAddress(address); this.session.setTargetServer(address.substring(address.indexOf(":") + 1,address.indexOf("["))); try{ init(); registry = JIWinRegFactory.getSingleTon().getWinreg(new JIDefaultAuthInfoImpl(session.getDomain(),session.getUserName(),session.getPassword()),session.getTargetServer(),true); JIPolicyHandle hkcr = registry.winreg_OpenHKCR(); JIPolicyHandle key = registry.winreg_CreateKey(hkcr,"CLSID\\{" + this.clsid + "}",IJIWinReg.REG_OPTION_NON_VOLATILE,IJIWinReg.KEY_ALL_ACCESS ); this.session.setStub(this);
@Override public void afterDisconnect(SlaveComputer computer, TaskListener listener) { try { JIDefaultAuthInfoImpl auth = createAuth(); JISession session = JISession.createSession(auth); session.setGlobalSocketTimeout(60000); SWbemServices services = WMI.connect(session, computer.getName()); Win32Service slaveService = services.getService("hudsonslave"); if(slaveService!=null) { listener.getLogger().println(Messages.ManagedWindowsServiceLauncher_StoppingService()); slaveService.StopService(); } } catch (UnknownHostException e) { e.printStackTrace(listener.error(e.getMessage())); } catch (JIException e) { e.printStackTrace(listener.error(e.getMessage())); } }
server = session.getTargetServer(); if (session.isSSOEnabled()) winreg = JIWinRegFactory.getSingleTon().getWinreg(new JIDefaultAuthInfoImpl(session.getDomain(),session.getUserName(),session.getPassword()),server,true);
public MSExcel(String address,String[] args) throws JIException, UnknownHostException { session = JISession.createSession(args[1],args[2],args[3]); comServer = new JIComServer(JIProgId.valueOf("Excel.Application"),address,session); }
holder.username = session.getUserName (); holder.password = session.getPassword (); holder.domain = session.getDomain (); holder.currentSetOIDs.put ( oid, oid ); holder.modified = true;
public void release() throws JIException { checkLocal(); JICallBuilder obj = new JICallBuilder(true); obj.setParentIpid(ptr.getIPID()); obj.setOpnum(2);//release //length obj.addInParamAsShort((short)1,JIFlags.FLAG_NULL); //ipid to addfref on JIArray array = new JIArray(new rpc.core.UUID[]{new rpc.core.UUID(ptr.getIPID())},true); obj.addInParamAsArray(array,JIFlags.FLAG_NULL); //TODO requesting 5 for now, will later build caching mechnaism to exhaust 5 refs first before asking for more // same with release. obj.addInParamAsInt(5,JIFlags.FLAG_NULL); obj.addInParamAsInt(0,JIFlags.FLAG_NULL);//private refs = 0 if (JISystem.getLogger().isLoggable(Level.WARNING)) { JISystem.getLogger().warning("RELEASE called directly ! removing 5 references for " + ptr.getIPID()+ " session: " + session.getSessionIdentifier()); JISession.debug_delIpids(ptr.getIPID(), 5); } session.getStub().addRef_ReleaseRef(obj); }
if (JISystem.getLogger().isLoggable(Level.WARNING)) JISystem.getLogger().warning("addRef: Adding 5 references for " + ptr.getIPID() + " session: " + session.getSessionIdentifier()); JISession.debug_addIpids(ptr.getIPID(), 5); session.getStub().addRef_ReleaseRef(obj);
@Override public void release () throws JIException { checkLocal (); final JICallBuilder obj = new JICallBuilder ( true ); obj.setParentIpid ( this.ptr.getIPID () ); obj.setOpnum ( 2 );//release //length obj.addInParamAsShort ( (short)1, JIFlags.FLAG_NULL ); //ipid to addfref on final JIArray array = new JIArray ( new rpc.core.UUID[] { new rpc.core.UUID ( this.ptr.getIPID () ) }, true ); obj.addInParamAsArray ( array, JIFlags.FLAG_NULL ); //TODO requesting 5 for now, will later build caching mechnaism to exhaust 5 refs first before asking for more // same with release. obj.addInParamAsInt ( 5, JIFlags.FLAG_NULL ); obj.addInParamAsInt ( 0, JIFlags.FLAG_NULL );//private refs = 0 if ( logger.isInfoEnabled () ) { logger.info ( "RELEASE called directly ! removing 5 references for " + this.ptr.getIPID () + " session: " + this.session.getSessionIdentifier () ); JISession.debug_delIpids ( this.ptr.getIPID (), 5 ); } this.session.getStub2 ().addRef_ReleaseRef ( obj ); }
@Override public void addRef () throws JIException { checkLocal (); final JICallBuilder obj = new JICallBuilder ( true ); obj.setParentIpid ( this.ptr.getIPID () ); obj.setOpnum ( 1 );//addRef //length obj.addInParamAsShort ( (short)1, JIFlags.FLAG_NULL ); //ipid to addfref on final JIArray array = new JIArray ( new rpc.core.UUID[] { new rpc.core.UUID ( this.ptr.getIPID () ) }, true ); obj.addInParamAsArray ( array, JIFlags.FLAG_NULL ); //TODO requesting 5 for now, will later build caching mechnaism to exhaust 5 refs first before asking for more // same with release. obj.addInParamAsInt ( 5, JIFlags.FLAG_NULL ); obj.addInParamAsInt ( 0, JIFlags.FLAG_NULL );//private refs = 0 obj.addOutParamAsType ( Short.class, JIFlags.FLAG_NULL );//size obj.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );//Hresult for size if ( logger.isInfoEnabled () ) { logger.info ( "addRef: Adding 5 references for " + this.ptr.getIPID () + " session: " + this.session.getSessionIdentifier () ); } JISession.debug_addIpids ( this.ptr.getIPID (), 5 ); this.session.getStub2 ().addRef_ReleaseRef ( obj ); if ( obj.getResultAsIntAt ( 1 ) != 0 ) { throw new JIException ( obj.getResultAsIntAt ( 1 ), (Throwable)null ); } }