|
@@ -222,23 +222,67 @@ public class Token<T extends TokenIdentifier> implements Writable {
|
|
|
service = newService;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Whether this is a private token.
|
|
|
+ * @return false always for non-private tokens
|
|
|
+ */
|
|
|
+ public boolean isPrivate() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Whether this is a private clone of a public token.
|
|
|
+ * @param thePublicService the public service name
|
|
|
+ * @return false always for non-private tokens
|
|
|
+ */
|
|
|
+ public boolean isPrivateCloneOf(Text thePublicService) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Create a private clone of a public token.
|
|
|
+ * @param newService the new service name
|
|
|
+ * @return a private token
|
|
|
+ */
|
|
|
+ public Token<T> privateClone(Text newService) {
|
|
|
+ return new PrivateToken<>(this, newService);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Indicates whether the token is a clone. Used by HA failover proxy
|
|
|
* to indicate a token should not be visible to the user via
|
|
|
* UGI.getCredentials()
|
|
|
*/
|
|
|
- @InterfaceAudience.Private
|
|
|
- @InterfaceStability.Unstable
|
|
|
- public static class PrivateToken<T extends TokenIdentifier> extends Token<T> {
|
|
|
+ static class PrivateToken<T extends TokenIdentifier> extends Token<T> {
|
|
|
final private Text publicService;
|
|
|
|
|
|
- public PrivateToken(Token<T> token) {
|
|
|
- super(token);
|
|
|
- publicService = new Text(token.getService());
|
|
|
+ PrivateToken(Token<T> publicToken, Text newService) {
|
|
|
+ super(publicToken.identifier, publicToken.password, publicToken.kind,
|
|
|
+ newService);
|
|
|
+ assert !publicToken.isPrivate();
|
|
|
+ publicService = publicToken.service;
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
+ LOG.debug("Cloned private token " + this + " from " + publicToken);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public Text getPublicService() {
|
|
|
- return publicService;
|
|
|
+ /**
|
|
|
+ * Whether this is a private token.
|
|
|
+ * @return true always for private tokens
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean isPrivate() {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Whether this is a private clone of a public token.
|
|
|
+ * @param thePublicService the public service name
|
|
|
+ * @return true when the public service is the same as specified
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean isPrivateCloneOf(Text thePublicService) {
|
|
|
+ return publicService.equals(thePublicService);
|
|
|
}
|
|
|
|
|
|
@Override
|