Package com.betfair.cougar.api.geolocation

Examples of com.betfair.cougar.api.geolocation.GeoLocationDetails


        if (ctx.traceLoggingEnabled()) {
            result.add(new BasicHeader("X-Trace-Me", "true"));
        }

        GeoLocationDetails gld = ctx.getLocation();
        if (gld != null) {
            geoLocationSerializer.serialize(gld, result);
        }

        if (xRequestUUIDHeader != null) {
View Full Code Here


    @Override
    public ExecutionContextWithTokens readExecutionContext(CougarObjectInput in, String remoteAddress, X509Certificate[] clientCertChain, int transportSecurityStrengthFactor, byte protocolVersion) throws IOException {
        EnumUtils.setHardFailureForThisThread(hardFailEnumDeserialisation);
        // this has to be first as the protocol requires it
        final GeoLocationDetails geo = readGeoLocation(in, remoteAddress, protocolVersion);

        List<IdentityToken> tokens = identityTokenResolver.resolve(in, clientCertChain);

        return resolveExecutionContext(in, geo, tokens, transportSecurityStrengthFactor, protocolVersion);
  }
View Full Code Here

        this.addressClassifier = addressClassifier;
    }

    @Override
    public InterceptorResult invoke(ExecutionContext ctx, OperationKey key, Object[] args) {
        GeoLocationDetails gld = ctx.getLocation();

        if (addressClassifier.isPrivateAddress(gld.getRemoteAddr()) || addressClassifier.isLocalAddress(gld.getRemoteAddr())) {
            return new InterceptorResult(InterceptorState.CONTINUE);
        }

        return new InterceptorResult(InterceptorState.FORCE_ON_EXCEPTION, new CougarServiceException(ServerFaultCode.BannedLocation, "Access not being made from private network location"));
    }
View Full Code Here

        if (ctx.traceLoggingEnabled()) {
            result.add(new BasicHeader("X-Trace-Me", "true"));
        }

        GeoLocationDetails gld = ctx.getLocation();
        if (gld != null) {
            geoLocationSerializer.serialize(gld, result);
        }

        if (xRequestUUIDHeader != null) {
View Full Code Here

    }

    @Override
    public InterceptorResult invoke(ExecutionContext ctx, OperationKey key, Object[] args) {
        if (key.getType() == OperationKey.Type.Request) {
            GeoLocationDetails geoDetails = ctx.getLocation();
            if (geoDetails == null) {
                return new InterceptorResult(InterceptorState.FORCE_ON_EXCEPTION,
                        new CougarServiceException(ServerFaultCode.SecurityException, "Geo location details were not provided"));
            } else if (banList.contains(geoDetails.getResolvedAddresses().get(0))) {
                return new InterceptorResult(InterceptorState.FORCE_ON_EXCEPTION,
                        new CougarServiceException(ServerFaultCode.SecurityException, "The IP Address [" + geoDetails.getRemoteAddr() + "] is not permitted to access to this service"));
            }
        }
        return new InterceptorResult(InterceptorState.CONTINUE);
    }
View Full Code Here

    }

    @Override
    public InterceptorResult invoke(ExecutionContext ctx, OperationKey key, Object[] args) {
        if (key.getType() == OperationKey.Type.Request) {
            GeoLocationDetails geoDetails = ctx.getLocation();
            if (geoDetails == null) {
                return new InterceptorResult(InterceptorState.FORCE_ON_EXCEPTION,
                        new CougarServiceException(ServerFaultCode.SecurityException, "Geo location details were not provided"));
            } else if (banList.contains(geoDetails.getResolvedAddresses().get(0))) {
                return new InterceptorResult(InterceptorState.FORCE_ON_EXCEPTION,
                        new CougarServiceException(ServerFaultCode.SecurityException, "The IP Address [" + geoDetails.getRemoteAddr() + "] is not permitted to access to this service"));
            }
        }
        return new InterceptorResult(InterceptorState.CONTINUE);
    }
View Full Code Here

    @Override
    public ExecutionContextWithTokens readExecutionContext(CougarObjectInput in, String remoteAddress, X509Certificate[] clientCertChain, int transportSecurityStrengthFactor, byte protocolVersion) throws IOException {
        EnumUtils.setHardFailureForThisThread(hardFailEnumDeserialisation);
        // this has to be first as the protocol requires it
        final GeoLocationDetails geo = readGeoLocation(in, remoteAddress, protocolVersion);

        List<IdentityToken> tokens = identityTokenResolver.resolve(in, clientCertChain);

        return resolveExecutionContext(in, geo, tokens, transportSecurityStrengthFactor, protocolVersion);
  }
View Full Code Here

*/
@ManagedResource(description = "No-op implementation of geo-location")
public class NullGeoIPLocator implements GeoIPLocator {
    @Override
    public GeoLocationDetails getGeoLocation(final String remoteIP, final List<String> resolvedIPs, final String inferredCountry) {
        return new GeoLocationDetails() {
            @Override
            public String getRemoteAddr() {
                return remoteIP;
            }

View Full Code Here

        } else {
            requestUUID = new RequestUUIDImpl();
        }
        final boolean traceEnabled = traceMeHeaderParamValue != null;

        GeoLocationDetails geoDetails = geoIPLocator.getGeoLocation(remoteAddress, resolvedAddresses, inferredCountry);

        return resolveExecutionContext(tokens, requestUUID, geoDetails, receivedTime, traceEnabled, transportSecurityStrengthFactor, requestTime, ignoreSubsequentWritesOfIdentity);
    }
View Full Code Here

                }

                @Override
                public Object[] getFieldsToLog() {

                    GeoLocationDetails location = context != null ? context.getLocation() : null;

                    // This is a bit (deeply!) ugly, but it is necessary as it is not possible to know
                    // if a response is gzipped until after it is written. Therefore the only other solution
                    // would be to pollute the command object with a getCompression() method, which
                    //   (a) seems overkill for a simple logger.
                    //   (b) just moves the problem to the jetty transport.
                    String compression = "none";
                    try {
                        if (command.getResponse().getOutputStream().getClass().getSimpleName().contains("GzipStream")) {
                            compression = "gzip";
                        }
                    } catch (Exception e) {
                        // ho hum. Let's assume it's not compressed
                    }

                    // Check the extra loggable fields.
                    List<String> extraFields;
                    if (headersToLog.isEmpty()) {
                        extraFields = Collections.emptyList();
                    } else {
                        extraFields = new ArrayList<String>();
                        for (String headerName: headersToLog) {
                            String value = HeaderUtils.cleanHeaderValue(command.getRequest().getHeader(headerName));
                            if (value != null && value.length() > 0) {
                                extraFields.add(headerName+"="+value);
                            }
                        }
                    }
                    return new Object[] {
                            command.getTimer().getReceivedTime(),
                            context != null ? context.getRequestUUID() : "",
                            command.getFullPath(),
                            compression,
                            location != null ? location.getRemoteAddr() : "",
                            location != null ? format(location.getResolvedAddresses()) : "",
                            location != null ? location.getCountry() : "",
                            responseCode,
                            command.getTimer().getProcessTimeNanos(),
                            bytesRead,
                            bytesWritten,
                            requestMediaType != null ? requestMediaType.getSubtype() : "",
View Full Code Here

TOP

Related Classes of com.betfair.cougar.api.geolocation.GeoLocationDetails

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.