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

uk.num.numlib.api.NumAPICallbacks Maven / Gradle / Ivy

/*
 * Copyright (c) 2019. NUM Technology Ltd
 */

package uk.num.numlib.api;

import java.security.Key;

/**
 * This interface defines the callback contract for the NumAPI.
 *
 * @author tonywalmsley
 */
public interface NumAPICallbacks {
    /**
     * Called if an error occurs while retrieving or processing the NUM recocrd.
     *
     * @param error The error String.
     */
    void setErrorResult(final String error);

    /**
     * Check whether the record needs to be decrypted.
     *
     * @return true if the record is encrypted
     */
    boolean isEncrypted();

    /**
     * Set a flag to indicate whether the NUM record was encrypted or not.
     *
     * @param encrypted true if the NUM record was encrypted
     */
    void setEncrypted(final boolean encrypted);

    /**
     * Check whether the NUM record was encrypted when received from DNS.
     *
     * @return true if the record was encrypted.
     */
    boolean wasEncrypted();

    /**
     * Check whether the record was DNSSEC signed.
     *
     * @return true if the record was DNSSEC signed.
     */
    boolean isSignedDNSSEC();

    /**
     * Set a flag to indicate whether the record was DNSSEC signed or not.
     *
     * @param signedDNSSEC true if the record was DNSSEC signed
     */
    void setSignedDNSSEC(final boolean signedDNSSEC);

    /**
     * The type of location the NUM record was received from.
     *
     * @return Location::INDEPENDENT, Location::MANAGED, Location::POPULATED
     */
    Location receivedFrom();

    /**
     * Tell the library user whether the record retrieved from DNS was encrypted or not.
     *
     * @param wasEncrypted true if the record retrieved from DNS was encrypted
     */
    void setWasEncrypted(final boolean wasEncrypted);

    /**
     * Tell the library user where the record was retrieved from.
     *
     * @param location Location::INDEPENDENT, Location::MANAGED, Location::POPULATED
     */
    void setLocation(final Location location);

    /**
     * The decryption key from the client application.
     *
     * @return a Key
     */
    Key getKey();

    /**
     * The decryption key set by the client application
     *
     * @param key a Key that matches the algorithm returned by the getAlgorithm() method.
     */
    void setKey(final Key key);

    /**
     * Accessor for the encryption algorithm.
     *
     * @return the encryption algorithm used by the NUM record
     */
    String getEncryptionAlgorithm();

    /**
     * This value is determined by the NUM API
     *
     * @param algorithm the encryption algorithm used by the NUM record
     */
    void setEncryptionAlgorithm(final String algorithm);

    /**
     * Accessor for the JSON result.
     *
     * @return the JSON result
     */
    String getResult();

    /**
     * Called when the result is available from DNS
     *
     * @param json The JSON String containing the result.
     */
    void setResult(final String json);


    /**
     * The type of location the NUM record was received from
     */
    enum Location {INDEPENDENT, MANAGED, POPULATOR, STOP, ENCRYPTED, POPULATED}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy