All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.urbanairship.api.oauth.PublicKeyVerificationRequest Maven / Gradle / Ivy

There is a newer version: 9.4.2
Show newest version
package com.urbanairship.api.oauth;

import com.urbanairship.api.client.Request;
import com.urbanairship.api.client.ResponseParser;
import org.apache.http.entity.ContentType;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;

public class PublicKeyVerificationRequest implements Request {

    private final String keyId;
    private final boolean useEuropeanSite;

    private PublicKeyVerificationRequest(String keyId, boolean useEuropeanSite) {
        this.keyId = keyId;
        this.useEuropeanSite = useEuropeanSite;
    }

    private PublicKeyVerificationRequest(String keyId) {
        this(keyId, false);
    }

    public static PublicKeyVerificationRequest newRequest(String keyId, boolean useEuropeanSite) {
        return new PublicKeyVerificationRequest(keyId, useEuropeanSite);
    }

    public static PublicKeyVerificationRequest newRequest(String keyId) {
        return new PublicKeyVerificationRequest(keyId);
    }

    @Override
    public HttpMethod getHttpMethod() {
        return HttpMethod.GET;
    }

    @Override
    public String getRequestBody() {
        return null;
    }

    @Override
    public ContentType getContentType() {
        return ContentType.TEXT_PLAIN;
    }

    @Override
    public Map getRequestHeaders() {
        Map headers = new HashMap<>();
        headers.put("Accept", "text/plain");
        return headers;
    }

    @Override
    public URI getUri(URI baseUri) throws URISyntaxException {
        String baseEndpoint = useEuropeanSite ? "https://oauth2.asnapieu.com" : "https://oauth2.asnapius.com";
        return new URI(baseEndpoint + "/verify/public_key/" + this.keyId);
    }

    @Override
    public ResponseParser getResponseParser() {
        return response -> response;
    }

    @Override
    public boolean bearerTokenAuthRequired() {
        return false;
    }

    @Override
    public boolean canUseBearerTokenAuth() {
        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy