1 module hunt.security.Principal;
2 
3 // import hunt.Object;
4 import hunt.security.Subject;
5 
6 /**
7  * This interface represents the abstract notion of a principal, which
8  * can be used to represent any entity, such as an individual, a
9  * corporation, and a login id.
10  *
11  * @see java.security.cert.X509Certificate
12  */
13 interface Principal {
14 
15     /**
16      * Compares this principal to the specified object.  Returns true
17      * if the object passed in matches the principal represented by
18      * the implementation of this interface.
19      *
20      * @param another principal to compare with.
21      *
22      * @return true if the principal passed in is the same as that
23      * encapsulated by this principal, and false otherwise.
24      */
25     // bool opEquals(Object another);
26 
27     /**
28      * Returns a string representation of this principal.
29      *
30      * @return a string representation of this principal.
31      */
32     // string toString();
33 
34     /**
35      * Returns a hashcode for this principal.
36      *
37      * @return a hashcode for this principal.
38      */
39     // size_t toHash() @trusted nothrow;
40 
41     /**
42      * Returns the name of this principal.
43      *
44      * @return the name of this principal.
45      */
46     string getName();
47 
48     /**
49      * Returns true if the specified subject is implied by this principal.
50      *
51      * <p>The default implementation of this method returns true if
52      * {@code subject} is non-null and contains at least one principal that
53      * is equal to this principal.
54      *
55      * <p>Subclasses may override this with a different implementation, if
56      * necessary.
57      *
58      * @param subject the {@code Subject}
59      * @return true if {@code subject} is non-null and is
60      *              implied by this principal, or false otherwise.
61      * @since 1.8
62      */
63     // bool implies(Subject subject);
64     // {
65     //     if (subject is null)
66     //         return false;
67     //     return subject.getPrincipals().contains(this);
68     // }
69 }