/** * initialize the APR Library by loading the associated native libraries * and creating the associated singleton */ private static synchronized void initialize() { if (library == null) { library = new AprLibrary(); } }
/** * {@inheritDoc} */ public void stop() { agent.close(); } }
/** * get the shared instance of APR library, if none, initialize one * * @return the current APR library singleton */ public static synchronized AprLibrary getInstance() { if (!isInitialized()) { initialize(); } return library; }
@Override protected synchronized void doWriteData(byte[] data, int off, long len) throws IOException { ValidateUtils.checkTrue(len <= Integer.MAX_VALUE, "Data length exceeds int boundaries: %d", len); Window wLocal = getLocalWindow(); wLocal.consumeAndCheck(len); int result = Socket.send(socket, data, off, (int) len); if (result < Status.APR_SUCCESS) { throw AgentServerProxy.toIOException(result); } } }
@Override public SshAgentServer createServer(ConnectionService service) throws IOException { Session session = Objects.requireNonNull(service.getSession(), "No session"); ValidateUtils.checkInstanceOf(session, ServerSession.class, "The session used to create an agent server proxy must be a server session: %s", session); return new AgentServerProxy(service, newExecutor()); } }
@Override public SshAgent createClient(FactoryManager manager) throws IOException { String authSocket = manager.getString(SshAgent.SSH_AUTHSOCKET_ENV_NAME); if (GenericUtils.isEmpty(authSocket)) { throw new SshException("No " + SshAgent.SSH_AUTHSOCKET_ENV_NAME + " value"); } return new AgentClient(authSocket, newExecutor()); }
static void secureLocalSocket(String authSocket, long handle) throws IOException { // should be ok on windows if (OsUtils.isUNIX()) { chmodOwner(authSocket, false); } }
@Override public Channel create() { CloseableExecutorService executorService = executorServiceFactory != null ? executorServiceFactory.create() : null; ChannelAgentForwarding channel = new ChannelAgentForwarding(executorService); return channel; } }
protected File removeSocketFile(String socketPath, boolean debugEnabled) throws Exception { File socketFile = new File(socketPath); if (socketFile.exists()) { deleteFile(socketFile, "Deleted PIPE socket {}", debugEnabled); if (OsUtils.isUNIX()) { deleteFile(socketFile.getParentFile(), "Deleted parent PIPE socket {}", debugEnabled); } } return socketFile; }
/** * Constructor. * * @param listener the listener. * @throws Exception if the agent could not start. */ public MinaRemoteAgent(TaskListener listener) throws Exception { this.listener = listener; agent = new AgentServer(); socket = agent.start(); }
@Override protected void doWriteData(byte[] data, int off, long len) throws IOException { ValidateUtils.checkTrue(len <= Integer.MAX_VALUE, "Data length exceeds int boundaries: %d", len); int result = Socket.send(handle, data, off, (int) len); if (result < Status.APR_SUCCESS) { throwException(result); } }
/** * get the shared instance of APR library, if none, initialize one * * @return the current APR library singleton */ public static synchronized AprLibrary getInstance() { if (!isInitialized()) { initialize(); } return library; }
@Override protected synchronized void doWriteData(byte[] data, int off, long len) throws IOException { ValidateUtils.checkTrue(len <= Integer.MAX_VALUE, "Data length exceeds int boundaries: %d", len); Window wLocal = getLocalWindow(); wLocal.consumeAndCheck(len); int result = Socket.send(socket, data, off, (int) len); if (result < Status.APR_SUCCESS) { throw AgentServerProxy.toIOException(result); } } }
@Override public SshAgentServer createServer(ConnectionService service) throws IOException { Session session = Objects.requireNonNull(service.getSession(), "No session"); ValidateUtils.checkInstanceOf(session, ServerSession.class, "The session used to create an agent server proxy must be a server session: %s", session); return new AgentServerProxy(service, newExecutor()); } }
@Override public SshAgent createClient(FactoryManager manager) throws IOException { String authSocket = manager.getString(SshAgent.SSH_AUTHSOCKET_ENV_NAME); if (GenericUtils.isEmpty(authSocket)) { throw new SshException("No " + SshAgent.SSH_AUTHSOCKET_ENV_NAME + " value"); } return new AgentClient(authSocket, newExecutor()); }
/** * initialize the APR Library by loading the associated native libraries * and creating the associated singleton */ private static synchronized void initialize() { if (library == null) { library = new AprLibrary(); } }
static void secureLocalSocket(String authSocket, long handle) throws IOException { // should be ok on windows if (OsUtils.isUNIX()) { chmodOwner(authSocket, false); } }
@Override public Channel create() { CloseableExecutorService executorService = executorServiceFactory != null ? executorServiceFactory.create() : null; ChannelAgentForwarding channel = new ChannelAgentForwarding(executorService); return channel; } }
protected File removeSocketFile(String socketPath, boolean debugEnabled) throws Exception { File socketFile = new File(socketPath); if (socketFile.exists()) { deleteFile(socketFile, "Deleted PIPE socket {}", debugEnabled); if (OsUtils.isUNIX()) { deleteFile(socketFile.getParentFile(), "Deleted parent PIPE socket {}", debugEnabled); } } return socketFile; }