-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a command to test the mail system. Additionally, some unused string resources were removed, and a missing string resource was added. Also, the documentation now correctly imports the missing monitoring chapter. Fix: #76
- Loading branch information
Showing
39 changed files
with
1,411 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...dstore.documentation/src/main/resources/com/io7m/idstore/documentation/scmd-mail-test.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<Section id="157840ab-7cc0-434a-a6a5-ee2fdbfd2848" title="mail-test" xmlns="urn:com.io7m.structural:8:0"> | ||
<Subsection title="Name"> | ||
<Paragraph> | ||
<Term type="command">mail-test</Term> | ||
- Send a test email. | ||
</Paragraph> | ||
</Subsection> | ||
<Subsection title="Description"> | ||
<Paragraph> | ||
The | ||
<Term type="command">mail-test</Term> | ||
command checks to see if the mail system is working by sending a test email. | ||
</Paragraph> | ||
<Paragraph> | ||
For obvious reasons, the command can only check that the <Term type="package">idstore</Term> | ||
server is capable of sending mail through its configured mail service - it cannot automatically | ||
verify that the target will actually receive the sent mail. | ||
</Paragraph> | ||
<FormalItem title="Parameters"> | ||
<Table type="parameterTable"> | ||
<Columns> | ||
<Column>Parameter</Column> | ||
<Column>Type</Column> | ||
<Column>Cardinality</Column> | ||
<Column>Default</Column> | ||
<Column>Description</Column> | ||
</Columns> | ||
<Row> | ||
<Cell> | ||
<Term type="parameter">--email</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="type">com.io7m.idstore.model.IdEmail</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="expression">[1]</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="constant"/> | ||
</Cell> | ||
<Cell>The target email address.</Cell> | ||
</Row> | ||
<Row> | ||
<Cell> | ||
<Term type="parameter">--token</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="type">com.io7m.idstore.model.IdShortHumanToken</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="expression">[0, 1]</Term> | ||
</Cell> | ||
<Cell> | ||
<Term type="constant"/> | ||
</Cell> | ||
<Cell>The short token to include in the email. If a value is not provided, one is randomly generated.</Cell> | ||
</Row> | ||
</Table> | ||
</FormalItem> | ||
</Subsection> | ||
<Subsection title="Example"> | ||
<FormalItem title="Example"> | ||
<Verbatim><![CDATA[[idstore]# mail-test --email user@example.com | ||
Mail sent successfully. | ||
Token: 220384 | ||
]]></Verbatim> | ||
</FormalItem> | ||
</Subsection> | ||
</Section> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
com.io7m.idstore.model/src/main/java/com/io7m/idstore/model/IdShortHumanToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright © 2023 Mark Raynsford <code@io7m.com> https://www.io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package com.io7m.idstore.model; | ||
|
||
import java.security.NoSuchAlgorithmException; | ||
import java.security.SecureRandom; | ||
import java.util.Objects; | ||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* A short human-readable token. | ||
* | ||
* @param value The token string | ||
*/ | ||
|
||
public record IdShortHumanToken(String value) | ||
{ | ||
/** | ||
* The pattern that defines a valid token. | ||
*/ | ||
|
||
public static final Pattern VALID_NUMBER = | ||
Pattern.compile("[0-9]{6}"); | ||
|
||
/** | ||
* A generic token. | ||
* | ||
* @param value The token string | ||
*/ | ||
|
||
public IdShortHumanToken | ||
{ | ||
Objects.requireNonNull(value, "value"); | ||
|
||
if (!VALID_NUMBER.matcher(value).matches()) { | ||
throw new IdValidityException( | ||
"Token value %s must match %s".formatted(value, VALID_NUMBER)); | ||
} | ||
} | ||
|
||
/** | ||
* Generate a random token. | ||
* | ||
* @param random The secure random instance | ||
* | ||
* @return A random token | ||
*/ | ||
|
||
public static IdShortHumanToken generate( | ||
final SecureRandom random) | ||
{ | ||
Objects.requireNonNull(random, "random"); | ||
|
||
final var builder = new StringBuilder(6); | ||
for (int index = 0; index < 6; ++index) { | ||
builder.append(random.nextInt(10)); | ||
} | ||
return new IdShortHumanToken(builder.toString()); | ||
} | ||
|
||
/** | ||
* Generate a random token, using a default strong RNG instance. | ||
* | ||
* @return A random token | ||
*/ | ||
|
||
public static IdShortHumanToken generate() | ||
{ | ||
try { | ||
return generate(SecureRandom.getInstanceStrong()); | ||
} catch (final NoSuchAlgorithmException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return this.value; | ||
} | ||
} |
Oops, something went wrong.