You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2020/01/14 08:39:22 UTC
[tomcat] branch master updated: Add deprecated constructors
This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new e680e0a Add deprecated constructors
e680e0a is described below
commit e680e0a83312aebc257c67c844f897a633aaac70
Author: remm <re...@apache.org>
AuthorDate: Tue Jan 14 09:39:11 2020 +0100
Add deprecated constructors
Also add a new constructor with only the principal name. Resolve
ambiguous calls from (name, null, null) to (name). Revert
cb791c14e5760247a0bfd585b67a48e2494e4323.
This will not give 100% compatibility with custom realms for Tomcat 9,
but once the ambiguous calls are resolved it is possible to have code
compatible with both branches.
---
.../catalina/authenticator/AuthenticatorBase.java | 2 +-
.../catalina/realm/AuthenticatedUserRealm.java | 2 +-
.../apache/catalina/realm/GenericPrincipal.java | 35 ++++++++++++++++++++++
.../catalina/realm/JAASMemoryLoginModule.java | 2 +-
4 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/catalina/authenticator/AuthenticatorBase.java b/java/org/apache/catalina/authenticator/AuthenticatorBase.java
index 4fc5d56..00a02a8 100644
--- a/java/org/apache/catalina/authenticator/AuthenticatorBase.java
+++ b/java/org/apache/catalina/authenticator/AuthenticatorBase.java
@@ -1024,7 +1024,7 @@ public abstract class AuthenticatorBase extends ValveBase
if (log.isDebugEnabled()) {
log.debug(sm.getString("authenticator.check.authorizeFail", username));
}
- authorized = new GenericPrincipal(username, null, null);
+ authorized = new GenericPrincipal(username);
}
String authType = request.getAuthType();
if (authType == null || authType.length() == 0) {
diff --git a/java/org/apache/catalina/realm/AuthenticatedUserRealm.java b/java/org/apache/catalina/realm/AuthenticatedUserRealm.java
index 96abe6c..ab6c4b9 100644
--- a/java/org/apache/catalina/realm/AuthenticatedUserRealm.java
+++ b/java/org/apache/catalina/realm/AuthenticatedUserRealm.java
@@ -41,6 +41,6 @@ public class AuthenticatedUserRealm extends RealmBase {
protected Principal getPrincipal(String username) {
// The authentication mechanism has authenticated the user so create
// the Principal directly
- return new GenericPrincipal(username, null, null);
+ return new GenericPrincipal(username);
}
}
diff --git a/java/org/apache/catalina/realm/GenericPrincipal.java b/java/org/apache/catalina/realm/GenericPrincipal.java
index 1c29f5c..560b123 100644
--- a/java/org/apache/catalina/realm/GenericPrincipal.java
+++ b/java/org/apache/catalina/realm/GenericPrincipal.java
@@ -41,6 +41,16 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable {
/**
* Construct a new Principal, associated with the specified Realm, for the
+ * specified username, with no roles.
+ *
+ * @param name The username of the user represented by this Principal
+ */
+ public GenericPrincipal(String name) {
+ this(name, null);
+ }
+
+ /**
+ * Construct a new Principal, associated with the specified Realm, for the
* specified username, with the specified role names (as Strings).
*
* @param name The username of the user represented by this Principal
@@ -50,6 +60,11 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable {
this(name, roles, null);
}
+ @Deprecated
+ public GenericPrincipal(String name, String password, List<String> roles) {
+ this(name, roles, null);
+ }
+
/**
* Construct a new Principal, associated with the specified Realm, for the
* specified username, with the specified role names (as Strings).
@@ -64,6 +79,12 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable {
this(name, roles, userPrincipal, null);
}
+ @Deprecated
+ public GenericPrincipal(String name, String password, List<String> roles,
+ Principal userPrincipal) {
+ this(name, roles, userPrincipal, null);
+ }
+
/**
* Construct a new Principal, associated with the specified Realm, for the
* specified username, with the specified role names (as Strings).
@@ -80,6 +101,12 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable {
this(name, roles, userPrincipal, loginContext, null);
}
+ @Deprecated
+ public GenericPrincipal(String name, String password, List<String> roles,
+ Principal userPrincipal, LoginContext loginContext) {
+ this(name, roles, userPrincipal, loginContext, null);
+ }
+
/**
* Construct a new Principal, associated with the specified Realm, for the
* specified username, with the specified role names (as Strings).
@@ -111,6 +138,14 @@ public class GenericPrincipal implements TomcatPrincipal, Serializable {
}
+ @Deprecated
+ public GenericPrincipal(String name, String password, List<String> roles,
+ Principal userPrincipal, LoginContext loginContext,
+ GSSCredential gssCredential) {
+ this(name, roles, userPrincipal, loginContext, gssCredential);
+ }
+
+
// -------------------------------------------------------------- Properties
/**
diff --git a/java/org/apache/catalina/realm/JAASMemoryLoginModule.java b/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
index a228003..75003f5 100644
--- a/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
+++ b/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
@@ -197,7 +197,7 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule {
if (principal instanceof GenericPrincipal) {
String roles[] = ((GenericPrincipal) principal).getRoles();
for (int i = 0; i < roles.length; i++) {
- subject.getPrincipals().add(new GenericPrincipal(roles[i], null, null));
+ subject.getPrincipals().add(new GenericPrincipal(roles[i]));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org