List of usage examples for org.apache.http.nio.reactor IOSession setAttribute
void setAttribute(String name, Object obj);
From source file:org.wso2.carbon.inbound.endpoint.protocol.hl7.core.MLLPSourceHandler.java
@Override public void connected(IOSession session) { if (session.getAttribute(MLLPConstants.MLLP_CONTEXT) == null) { session.setAttribute(MLLPConstants.MLLP_CONTEXT, MLLPContextFactory.createMLLPContext(session, hl7Processor)); }/*from ww w .j ava 2 s .co m*/ inputBuffer = bufferFactory.getBuffer(); outputBuffer = bufferFactory.getBuffer(); }
From source file:org.apache.axis2.transport.nhttp.PlainServerIOEventDispatch.java
public void connected(final IOSession session) { // Decorate I/O session with logging capabilities LoggingNHttpServerConnection conn = new LoggingNHttpServerConnection(new LoggingIOSession(session), new DefaultHttpRequestFactory(), new HeapByteBufferAllocator(), this.params); session.setAttribute(NHTTP_CONN, conn); this.handler.connected(conn); }
From source file:org.apache.axis2.transport.nhttp.PlainClientIOEventDispatch.java
public void connected(final IOSession session) { // Decorate I/O session with logging capabilities LoggingNHttpClientConnection conn = new LoggingNHttpClientConnection(new LoggingIOSession(session), new DefaultHttpResponseFactory(), new HeapByteBufferAllocator(), this.params); session.setAttribute(NHTTP_CONN, conn); Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY); this.handler.connected(conn, attachment); }
From source file:org.siddhiesb.transport.http.conn.ClientConnFactory.java
public void upgrade(final UpgradableNHttpConnection conn) { if (ssl != null) { IOSession iosession = conn.getIOSession(); if (!(iosession instanceof SSLIOSession)) { SSLContext customContext = getSSLContext(iosession); SSLIOSession ssliosession = new SSLIOSession(iosession, SSLMode.CLIENT, customContext, ssl.getHandler());/*from w w w .j a va 2 s .com*/ iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession); conn.bind(ssliosession); } } }
From source file:org.apache.axis2.transport.nhttp.SSLServerIOEventDispatch.java
public void connected(final IOSession session) { SSLIOSession sslSession = new SSLIOSession(session, this.sslcontext, this.sslHandler); LoggingNHttpServerConnection conn = new LoggingNHttpServerConnection(new LoggingIOSession(sslSession), new DefaultHttpRequestFactory(), new HeapByteBufferAllocator(), this.params); session.setAttribute(NHTTP_CONN, conn); session.setAttribute(SSL_SESSION, sslSession); this.handler.connected(conn); try {//from w w w. ja v a 2 s. c o m sslSession.bind(SSLMode.SERVER, this.params); } catch (SSLException ex) { this.handler.exception(conn, ex); sslSession.shutdown(); } }
From source file:org.apache.axis2.transport.nhttp.SSLClientIOEventDispatch.java
public void connected(final IOSession session) { SSLIOSession sslSession = new SSLIOSession(session, this.sslcontext, this.sslHandler); LoggingNHttpClientConnection conn = new LoggingNHttpClientConnection(new LoggingIOSession(sslSession), new DefaultHttpResponseFactory(), new HeapByteBufferAllocator(), this.params); session.setAttribute(NHTTP_CONN, conn); session.setAttribute(SSL_SESSION, sslSession); Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY); this.handler.connected(conn, attachment); try {//from w ww. ja va2s. c om sslSession.bind(SSLMode.CLIENT, this.params); } catch (SSLException ex) { this.handler.exception(conn, ex); sslSession.shutdown(); } }
From source file:org.siddhiesb.transport.http.conn.ClientConnFactory.java
public DefaultNHttpClientConnection createConnection(final IOSession iosession, final HttpRoute route) { IOSession customSession;/*from w w w.j a v a 2s . c o m*/ if (ssl != null && route.isSecure() && !route.isTunnelled()) { SSLContext customContext = getSSLContext(iosession); SSLIOSession ssliosession = new SSLIOSession(iosession, SSLMode.CLIENT, customContext, ssl.getHandler()); iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession); customSession = ssliosession; } else { customSession = iosession; } DefaultNHttpClientConnection conn = org.siddhiesb.transport.http.conn.LoggingUtils .createClientConnection(customSession, responseFactory, allocator, params); int timeout = HttpConnectionParams.getSoTimeout(params); conn.setSocketTimeout(timeout); return conn; }
From source file:org.aevans.goat.net.SSLStrategyGetter.java
public static SchemeIOSessionStrategy getSchemeIOSessionStrategy() { DefaultHostnameVerifier hostnameVerifier = new DefaultHostnameVerifier( PublicSuffixMatcherLoader.getDefault()); SchemeIOSessionStrategy sioss = new SchemeIOSessionStrategy() { @Override//from ww w .j a va 2 s .co m public boolean isLayeringRequired() { return true; } @Override public IOSession upgrade(final HttpHost host, final IOSession iosession) throws IOException { SSLSetupHandler handler = new SSLSetupHandler() { @Override public void initalize(SSLEngine sslengine) throws SSLException { } @Override public void verify(IOSession iosession, SSLSession sslsession) throws SSLException { if (!hostnameVerifier.verify(host.getHostName(), sslsession)) { final java.security.cert.Certificate[] certs = sslsession.getPeerCertificates(); final X509Certificate x509 = (X509Certificate) certs[0]; final X500Principal x500Principal = x509.getSubjectX500Principal(); throw new SSLPeerUnverifiedException("Host name '" + host.getHostName() + "' does not match " + "the certificate subject provided by the peer (" + x500Principal.toString() + ")"); } } }; SSLBufferManagementStrategy sslbm = new ReleasableSSLBufferManagementStrategy(); SSLIOSession ssio = new SSLIOSession(iosession, SSLMode.CLIENT, host, SSLContexts.createDefault(), handler, sslbm); iosession.setAttribute(SSLIOSession.SESSION_KEY, ssio); ssio.initialize(); return ssio; } }; return sioss; }
From source file:org.siddhiesb.transport.http.conn.ServerConnFactory.java
public DefaultNHttpServerConnection createConnection(final IOSession iosession) { org.siddhiesb.transport.http.conn.SSLContextDetails customSSL = null; if (sslByIPMap != null) { customSSL = sslByIPMap.get(iosession.getLocalAddress()); }/*from w w w.ja v a2 s. co m*/ if (customSSL == null) { customSSL = ssl; } IOSession customSession; if (customSSL != null) { customSession = new SSLIOSession(iosession, SSLMode.SERVER, customSSL.getContext(), customSSL.getHandler()); iosession.setAttribute(SSLIOSession.SESSION_KEY, customSession); } else { customSession = iosession; } DefaultNHttpServerConnection conn = LoggingUtils.createServerConnection(customSession, requestFactory, allocator, params); int timeout = HttpConnectionParams.getSoTimeout(params); conn.setSocketTimeout(timeout); return conn; }
From source file:com.ok2c.lightmtp.impl.protocol.AuthCodec.java
@Override public void produceData(final IOSession iosession, final ClientState state) throws IOException, SMTPProtocolException { Args.notNull(iosession, "IO session"); Args.notNull(state, "Session state"); SessionOutputBuffer buf = this.iobuffers.getOutbuf(); switch (this.codecState) { case AUTH_READY: AuthMode mode = null;/* w w w.j a va 2 s .c o m*/ for (final String extension : state.getExtensions()) { if (extension.startsWith(ProtocolState.AUTH.name())) { String types = extension.substring(ProtocolState.AUTH.name().length() + 1); mode = getAuthMode(types); if (mode != null) { break; } } } if (mode == null) { // TODO: Maybe we should just skip auth then and call the next codec in the chain throw new SMTPProtocolException("Unsupported AUTH types"); } else { iosession.setAttribute(AUTH_TYPE, mode); } SMTPCommand auth = new SMTPCommand("AUTH", mode.name()); this.writer.write(auth, buf); this.codecState = CodecState.AUTH_RESPONSE_READY; break; case AUTH_PLAIN_INPUT_READY: byte[] authdata = Base64.encodeBase64(("\0" + username + "\0" + password).getBytes(AUTH_CHARSET)); lineBuf.append(authdata, 0, authdata.length); this.codecState = CodecState.AUTH_PLAIN_INPUT_RESPONSE_EXPECTED; break; case AUTH_LOGIN_USERNAME_INPUT_READY: byte[] authUserData = Base64.encodeBase64(username.getBytes(AUTH_CHARSET)); lineBuf.append(authUserData, 0, authUserData.length); this.codecState = CodecState.AUTH_LOGIN_USERNAME_INPUT_RESPONSE_EXPECTED; break; case AUTH_LOGIN_PASSWORD_INPUT_READY: byte[] authPassData = Base64.encodeBase64(password.getBytes(AUTH_CHARSET)); lineBuf.append(authPassData, 0, authPassData.length); this.codecState = CodecState.AUTH_LOGIN_PASSWORD_INPUT_RESPONSE_EXPECTED; break; } if (!lineBuf.isEmpty()) { buf.writeLine(lineBuf); lineBuf.clear(); } if (buf.hasData()) { buf.flush(iosession.channel()); } if (!buf.hasData()) { iosession.clearEvent(SelectionKey.OP_WRITE); } }