• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Glusk / srp6-variables / 178

pending completion
178

Pull #84

travis-ci-com

web-flow
Merge 2f052c477 into 5e89cf461
Pull Request #84: Make ctors code free

13 of 13 new or added lines in 4 files covered. (100.0%)

214 of 216 relevant lines covered (99.07%)

0.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/src/main/java/com.github.glusk.srp6_variables/com/github/glusk/srp6_variables/ZeroPadded.java
1
package com.github.glusk.srp6_variables;
2

3
import java.nio.ByteOrder;
4

5
import com.github.glusk.caesar.AbstractBytes;
6

7
/** A zero-padded SRP-6 Integer Variable Bytes view. */
8
public final class ZeroPadded extends AbstractBytes {
9
    /** An SRP-6 Integer Variable to zero-pad. */
10
    private final SRP6IntegerVariable variableToZeroPad;
11
    /**
12
     * The byte order to use when converting {@code variableToZeroPad}
13
     * to Bytes.
14
     */
15
    private final ByteOrder order;
16
    /**
17
     * {@code variableToZeroPad} will be zero-padded to
18
     * {@code variableToPadTo.bytes(order).asArray().length}.
19
     */
20
    private final SRP6IntegerVariable variableToPadTo;
21

22
    /**
23
     * Creates a new ZeroPadded Bytes object by wrapping
24
     * {@code variableToZeroPad}, {@code order}, and {@code} variableToPadTo}.
25
     *
26
     * @param variableToZeroPad an SRP-6 Integer Variable to zero-pad
27
     * @param order the byte order to use when converting
28
     *              {@code variableToZeroPad} to Bytes
29
     * @param variableToPadTo {@code variableToZeroPad} will be zero-padded to
30
     *                    {@code variableToPadTo.bytes(order).asArray().length}
31
     */
32
    @SuppressWarnings("checkstyle:hiddenfield")
33
    public ZeroPadded(
34
        final SRP6IntegerVariable variableToZeroPad,
35
        final ByteOrder order,
36
        final SRP6IntegerVariable variableToPadTo
37
    ) {
1✔
38
        this.variableToZeroPad = variableToZeroPad;
1✔
39
        this.order = order;
1✔
40
        this.variableToPadTo = variableToPadTo;
1✔
41
    }
1✔
42
    /**
43
     * {@inheritDoc}
44
     *
45
     * @throws IllegalStateException If {@code variableToZeroPad} has a
46
     * greater byte length than {@code variableToPadTo}, an
47
     * {@code SRP6PaddingException} gets thrown. This method catches it and
48
     * re-throws it as an {@code IllegalStateException}. More info:
49
     * {@linkplain SRP6IntegerVariable#bytes(ByteOrder,int)}
50
     */
51
    @Override
52
    public byte[] asArray() throws IllegalStateException {
53
        try {
54
            return this.variableToZeroPad.bytes(
1✔
55
                this.order,
56
                this.variableToPadTo.bytes(this.order).asArray().length
1✔
57
            ).asArray();
1✔
58
        } catch (SRP6PaddingException e) {
×
59
            throw new IllegalStateException("Failed to zero-pad", e);
×
60
        }
61
    }
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc