Skip to content

Fix Javadoc and reenable maven-javadoc-plugin failOnError #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
617 changes: 308 additions & 309 deletions pom.xml

Large diffs are not rendered by default.

103 changes: 52 additions & 51 deletions src/main/java/org/interledger/connector/Connector.java
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
package org.interledger.connector;


import org.interledger.connector.config.ConnectorConfigurationService;
import org.interledger.connector.services.LedgerPluginManager;

/**
* This interface defines an Interledger Connector, which orchestrates any two ledgers to facilitate an Interledger
* payment.
*
* <p>The Connector serves three primary purposes:</p>
*
* <pre>
* 1. To hold accounts on various ledgers so that it can provide liquidity across ledgers.
* 3. To provide route information and routing updates to other connectors.
* 3. To provide quotes for a given ledger-to-ledger transfer.
* </pre>
*
* <p>Interledger Payments moves asset representations (e.g., currency, stock, IOUs, gold, etc) from one party to
* another by utilizing one or more ledger transfers, potentially across multiple ledgers.</p>
*
* <p> When a sender prepares a transfer on a Ledger to start a payment, the sender attaches an ILP Payment to the
* ledger transfer, in the memo field if possible. If a ledger does not support attaching the entire ILP Payment to a
* transfer as a memo, users of that ledger can transmit the ILP Payment using another authenticated messaging channel,
* but MUST be able to correlate transfers and ILP Payments.</p>
*
* <p> When a connector sees an incoming prepared transfer with an ILP Payment, it reads the ILP Payment information to
* confirm the details of the packet. For example, the connector reads the InterledgerAddress of the payment's receiver,
* and if the connector has a route to the receiver's account, the connector prepares a transfer to continue the payment
* chain by attaching the same ILP Payment to the new transfer.</p>
*
* <p>At the end of the payment chain, the final receiver (or, more likely, that ledger acting on behalf of the final
* receiver) confirms that the amount in the ILP Payment Packet matches the amount actually delivered by the transfer.
* Finally, the last-hop ledger decodes the data portion of the Payment and matches the condition to the payment. The
* final Interledger node MUST confirm the integrity of the ILP Payment, for example with a hash-based message
* authentication code (HMAC). If the receiver finds the transfer acceptable, the receiver releases the fulfillment for
* the transfer, which can be used to execute all prepared transfers that were established prior to the receiver
* accepting the payment.</p>
*/
public interface Connector<T extends ConnectorConfigurationService> {

/**
* Accessor for the {@link LedgerPluginManager} that is used to centralize all interactions with ledger plugins for a
* given Connector.
*/
LedgerPluginManager getLedgerPluginManager();

T getConnectorConfigurationService();

// TODO: Router, Quoter

package org.interledger.connector;


import org.interledger.connector.config.ConnectorConfigurationService;
import org.interledger.connector.services.LedgerPluginManager;

/**
* This interface defines an Interledger Connector, which orchestrates any two ledgers to facilitate an Interledger
* payment.
*
* <p>The Connector serves three primary purposes:</p>
*
* <pre>
* 1. To hold accounts on various ledgers so that it can provide liquidity across ledgers.
* 3. To provide route information and routing updates to other connectors.
* 3. To provide quotes for a given ledger-to-ledger transfer.
* </pre>
*
* <p>Interledger Payments moves asset representations (e.g., currency, stock, IOUs, gold, etc) from one party to
* another by utilizing one or more ledger transfers, potentially across multiple ledgers.</p>
*
* <p> When a sender prepares a transfer on a Ledger to start a payment, the sender attaches an ILP Payment to the
* ledger transfer, in the memo field if possible. If a ledger does not support attaching the entire ILP Payment to a
* transfer as a memo, users of that ledger can transmit the ILP Payment using another authenticated messaging channel,
* but MUST be able to correlate transfers and ILP Payments.</p>
*
* <p> When a connector sees an incoming prepared transfer with an ILP Payment, it reads the ILP Payment information to
* confirm the details of the packet. For example, the connector reads the InterledgerAddress of the payment's receiver,
* and if the connector has a route to the receiver's account, the connector prepares a transfer to continue the payment
* chain by attaching the same ILP Payment to the new transfer.</p>
*
* <p>At the end of the payment chain, the final receiver (or, more likely, that ledger acting on behalf of the final
* receiver) confirms that the amount in the ILP Payment Packet matches the amount actually delivered by the transfer.
* Finally, the last-hop ledger decodes the data portion of the Payment and matches the condition to the payment. The
* final Interledger node MUST confirm the integrity of the ILP Payment, for example with a hash-based message
* authentication code (HMAC). If the receiver finds the transfer acceptable, the receiver releases the fulfillment for
* the transfer, which can be used to execute all prepared transfers that were established prior to the receiver
* accepting the payment.</p>
*/
public interface Connector<T extends ConnectorConfigurationService> {

/**
* Accessor for the {@link LedgerPluginManager} that is used to centralize all interactions with ledger plugins for a
* given Connector.
* @return {@link LedgerPluginManager}
*/
LedgerPluginManager getLedgerPluginManager();

T getConnectorConfigurationService();

// TODO: Router, Quoter

}
128 changes: 64 additions & 64 deletions src/main/java/org/interledger/connector/ConnectorUtils.java
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
package org.interledger.connector;

import org.interledger.InterledgerAddress;
import org.interledger.plugin.lpi.TransferId;

import com.google.common.io.BaseEncoding;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Objects;
import java.util.UUID;

/**
* Various utilities that might be useful to consumers of this library.
*/
public class ConnectorUtils {

/**
* Using HMAC-SHA-256, deterministically generate a UUID from a secret and a public input, which in this case is a
* ledger-prefix and a transferId.
*
* This method can be used to generate a deterministic identifier for the "next" transfer that a Connector might make,
* so that the connector doesn't send duplicate outgoing transfers if it receives duplicate notifications. In the case
* of a Connector's next-hop transfer identifier, the deterministic generation should ideally be impossible for a
* third party to predict. Otherwise an attacker might be able to squat on a predicted ID in order to interfere with a
* payment or make a connector look unreliable. In order to assure this, the connector may use a secret that seeds the
* deterministic ID generation.
*
* @param secret A {@link String} containing secret information known only to the creator of this transfer id.
* @param ledgerPrefix A {@link InterledgerAddress} containing a ledger prefix.
* @param transferId A {@link TransferId} that uniquely identifies the transfer.
*
* @returns A deterministically generated {@link UUID}.
**/
public static TransferId generateTransferId(
final String secret, final InterledgerAddress ledgerPrefix, final TransferId transferId
) {
Objects.requireNonNull(secret);
Objects.requireNonNull(ledgerPrefix);
InterledgerAddress.requireLedgerPrefix(ledgerPrefix);
Objects.requireNonNull(transferId);

final String publicInput = String.format("%s/%s", ledgerPrefix, transferId);

try {
final MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
messageDigest.update(secret.getBytes());
byte[] digest = messageDigest.digest(publicInput.getBytes());

final String hash = BaseEncoding.base16().encode(digest).substring(0, 36);
final char[] hashCharArray = hash.toCharArray();
hashCharArray[8] = '-';
hashCharArray[13] = '-';
hashCharArray[14] = '4';
hashCharArray[18] = '-';
hashCharArray[19] = '8';
hashCharArray[23] = '-';
return TransferId.of(UUID.fromString(new String(hashCharArray)));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}

}
}
package org.interledger.connector;
import org.interledger.InterledgerAddress;
import org.interledger.plugin.lpi.TransferId;
import com.google.common.io.BaseEncoding;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Objects;
import java.util.UUID;
/**
* Various utilities that might be useful to consumers of this library.
*/
public class ConnectorUtils {
/**
* Using HMAC-SHA-256, deterministically generate a UUID from a secret and a public input, which in this case is a
* ledger-prefix and a transferId.
*
* This method can be used to generate a deterministic identifier for the "next" transfer that a Connector might make,
* so that the connector doesn't send duplicate outgoing transfers if it receives duplicate notifications. In the case
* of a Connector's next-hop transfer identifier, the deterministic generation should ideally be impossible for a
* third party to predict. Otherwise an attacker might be able to squat on a predicted ID in order to interfere with a
* payment or make a connector look unreliable. In order to assure this, the connector may use a secret that seeds the
* deterministic ID generation.
*
* @param secret A {@link String} containing secret information known only to the creator of this transfer id.
* @param ledgerPrefix A {@link InterledgerAddress} containing a ledger prefix.
* @param transferId A {@link TransferId} that uniquely identifies the transfer.
*
* @return A deterministically generated {@link UUID}.
**/
public static TransferId generateTransferId(
final String secret, final InterledgerAddress ledgerPrefix, final TransferId transferId
) {
Objects.requireNonNull(secret);
Objects.requireNonNull(ledgerPrefix);
InterledgerAddress.requireLedgerPrefix(ledgerPrefix);
Objects.requireNonNull(transferId);
final String publicInput = String.format("%s/%s", ledgerPrefix, transferId);
try {
final MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
messageDigest.update(secret.getBytes());
byte[] digest = messageDigest.digest(publicInput.getBytes());
final String hash = BaseEncoding.base16().encode(digest).substring(0, 36);
final char[] hashCharArray = hash.toCharArray();
hashCharArray[8] = '-';
hashCharArray[13] = '-';
hashCharArray[14] = '4';
hashCharArray[18] = '-';
hashCharArray[19] = '8';
hashCharArray[23] = '-';
return TransferId.of(UUID.fromString(new String(hashCharArray)));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
}
39 changes: 20 additions & 19 deletions src/main/java/org/interledger/connector/config/ConnectorConfig.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package org.interledger.connector.config;

/**
* Defines Connector-wide configuration properties that affect the connector as a whole.
*/
public interface ConnectorConfig {

/**
* The minimum time, in seconds, that the connector wants to budget for getting a message to the ledgers its trading
* on.
*
* Defaults to 1 second.
*/
default Integer getMinimumMessageWindow() {
return 1;
}


}
package org.interledger.connector.config;

/**
* Defines Connector-wide configuration properties that affect the connector as a whole.
*/
public interface ConnectorConfig {

/**
* The minimum time, in seconds, that the connector wants to budget for getting a message to the ledgers its trading
* on.
*
* Defaults to 1 second.
* @return Integer
*/
default Integer getMinimumMessageWindow() {
return 1;
}


}
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
package org.interledger.connector.config;

import org.interledger.InterledgerAddress;
import org.interledger.connector.services.LedgerPluginManager;
import org.interledger.plugin.lpi.LedgerPluginConfig;

import java.util.Collection;

/**
* A configuration service that provides typed (and runtime-reloadable) access to important configuration properties for
* _this_ connector.
*/
public interface ConnectorConfigurationService<T extends ConnectorConfig> {

/**
* Accessor for Connector-wide configuration values.
*/
T getConnectorConfig();

/**
* Accessor for all currently configured ledger plugins.
*
* Note that this list does not necessarily reflect the current status of a connection to any underlying ledger, but
* instead merely represents information about the current configuration (whereas the current state of the connector,
* such as the availability of a given ledger plugin due to downtime) is managed by a separate service.
*
* @return A {@link Collection} of type {@link LedgerPluginConfig} for all configured ledger plugins.
*/
Collection<? extends LedgerPluginConfig> getLedgerPluginConfigurations();

/**
* Return configuration info for the ledger plugin indicated by the supplied {@code ledgerPrefix}. This interface
* returns only some typed configuration properties, with any other properties contained in {@link
* LedgerPluginConfig#getOptions()}. Implementations can write adaptor classes to access these properties in a typed
* fashion.
*
* Note that this list does not necessarily reflect the current status of a connection to any underlying ledger, but
* instead merely represents information about the current configuration (whereas the current state of the connector,
* such as the availability of a given ledger plugin due to downtime) is managed by the {@link LedgerPluginManager}
* and the plugin itself.
*
* @param ledgerPrefix An {@link InterledgerAddress} that is a ledger-prefix for a ledger that this connector has an
* account on.
*
* @return A {@link LedgerPluginConfig} for the specified ledger prefix.
*
* @throws RuntimeException if ledger-plugin configuration cannot be found or otherwise assembled.
*/
LedgerPluginConfig getLedgerPluginConfiguration(InterledgerAddress ledgerPrefix);

}
package org.interledger.connector.config;

import org.interledger.InterledgerAddress;
import org.interledger.connector.services.LedgerPluginManager;
import org.interledger.plugin.lpi.LedgerPluginConfig;

import java.util.Collection;

/**
* A configuration service that provides typed (and runtime-reloadable) access to important configuration properties for
* _this_ connector.
*/
public interface ConnectorConfigurationService<T extends ConnectorConfig> {

/**
* Accessor for Connector-wide configuration values.
* @return Generic Type T of {@link ConnectorConfig}
*/
T getConnectorConfig();

/**
* Accessor for all currently configured ledger plugins.
*
* Note that this list does not necessarily reflect the current status of a connection to any underlying ledger, but
* instead merely represents information about the current configuration (whereas the current state of the connector,
* such as the availability of a given ledger plugin due to downtime) is managed by a separate service.
*
* @return A {@link Collection} of type {@link LedgerPluginConfig} for all configured ledger plugins.
*/
Collection<? extends LedgerPluginConfig> getLedgerPluginConfigurations();

/**
* Return configuration info for the ledger plugin indicated by the supplied {@code ledgerPrefix}. This interface
* returns only some typed configuration properties, with any other properties contained in {@link
* LedgerPluginConfig#getOptions()}. Implementations can write adaptor classes to access these properties in a typed
* fashion.
*
* Note that this list does not necessarily reflect the current status of a connection to any underlying ledger, but
* instead merely represents information about the current configuration (whereas the current state of the connector,
* such as the availability of a given ledger plugin due to downtime) is managed by the {@link LedgerPluginManager}
* and the plugin itself.
*
* @param ledgerPrefix An {@link InterledgerAddress} that is a ledger-prefix for a ledger that this connector has an
* account on.
*
* @return A {@link LedgerPluginConfig} for the specified ledger prefix.
*
* @throws RuntimeException if ledger-plugin configuration cannot be found or otherwise assembled.
*/
LedgerPluginConfig getLedgerPluginConfiguration(InterledgerAddress ledgerPrefix);

}
Loading