Remove OAuth2 remnants 68/104968/5
authorOleksandrZharov <Oleksandr.Zharov@pantheon.tech>
Mon, 20 Mar 2023 09:42:53 +0000 (10:42 +0100)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Mon, 20 Mar 2023 15:22:06 +0000 (15:22 +0000)
Removed code related to tokens and their validation from
TokenAuthRealm class - OAuth2 is gone so we don't need it.

JIRA: AAA-255
Change-Id: I67e1a155c70f6ea8a328676bd462acd97332d58b
Signed-off-by: OleksandrZharov <Oleksandr.Zharov@pantheon.tech>
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/realm/TokenAuthRealm.java

index 18733487cb1869f7dffe42f8d8dabff572e71619..372e14a9f59af2c0ea4739a5accf67934f5e230a 100644 (file)
@@ -125,7 +125,6 @@ public class TokenAuthRealm extends AuthorizingRealm {
                 "{\"error\":\"Only basic authentication is supported by TokenAuthRealm\"}", e);
         }
 
-        // if the password is empty, this is an OAuth2 request, not a Basic HTTP Auth request
         if (!Strings.isNullOrEmpty(password)) {
             Map<String, List<String>> headers = HeaderUtils.formHeaders(username, password, domain);
             // iterate over <code>TokenAuth</code> implementations and
@@ -149,30 +148,7 @@ public class TokenAuthRealm extends AuthorizingRealm {
             }
         }
 
-        // extract the authentication token and attempt validation of the token
-        final String token = TokenUtils.extractUsername(authenticationToken);
-        try {
-            final Authentication auth = validate(token);
-            final ODLPrincipal odlPrincipal = ODLPrincipalImpl.createODLPrincipal(auth);
-            return new SimpleAuthenticationInfo(odlPrincipal, "", getName());
-        } catch (AuthenticationException e) {
-            LOG.debug("Unknown OAuth2 Token Access Request", e);
-        }
-
         LOG.debug("Authentication failed: exhausted TokenAuth resources");
         return null;
     }
-
-    private Authentication validate(final String token) {
-        if (tokenStore == null) {
-            throw new AuthenticationException("Token store not available, could not validate the token " + token);
-        }
-
-        final Authentication auth = tokenStore.get(token);
-        if (auth == null) {
-            throw new AuthenticationException("Could not validate the token " + token);
-        }
-        authService.set(auth);
-        return auth;
-    }
 }