|
40 | 40 | package javax.security.enterprise; |
41 | 41 |
|
42 | 42 | import java.security.Principal; |
| 43 | +import java.util.Set; |
43 | 44 |
|
44 | 45 | import javax.ejb.SessionContext; |
45 | 46 | import javax.security.enterprise.authentication.mechanism.http.AuthenticationParameters; |
|
62 | 63 | public interface SecurityContext { |
63 | 64 |
|
64 | 65 | /** |
65 | | - * Retrieve the <code>java.security.Principal</code> that represents the name of authenticated caller name, or null |
66 | | - * if the current caller is not authenticated. |
67 | | - * |
68 | | - * <p> |
69 | | - * The Principal can be downcasted to the exact Principal type that was set by the {@link HttpAuthenticationMechanism} |
70 | | - * (possibly via an {@link IdentityStore}) or a JASPIC ServerAuthModule. |
| 66 | + * Retrieve the platform-specific <code>java.security.Principal</code> that represents |
| 67 | + * the name of authenticated caller, or null if the current caller is not authenticated. |
71 | 68 | * |
72 | 69 | * @return Principal representing the name of the current authenticated user, or null if not authenticated. |
73 | 70 | */ |
74 | 71 | Principal getCallerPrincipal(); |
75 | | - |
| 72 | + |
| 73 | + /** |
| 74 | + * Retrieve all Principals of the given type from the authenticated caller's Subject, |
| 75 | + * or an empty set if the current caller is not authenticated, or if the specified type |
| 76 | + * isn't found in the Subject. |
| 77 | + * <p> |
| 78 | + * This can be used to retrieve application-specific |
| 79 | + * Principals when the platform's representation of the caller uses a different principal type. |
| 80 | + * |
| 81 | + * @param pType Class object representing the type of Principal to return. |
| 82 | + * |
| 83 | + * @return Set of Principals of the given type, or an empty set. |
| 84 | + */ |
| 85 | + <T extends Principal> Set<T> getPrincipalsByType(Class<T> pType); |
| 86 | + |
76 | 87 | /** |
77 | 88 | * Checks whether the authenticated caller is included in the specified logical <em>application</em> "role". |
78 | 89 | * If the caller is not authenticated, this always returns <code>false</code>. |
|
0 commit comments