本文整理汇总了Java中org.apache.mina.core.filterchain.IoFilter.NextFilter类的典型用法代码示例。如果您正苦于以下问题:Java NextFilter类的具体用法?Java NextFilter怎么用?Java NextFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NextFilter类属于org.apache.mina.core.filterchain.IoFilter包,在下文中一共展示了NextFilter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: deliverEvent
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Static method which effectively delivers the specified event to the next filter
* <code>nextFilter</code> on the <code>session</code>.
*
* @param nextFilter the next filter
* @param session the session on which the event occured
* @param type the event type
* @param status the idle status should only be non null only if the event type is
* {@link IoSessionEventType#IDLE}
*/
private static void deliverEvent(final NextFilter nextFilter, final IoSession session,
final IoSessionEventType type, final IdleStatus status) {
switch (type) {
case CREATED:
nextFilter.sessionCreated(session);
break;
case OPENED:
nextFilter.sessionOpened(session);
break;
case IDLE:
nextFilter.sessionIdle(session, status);
break;
case CLOSED:
nextFilter.sessionClosed(session);
break;
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:28,代码来源:IoSessionEvent.java
示例2: doHandshake
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException {
logger.debug(" doHandshake()");
if (step > 0) {
throw new ProxyAuthException("Authentication request already sent");
}
// Send request
HttpProxyRequest req = (HttpProxyRequest) request;
Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders()
: new HashMap<String, List<String>>();
String username = req.getProperties().get(HttpProxyConstants.USER_PROPERTY);
String password = req.getProperties().get(HttpProxyConstants.PWD_PROPERTY);
StringUtilities.addValueToHeader(headers, "Proxy-Authorization",
"Basic " + createAuthorization(username, password), true);
addKeepAliveHeaders(headers);
req.setHeaders(headers);
writeRequest(nextFilter, req);
step++;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:29,代码来源:HttpBasicAuthLogicHandler.java
示例3: messageReceived
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Handles incoming data during the handshake process. Should consume only the
* handshake data from the buffer, leaving any extra data in place.
*
* @param nextFilter the next filter
* @param buf the buffered data received
*/
public synchronized void messageReceived(final NextFilter nextFilter, final IoBuffer buf) {
try {
int step = ((Integer) getSession().getAttribute(HANDSHAKE_STEP)).intValue();
if (step == SocksProxyConstants.SOCKS5_GREETING_STEP && buf.get(0) != SocksProxyConstants.SOCKS_VERSION_5) {
throw new IllegalStateException("Wrong socks version running on server");
}
if ((step == SocksProxyConstants.SOCKS5_GREETING_STEP || step == SocksProxyConstants.SOCKS5_AUTH_STEP)
&& buf.remaining() >= 2) {
handleResponse(nextFilter, buf, step);
} else if (step == SocksProxyConstants.SOCKS5_REQUEST_STEP && buf.remaining() >= 5) {
handleResponse(nextFilter, buf, step);
}
} catch (Exception ex) {
closeSession("Proxy handshake failed: ", ex);
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:26,代码来源:Socks5LogicHandler.java
示例4: callNextExceptionCaught
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
private void callNextExceptionCaught(Entry entry, IoSession session, Throwable cause) {
// Notify the related future.
ConnectFuture future = (ConnectFuture) session.removeAttribute(SESSION_CREATED_FUTURE);
if (future == null) {
try {
IoFilter filter = entry.getFilter();
NextFilter nextFilter = entry.getNextFilter();
filter.exceptionCaught(nextFilter, session, cause);
} catch (Throwable e) {
LOGGER.warn("Unexpected exception from exceptionCaught handler.", e);
}
} else {
// Please note that this place is not the only place that
// calls ConnectFuture.setException().
session.close(true);
future.setException(cause);
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:DefaultIoFilterChain.java
示例5: sessionClosed
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
@Override
public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception {
AbstractIoSession s = (AbstractIoSession) session;
try {
s.getHandler().sessionClosed(session);
} finally {
try {
s.getWriteRequestQueue().dispose(session);
} finally {
try {
s.getAttributeMap().dispose(session);
} finally {
try {
// Remove all filters.
session.getFilterChain().clear();
} finally {
if (s.getConfig().isUseReadOperation()) {
s.offerClosedReadFuture();
}
}
}
}
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:DefaultIoFilterChain.java
示例6: messageReceived
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
@Override
public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception {
AbstractIoSession s = (AbstractIoSession) session;
if (!(message instanceof IoBuffer)) {
s.increaseReadMessages(System.currentTimeMillis());
} else if (!((IoBuffer) message).hasRemaining()) {
s.increaseReadMessages(System.currentTimeMillis());
}
try {
session.getHandler().messageReceived(s, message);
} finally {
if (s.getConfig().isUseReadOperation()) {
s.offerReadFuture(message);
}
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:DefaultIoFilterChain.java
示例7: wrap
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
public void wrap(NextFilter nextFilter, WriteRequest writeRequest, IoBuffer buf)
throws AuthException
{
int endOriginalMessage = buf.limit() - DigestMD5IntegrityIoFilterCodec.LINE_TERMINATOR.length;
byte[] originalMessage = new byte[endOriginalMessage];
buf.get(originalMessage);
buf.put(AuthDigestMD5IoFilter.computeMACBlock(session, originalMessage, false));
buf.put(DigestMD5IntegrityIoFilterCodec.LINE_TERMINATOR);
buf.flip();
if (buf.limit() > ((Integer)session.getAttribute(AuthDigestMD5Command.CLIENT_MAXBUF)).intValue())
throw new AuthException("Data exceeds client maxbuf capabilities");
nextFilter.filterWrite(session,
new DefaultWriteRequest(buf, writeRequest.getFuture()));
}
开发者ID:edeoliveira,项目名称:Mailster,代码行数:17,代码来源:DigestMD5IntegrityIoFilterCodec.java
示例8: flushScheduledEvents
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
void flushScheduledEvents() {
scheduled_events.getAndIncrement();
// Fire events only when the lock is available for this handler.
if (sslLock.tryLock()) {
try {
do {
Entry<NextFilter, WriteRequest> eventW;
// We need synchronization here inevitably because filterWrite can be
// called simultaneously and cause 'bad record MAC' integrity error.
while ((eventW = filterWriteEventQueue.poll()) != null) {
eventW.getKey().filterWrite(eventW.getValue());
}
Entry<NextFilter, Object> eventR;
while ((eventR = messageReceivedEventQueue.poll()) != null) {
eventR.getKey().messageReceived(eventR.getValue());
}
} while (scheduled_events.decrementAndGet() > 0);
} finally {
sslLock.unlock();
}
}
}
开发者ID:dwing4g,项目名称:jane,代码行数:25,代码来源:SslHandler.java
示例9: HandshakeContext
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
public HandshakeContext ( final ProtocolConfiguration protocolConfiguration, final boolean clientMode, final IoSession session, final NextFilter nextFilter )
{
super ();
this.protocolConfiguration = protocolConfiguration;
this.clientMode = clientMode;
this.session = session;
this.nextFilter = nextFilter;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:9,代码来源:HandshakeContext.java
示例10: writeData
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Writes data to the proxy server.
*
* @param nextFilter the next filter
* @param data Data buffer to be written.
*/
protected WriteFuture writeData(final NextFilter nextFilter, final IoBuffer data) {
// write net data
ProxyHandshakeIoBuffer writeBuffer = new ProxyHandshakeIoBuffer(data);
LOGGER.debug(" session write: {}", writeBuffer);
WriteFuture writeFuture = new DefaultWriteFuture(getSession());
getProxyFilter().writeData(nextFilter, getSession(), new DefaultWriteRequest(writeBuffer, writeFuture), true);
return writeFuture;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:AbstractProxyLogicHandler.java
示例11: enqueueWriteRequest
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Enqueue a message to be written once handshaking is complete.
*/
public synchronized void enqueueWriteRequest(final NextFilter nextFilter, final WriteRequest writeRequest) {
if (writeRequestQueue == null) {
writeRequestQueue = new LinkedList<Event>();
}
writeRequestQueue.offer(new Event(nextFilter, writeRequest));
}
开发者ID:eclipse,项目名称:neoscada,代码行数:11,代码来源:AbstractProxyLogicHandler.java
示例12: doHandshake
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Performs the handshake processing.
*
* @param nextFilter the next filter
*/
public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException {
logger.debug(" doHandshake()");
if (authHandler != null) {
authHandler.doHandshake(nextFilter);
} else {
if (requestSent) {
// Safety check
throw new ProxyAuthException("Authentication request already sent");
}
logger.debug(" sending HTTP request");
// Compute request headers
HttpProxyRequest req = (HttpProxyRequest) getProxyIoSession().getRequest();
Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders()
: new HashMap<String, List<String>>();
AbstractAuthLogicHandler.addKeepAliveHeaders(headers);
req.setHeaders(headers);
// Write request to the proxy
writeRequest(nextFilter, req);
requestSent = true;
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:32,代码来源:HttpSmartProxyHandler.java
示例13: doHandshake
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException {
logger.debug(" doHandshake()");
// Just send the request, no authentication needed
writeRequest(nextFilter, (HttpProxyRequest) request);
step++;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:12,代码来源:HttpNoAuthLogicHandler.java
示例14: writeRequest
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Calls{@link #writeRequest0(NextFilter, HttpProxyRequest)} to write the request.
* If needed a reconnection to the proxy is done previously.
*
* @param nextFilter the next filter
* @param request the http request
*/
public void writeRequest(final NextFilter nextFilter, final HttpProxyRequest request) {
ProxyIoSession proxyIoSession = getProxyIoSession();
if (proxyIoSession.isReconnectionNeeded()) {
reconnect(nextFilter, request);
} else {
writeRequest0(nextFilter, request);
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:AbstractHttpLogicHandler.java
示例15: writeRequest0
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Encodes a HTTP request and sends it to the proxy server.
*
* @param nextFilter the next filter
* @param request the http request
*/
private void writeRequest0(final NextFilter nextFilter, final HttpProxyRequest request) {
try {
String data = request.toHttpString();
IoBuffer buf = IoBuffer.wrap(data.getBytes(getProxyIoSession().getCharsetName()));
LOGGER.debug(" write:\n{}", data.replace("\r", "\\r").replace("\n", "\\n\n"));
writeData(nextFilter, buf);
} catch (UnsupportedEncodingException ex) {
closeSession("Unable to send HTTP request: ", ex);
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:20,代码来源:AbstractHttpLogicHandler.java
示例16: doHandshake
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Performs the handshake process.
*
* @param nextFilter the next filter
*/
public synchronized void doHandshake(final NextFilter nextFilter) {
LOGGER.debug(" doHandshake()");
// Send request
writeRequest(nextFilter, request, ((Integer) getSession().getAttribute(HANDSHAKE_STEP)).intValue());
}
开发者ID:eclipse,项目名称:neoscada,代码行数:12,代码来源:Socks5LogicHandler.java
示例17: writeRequest
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Encodes a SOCKS5 request and writes it to the next filter
* so it can be sent to the proxy server.
*
* @param nextFilter the next filter
* @param request the request to send.
* @param step the current step in the handshake process
*/
private void writeRequest(final NextFilter nextFilter, final SocksProxyRequest request, int step) {
try {
IoBuffer buf = null;
if (step == SocksProxyConstants.SOCKS5_GREETING_STEP) {
buf = encodeInitialGreetingPacket(request);
} else if (step == SocksProxyConstants.SOCKS5_AUTH_STEP) {
// This step can happen multiple times like in GSSAPI auth for instance
buf = encodeAuthenticationPacket(request);
// If buf is null then go to the next step
if (buf == null) {
step = SocksProxyConstants.SOCKS5_REQUEST_STEP;
}
}
if (step == SocksProxyConstants.SOCKS5_REQUEST_STEP) {
buf = encodeProxyRequestPacket(request);
}
buf.flip();
writeData(nextFilter, buf);
} catch (Exception ex) {
closeSession("Unable to send Socks request: ", ex);
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:35,代码来源:Socks5LogicHandler.java
示例18: doHandshake
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Perform the handshake.
*
* @param nextFilter the next filter
*/
public void doHandshake(final NextFilter nextFilter) {
logger.debug(" doHandshake()");
// Send request
writeRequest(nextFilter, request);
}
开发者ID:eclipse,项目名称:neoscada,代码行数:12,代码来源:Socks4LogicHandler.java
示例19: writeRequest
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Encode a SOCKS4/SOCKS4a request and writes it to the next filter
* so it can be sent to the proxy server.
*
* @param nextFilter the next filter
* @param request the request to send.
*/
protected void writeRequest(final NextFilter nextFilter, final SocksProxyRequest request) {
try {
boolean isV4ARequest = Arrays.equals(request.getIpAddress(), SocksProxyConstants.FAKE_IP);
byte[] userID = request.getUserName().getBytes("ASCII");
byte[] host = isV4ARequest ? request.getHost().getBytes("ASCII") : null;
int len = 9 + userID.length;
if (isV4ARequest) {
len += host.length + 1;
}
IoBuffer buf = IoBuffer.allocate(len);
buf.put(request.getProtocolVersion());
buf.put(request.getCommandCode());
buf.put(request.getPort());
buf.put(request.getIpAddress());
buf.put(userID);
buf.put(SocksProxyConstants.TERMINATOR);
if (isV4ARequest) {
buf.put(host);
buf.put(SocksProxyConstants.TERMINATOR);
}
if (isV4ARequest) {
logger.debug(" sending SOCKS4a request");
} else {
logger.debug(" sending SOCKS4 request");
}
buf.flip();
writeData(nextFilter, buf);
} catch (Exception ex) {
closeSession("Unable to send Socks request: ", ex);
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:46,代码来源:Socks4LogicHandler.java
示例20: messageReceived
import org.apache.mina.core.filterchain.IoFilter.NextFilter; //导入依赖的package包/类
/**
* Handle incoming data during the handshake process. Should consume only the
* handshake data from the buffer, leaving any extra data in place.
*
* @param nextFilter the next filter
* @param buf the server response data buffer
*/
public void messageReceived(final NextFilter nextFilter, final IoBuffer buf) {
try {
if (buf.remaining() >= SocksProxyConstants.SOCKS_4_RESPONSE_SIZE) {
handleResponse(buf);
}
} catch (Exception ex) {
closeSession("Proxy handshake failed: ", ex);
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:Socks4LogicHandler.java
注:本文中的org.apache.mina.core.filterchain.IoFilter.NextFilter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论