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

Commit 9aa0f7a

Browse files
committed
Support any principal type for notifyContainerAboutLogin() and getCallerPrincipal().
1 parent 83172f4 commit 9aa0f7a

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanism.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
*
6767
* <p>
6868
* Implementations of this class can notify the Servlet container about a succesful authentication by using the
69-
* {@link HttpMessageContext#notifyContainerAboutLogin(javax.security.enterprise.CallerPrincipal, java.util.Set)} method.
69+
* {@link HttpMessageContext#notifyContainerAboutLogin(java.security.Principal, java.util.Set)} method.
7070
*
7171
* <p>
7272
* Implementations are expected and encouraged to delegate the actual credential validation and/or retrieval of the

src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpMessageContext.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
*/
4040
package javax.security.enterprise.authentication.mechanism.http;
4141

42+
import java.security.Principal;
4243
import java.util.Set;
4344

4445
import javax.security.auth.Subject;
@@ -268,12 +269,12 @@ public interface HttpMessageContext {
268269
* As a convenience this method returns SUCCESS, so this method can be used in
269270
* one fluent return statement from an {@link HttpAuthenticationMechanism}
270271
*
271-
* @param callerPrincipal the CallerPrincipal that will become the caller principal
272+
* @param principal the Principal that will become the caller principal
272273
* @param groups the groups associated with the caller principal
273274
* @return {@link AuthenticationStatus#SUCCESS}
274275
*
275276
*/
276-
AuthenticationStatus notifyContainerAboutLogin(CallerPrincipal callerPrincipal, Set<String> groups);
277+
AuthenticationStatus notifyContainerAboutLogin(Principal principal, Set<String> groups);
277278

278279
/**
279280
* Convenience method intended to pass the <code>CredentialValidationResult</code> result of an
@@ -283,7 +284,7 @@ public interface HttpMessageContext {
283284
* If the outcome from the given {@link CredentialValidationResult#getStatus()} equals
284285
* {@link Status#VALID}, the {@link CallerPrincipal} and groups are obtained from the
285286
* <code>CredentialValidationResult</code> and passed into
286-
* {@link HttpMessageContext#notifyContainerAboutLogin(CallerPrincipal, Set)}.
287+
* {@link HttpMessageContext#notifyContainerAboutLogin(Principal, Set)}.
287288
*
288289
* <p>
289290
* If the outcome from the given {@link CredentialValidationResult#getStatus()} is not
@@ -313,8 +314,18 @@ public interface HttpMessageContext {
313314
*/
314315
AuthenticationStatus doNothing();
315316

316-
CallerPrincipal getCallerPrincipal();
317+
/**
318+
* Gets the Principal set by a call to notifyContainerAboutLogin().
319+
*
320+
* @return The caller principal
321+
*/
322+
Principal getCallerPrincipal();
317323

324+
/**
325+
* Gets the groups set by a call to notifyContainerAboutLogin().
326+
*
327+
* @return The groups
328+
*/
318329
Set<String> getGroups();
319330

320331
}

src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpMessageContextWrapper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
*/
4040
package javax.security.enterprise.authentication.mechanism.http;
4141

42+
import java.security.Principal;
4243
import java.util.Set;
4344

4445
import javax.security.auth.Subject;
4546
import javax.security.auth.callback.CallbackHandler;
4647
import javax.security.auth.message.MessageInfo;
4748
import javax.security.enterprise.AuthenticationStatus;
48-
import javax.security.enterprise.CallerPrincipal;
4949
import javax.security.enterprise.identitystore.CredentialValidationResult;
5050
import javax.servlet.http.HttpServletRequest;
5151
import javax.servlet.http.HttpServletResponse;
@@ -166,8 +166,8 @@ public AuthenticationStatus notifyContainerAboutLogin(String username, Set<Strin
166166
}
167167

168168
@Override
169-
public AuthenticationStatus notifyContainerAboutLogin(CallerPrincipal callerPrincipal, Set<String> roles) {
170-
return getWrapped().notifyContainerAboutLogin(callerPrincipal, roles);
169+
public AuthenticationStatus notifyContainerAboutLogin(Principal principal, Set<String> roles) {
170+
return getWrapped().notifyContainerAboutLogin(principal, roles);
171171
}
172172

173173
@Override
@@ -181,7 +181,7 @@ public AuthenticationStatus doNothing() {
181181
}
182182

183183
@Override
184-
public CallerPrincipal getCallerPrincipal() {
184+
public Principal getCallerPrincipal() {
185185
return getWrapped().getCallerPrincipal();
186186
}
187187

0 commit comments

Comments
 (0)