Skip to content
This repository was archived by the owner on May 11, 2018. It is now read-only.

Commit 83172f4

Browse files
committed
Add getPrincipalsByType() method.
1 parent 4f64647 commit 83172f4

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

src/main/java/javax/security/enterprise/SecurityContext.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
package javax.security.enterprise;
4141

4242
import java.security.Principal;
43+
import java.util.Set;
4344

4445
import javax.ejb.SessionContext;
4546
import javax.security.enterprise.authentication.mechanism.http.AuthenticationParameters;
@@ -62,17 +63,27 @@
6263
public interface SecurityContext {
6364

6465
/**
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.
7168
*
7269
* @return Principal representing the name of the current authenticated user, or null if not authenticated.
7370
*/
7471
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+
7687
/**
7788
* Checks whether the authenticated caller is included in the specified logical <em>application</em> "role".
7889
* If the caller is not authenticated, this always returns <code>false</code>.

0 commit comments

Comments
 (0)