summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/certsrv/ca/AuthorityID.java
blob: 9816f87ad02289739c7ff90be1ffc71e086a2bd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.netscape.certsrv.ca;

import java.util.UUID;

/**
 * Identifier for a CertificateAuthority.
 */
public class AuthorityID implements Comparable<AuthorityID> {

    protected UUID uuid;

    /**
     * Parse a AuthorityID from the given string
     */
    public AuthorityID(String s) {
        if (s == null)
            throw new IllegalArgumentException("null AuthorityID string");
        uuid = UUID.fromString(s);
    }

    /**
     * Construct a random AuthorityID
     */
    public AuthorityID() {
        uuid = UUID.randomUUID();
    }

    public String toString() {
        return uuid.toString();
    }

    public boolean equals(AuthorityID aid) {
        return this.compareTo(aid) == 0;
    }

    public int compareTo(AuthorityID aid) {
        return uuid.compareTo(aid.uuid);
    }

}