Example usage for io.vertx.core MultiMap contains

List of usage examples for io.vertx.core MultiMap contains

Introduction

In this page you can find the example usage for io.vertx.core MultiMap contains.

Prototype

@GenIgnore(GenIgnore.PERMITTED_TYPE)
boolean contains(CharSequence name);

Source Link

Document

Like #contains(String) but accepting a CharSequence as a parameter

Usage

From source file:org.sfs.rx.ConnectionCloseTerminus.java

License:Apache License

protected void fixcyberduck() {
    SfsRequest serverRequest = getSfsRequest();
    MultiMap headers = serverRequest.headers();
    // cyberduck sends keep-alive but then gets screwed up when connection: close isn't sent
    // if this is not a proxied request and originated in cyberduck then send the connection: close
    // headers. If it is a proxied request let the proxy deal with the issue
    if (!headers.contains((X_FORWARDED_FOR))) {
        String userAgent = toLowerCase(headers.get(USER_AGENT));
        if (userAgent != null && userAgent.contains("cyberduck")) {
            serverRequest.response().putHeader(CONNECTION, "close");
        }/* w ww. ja  v  a 2 s.c o  m*/
    }
}

From source file:org.sfs.SfsRequest.java

License:Apache License

public SfsRequest startProxyKeepAlive() {
    MultiMap headers = httpServerRequest.headers();
    long keepAliveTimeout = Long.parseLong(
            headers.contains(X_SFS_KEEP_ALIVE_TIMEOUT) ? headers.get(X_SFS_KEEP_ALIVE_TIMEOUT) : "10000");
    startProxyKeepAlive(keepAliveTimeout, MILLISECONDS);
    return this;
}

From source file:org.sfs.validate.ValidateActionAdminOrSystem.java

License:Apache License

@Override
public Observable<Void> call(Void aVoid) {
    Server verticle = sfsRequest.vertxContext().verticle();
    AuthProviderService authProvider = verticle.authProviderService();
    return authProvider.canAdmin(sfsRequest).map(canDo -> {
        if (!canDo) {
            MultiMap headers = sfsRequest.headers();
            if (headers.contains(X_SFS_REMOTE_NODE_TOKEN)) {
                byte[] actualToken = null;
                try {
                    actualToken = base64().decode(headers.get(X_SFS_REMOTE_NODE_TOKEN));
                } catch (Throwable ignore) {
                }/*from ww  w. j a v  a2 s  .c  om*/
                byte[] expectedToken = verticle.getRemoteNodeSecret();
                if (Arrays.equals(expectedToken, actualToken)) {
                    // autenticated
                    return null;
                }
            }
            JsonObject jsonObject = new JsonObject().put("message", "Admin and System Action Forbidden");
            throw new HttpRequestValidationException(HTTP_FORBIDDEN, jsonObject);
        }
        return null;
    });
}

From source file:org.sfs.validate.ValidateTtl.java

License:Apache License

@Override
public SfsRequest call(SfsRequest httpServerRequest) {
    MultiMap headers = httpServerRequest.headers();

    if (headers.contains(X_DELETE_AT) && headers.contains(X_DELETE_AFTER)) {
        JsonObject jsonObject = new JsonObject().put("message",
                format("Only one of %s or %s is allowed", X_DELETE_AFTER, X_DELETE_AT));

        throw new HttpRequestValidationException(HTTP_CONFLICT, jsonObject);
    }//from w w w .  java  2  s  .  c  o  m

    String deleteAt = headers.get(X_DELETE_AT);
    if (deleteAt != null) {
        long minDeleteAt = currentTimeMillis();
        Long parsed = tryParse(deleteAt);
        if (parsed == null || parsed < 0) {
            JsonObject jsonObject = new JsonObject().put("message",
                    format("%s must be between %d and %d", X_DELETE_AT, minDeleteAt, MAX_VALUE));

            throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
        }
    }

    String deleteAfter = headers.get(X_DELETE_AFTER);
    if (deleteAfter != null) {
        Long parsed = tryParse(deleteAfter);
        if (parsed == null || parsed < 0) {
            JsonObject jsonObject = new JsonObject().put("message",
                    format("%s must be between %d and %d", X_DELETE_AFTER, 60000, MAX_VALUE));

            throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
        }
    }
    return httpServerRequest;
}

From source file:org.sfs.vo.Container.java

License:Apache License

public T merge(SfsRequest httpServerRequest) {
    MultiMap headers = httpServerRequest.headers();

    if (headers.contains(X_SFS_OBJECT_REPLICAS)) {
        setObjectReplicas(parseInt(headers.get(X_SFS_OBJECT_REPLICAS)));
    } else {//from   w  ww  . ja  v a2 s  .c om
        setObjectReplicas(NOT_SET);
    }

    getMetadata().withHttpHeaders(headers);

    return (T) this;
}

From source file:org.sfs.vo.XBlob.java

License:Apache License

public XBlob merge(SfsRequest httpServerRequest) {
    MultiMap queryParams = httpServerRequest.params();
    MultiMap headers = httpServerRequest.headers();

    if (queryParams.contains(VOLUME)) {
        volume = tryParse(queryParams.get(VOLUME));
    }/*from   w  ww  .  j  a  v a 2s  .  com*/
    if (queryParams.contains(POSITION)) {
        position = Longs.tryParse(queryParams.get(POSITION));
    }
    if (queryParams.contains(VERSION)) {
        version = base64().decode(queryParams.get(VERSION));
    }
    if (headers.contains(CONTENT_LENGTH)) {
        length = Longs.tryParse(headers.get(CONTENT_LENGTH));
    }

    for (String queryParam : queryParams.names()) {
        Matcher matcher = COMPUTED_DIGEST.matcher(queryParam);
        if (matcher.matches()) {
            MessageDigestFactory digest = fromValueIfExists(matcher.group(1)).get();
            messageDigests.add(digest);
        }
    }

    return this;
}