Search in sources :

Example 91 with SocketAddress

use of java.net.SocketAddress in project pinpoint by naver.

the class TAsyncMethodCallConstructInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args, result, throwable);
    }
    if (validate(target)) {
        TNonblockingTransport transport = ((TNonblockingTransportFieldGetter) target)._$PINPOINT$_getTNonblockingTransport();
        if (validateTransport(transport)) {
            SocketAddress socketAddress = ((SocketAddressFieldAccessor) transport)._$PINPOINT$_getSocketAddress();
            ((SocketAddressFieldAccessor) target)._$PINPOINT$_setSocketAddress(socketAddress);
        }
    }
}
Also used : SocketAddressFieldAccessor(com.navercorp.pinpoint.plugin.thrift.field.accessor.SocketAddressFieldAccessor) TNonblockingTransport(org.apache.thrift.transport.TNonblockingTransport) TNonblockingTransportFieldGetter(com.navercorp.pinpoint.plugin.thrift.field.getter.TNonblockingTransportFieldGetter) SocketAddress(java.net.SocketAddress)

Example 92 with SocketAddress

use of java.net.SocketAddress in project pinpoint by naver.

the class NetworkAvailabilityCheckPacketFilterTest method testFilter_Continue.

@Test
public void testFilter_Continue() throws Exception {
    SocketAddress localSocketAddress = senderSocket.getLocalSocketAddress();
    logger.debug("localSocket:{}", localSocketAddress);
    TSpan skip = new TSpan();
    boolean skipResult = filter.filter(receiverSocket, skip, null);
    Assert.assertEquals(skipResult, TBaseFilter.CONTINUE);
}
Also used : TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Example 93 with SocketAddress

use of java.net.SocketAddress in project pinpoint by naver.

the class NetworkAvailabilityCheckPacketFilterTest method testFilter.

@Test
public void testFilter() throws Exception {
    SocketAddress localSocketAddress = senderSocket.getLocalSocketAddress();
    logger.debug("localSocket:{}", localSocketAddress);
    NetworkAvailabilityCheckPacket packet = new NetworkAvailabilityCheckPacket();
    boolean skipResult = filter.filter(receiverSocket, packet, new InetSocketAddress("localhost", senderSocket.getLocalPort()));
    Assert.assertEquals(skipResult, TBaseFilter.BREAK);
    DatagramPacket receivePacket = new DatagramPacket(new byte[100], 100);
    senderSocket.receive(receivePacket);
    Assert.assertEquals(receivePacket.getLength(), NetworkAvailabilityCheckPacket.DATA_OK.length);
    Assert.assertArrayEquals(Arrays.copyOf(receivePacket.getData(), NetworkAvailabilityCheckPacket.DATA_OK.length), NetworkAvailabilityCheckPacket.DATA_OK);
}
Also used : NetworkAvailabilityCheckPacket(com.navercorp.pinpoint.thrift.io.NetworkAvailabilityCheckPacket) InetSocketAddress(java.net.InetSocketAddress) DatagramPacket(java.net.DatagramPacket) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Example 94 with SocketAddress

use of java.net.SocketAddress in project aws-iam-ldap-bridge by denismo.

the class AWSIAMAuthenticator method authenticate.

@Override
public LdapPrincipal authenticate(BindOperationContext bindContext) throws Exception {
    if (!isAWSAccount(bindContext) || disabled) {
        LOG.debug("Skipping " + bindContext.getDn() + " - not an AWS account");
        if (delegatedAuth == null) {
            LOG.error("Delegated auth is null");
            return null;
        }
        return delegatedAuth.authenticate(bindContext);
    }
    LOG.debug("Authenticating " + bindContext.getDn());
    byte[] password = bindContext.getCredentials();
    LookupOperationContext lookupContext = new LookupOperationContext(getDirectoryService().getAdminSession(), bindContext.getDn(), SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES);
    Entry userEntry = getDirectoryService().getPartitionNexus().lookup(lookupContext);
    if (validator.verifyIAMPassword(userEntry, new String(password))) {
        LdapPrincipal principal = new LdapPrincipal(getDirectoryService().getSchemaManager(), bindContext.getDn(), AuthenticationLevel.SIMPLE, password);
        IoSession session = bindContext.getIoSession();
        if (session != null) {
            SocketAddress clientAddress = session.getRemoteAddress();
            principal.setClientAddress(clientAddress);
            SocketAddress serverAddress = session.getServiceAddress();
            principal.setServerAddress(serverAddress);
        }
        bindContext.setEntry(new ClonedServerEntry(userEntry));
        return principal;
    } else {
        // Bad password ...
        String message = I18n.err(I18n.ERR_230, bindContext.getDn().getName());
        LOG.info(message);
        throw new LdapAuthenticationException(message);
    }
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) ClonedServerEntry(org.apache.directory.server.core.api.entry.ClonedServerEntry) LdapPrincipal(org.apache.directory.server.core.api.LdapPrincipal) LdapAuthenticationException(org.apache.directory.api.ldap.model.exception.LdapAuthenticationException) LookupOperationContext(org.apache.directory.server.core.api.interceptor.context.LookupOperationContext) SocketAddress(java.net.SocketAddress) ClonedServerEntry(org.apache.directory.server.core.api.entry.ClonedServerEntry) IoSession(org.apache.mina.core.session.IoSession)

Example 95 with SocketAddress

use of java.net.SocketAddress in project dropwizard by dropwizard.

the class JerseyClientBuilderTest method usesACustomHttpRoutePlanner.

@Test
public void usesACustomHttpRoutePlanner() {
    final HttpRoutePlanner customHttpRoutePlanner = new SystemDefaultRoutePlanner(new ProxySelector() {

        @Override
        public List<Proxy> select(URI uri) {
            return ImmutableList.of(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("192.168.53.12", 8080)));
        }

        @Override
        public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
        }
    });
    builder.using(customHttpRoutePlanner);
    verify(apacheHttpClientBuilder).using(customHttpRoutePlanner);
}
Also used : ProxySelector(java.net.ProxySelector) Proxy(java.net.Proxy) HttpRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner) InetSocketAddress(java.net.InetSocketAddress) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) IOException(java.io.IOException) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) URI(java.net.URI) SystemDefaultRoutePlanner(org.apache.http.impl.conn.SystemDefaultRoutePlanner) Test(org.junit.Test)

Aggregations

SocketAddress (java.net.SocketAddress)355 InetSocketAddress (java.net.InetSocketAddress)279 IOException (java.io.IOException)79 Test (org.junit.Test)73 Socket (java.net.Socket)48 InetAddress (java.net.InetAddress)35 Channel (org.jboss.netty.channel.Channel)33 SocketException (java.net.SocketException)27 UnknownHostException (java.net.UnknownHostException)25 DefaultHttpResponse (org.jboss.netty.handler.codec.http.DefaultHttpResponse)23 HttpResponse (org.jboss.netty.handler.codec.http.HttpResponse)23 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)20 ConditionCheck (com.linkedin.databus2.test.ConditionCheck)19 SimpleObjectCaptureHandler (com.linkedin.databus2.test.container.SimpleObjectCaptureHandler)19 Proxy (java.net.Proxy)18 HashMap (java.util.HashMap)17 DatagramPacket (java.net.DatagramPacket)16 ByteBuffer (java.nio.ByteBuffer)16 Logger (org.apache.log4j.Logger)16 Test (org.testng.annotations.Test)16