test_class.declarator: userId
test_class.modifier: private
test_class.original_string: private String userId;
test_class.type: String
test_class.var_name: userId
test_class.declarator: authentication
test_class.modifier: private
test_class.original_string: private UserAuthentication authentication;
test_class.type: UserAuthentication
test_class.var_name: authentication
test_class.file: oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserAuthenticationTest.java
test_class.identifier: UserAuthenticationTest
test_class.superclass: extends AbstractSecurityTest
test_case.body: @Test
      public void testAuthenticateImpersonationCredentials2() throws Exception {
          SimpleCredentials sc = new SimpleCredentials(userId, new char[0]);
          assertTrue(authentication.authenticate(new ImpersonationCredentials(sc, mockAuthInfo(userId))));
      }
test_case.class_method_signature: UserAuthenticationTest.testAuthenticateImpersonationCredentials2()
test_case.full_signature: @Test public void testAuthenticateImpersonationCredentials2()
test_case.identifier: testAuthenticateImpersonationCredentials2
test_case.invocations: assertTrue authenticate mockAuthInfo
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testAuthenticateImpersonationCredentials2()
focal_class.declarator: log = LoggerFactory.getLogger(UserAuthentication.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(UserAuthentication.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: PARAM_PASSWORD_EXPIRY_FOR_ADMIN = "passwordExpiryForAdmin"
focal_class.modifier: public static final
focal_class.original_string: public static final String PARAM_PASSWORD_EXPIRY_FOR_ADMIN = "passwordExpiryForAdmin";
focal_class.type: String
focal_class.var_name: PARAM_PASSWORD_EXPIRY_FOR_ADMIN
focal_class.declarator: config
focal_class.modifier: private final
focal_class.original_string: private final UserConfiguration config;
focal_class.type: UserConfiguration
focal_class.var_name: config
focal_class.declarator: root
focal_class.modifier: private final
focal_class.original_string: private final Root root;
focal_class.type: Root
focal_class.var_name: root
focal_class.declarator: loginId
focal_class.modifier: private final
focal_class.original_string: private final String loginId;
focal_class.type: String
focal_class.var_name: loginId
focal_class.declarator: userId
focal_class.modifier: private
focal_class.original_string: private String userId;
focal_class.type: String
focal_class.var_name: userId
focal_class.declarator: principal
focal_class.modifier: private
focal_class.original_string: private Principal principal;
focal_class.type: Principal
focal_class.var_name: principal
focal_class.file: oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserAuthentication.java
focal_class.identifier: UserAuthentication
focal_class.interfaces: implements Authentication, UserConstants
focal_class.class_method_signature: UserAuthentication.UserAuthentication(@NotNull UserConfiguration config, @NotNull Root root, @Nullable String loginId)
focal_class.full_signature:   UserAuthentication(@NotNull UserConfiguration config, @NotNull Root root, @Nullable String loginId)
focal_class.identifier: UserAuthentication
focal_class.parameters: (@NotNull UserConfiguration config, @NotNull Root root, @Nullable String loginId)
focal_class.signature:  UserAuthentication(@NotNull UserConfiguration config, @NotNull Root root, @Nullable String loginId)
focal_class.class_method_signature: UserAuthentication.authenticate(@Nullable Credentials credentials)
focal_class.full_signature: @Override public boolean authenticate(@Nullable Credentials credentials)
focal_class.identifier: authenticate
focal_class.modifiers: @Override public
focal_class.parameters: (@Nullable Credentials credentials)
focal_class.return: boolean
focal_class.signature: boolean authenticate(@Nullable Credentials credentials)
focal_class.class_method_signature: UserAuthentication.getUserId()
focal_class.full_signature: @Nullable @Override public String getUserId()
focal_class.identifier: getUserId
focal_class.modifiers: @Nullable @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getUserId()
focal_class.class_method_signature: UserAuthentication.getUserPrincipal()
focal_class.full_signature: @Nullable @Override public Principal getUserPrincipal()
focal_class.identifier: getUserPrincipal
focal_class.modifiers: @Nullable @Override public
focal_class.parameters: ()
focal_class.return: Principal
focal_class.signature: Principal getUserPrincipal()
focal_class.class_method_signature: UserAuthentication.getValidUser(@NotNull UserManager userManager, @NotNull String loginId)
focal_class.full_signature: @Nullable private static User getValidUser(@NotNull UserManager userManager, @NotNull String loginId)
focal_class.identifier: getValidUser
focal_class.modifiers: @Nullable private static
focal_class.parameters: (@NotNull UserManager userManager, @NotNull String loginId)
focal_class.return: User
focal_class.signature: User getValidUser(@NotNull UserManager userManager, @NotNull String loginId)
focal_class.class_method_signature: UserAuthentication.checkSuccess(boolean success, String msg)
focal_class.full_signature: private static void checkSuccess(boolean success, String msg)
focal_class.identifier: checkSuccess
focal_class.modifiers: private static
focal_class.parameters: (boolean success, String msg)
focal_class.return: void
focal_class.signature: void checkSuccess(boolean success, String msg)
focal_class.class_method_signature: UserAuthentication.equalUserId(@NotNull ImpersonationCredentials creds, @NotNull String userId)
focal_class.full_signature: private static boolean equalUserId(@NotNull ImpersonationCredentials creds, @NotNull String userId)
focal_class.identifier: equalUserId
focal_class.modifiers: private static
focal_class.parameters: (@NotNull ImpersonationCredentials creds, @NotNull String userId)
focal_class.return: boolean
focal_class.signature: boolean equalUserId(@NotNull ImpersonationCredentials creds, @NotNull String userId)
focal_class.class_method_signature: UserAuthentication.changePassword(User user, SimpleCredentials credentials)
focal_class.full_signature: private boolean changePassword(User user, SimpleCredentials credentials)
focal_class.identifier: changePassword
focal_class.modifiers: private
focal_class.parameters: (User user, SimpleCredentials credentials)
focal_class.return: boolean
focal_class.signature: boolean changePassword(User user, SimpleCredentials credentials)
focal_class.class_method_signature: UserAuthentication.removeNewPwAttribute(@NotNull Credentials credentials)
focal_class.full_signature: private static void removeNewPwAttribute(@NotNull Credentials credentials)
focal_class.identifier: removeNewPwAttribute
focal_class.modifiers: private static
focal_class.parameters: (@NotNull Credentials credentials)
focal_class.return: void
focal_class.signature: void removeNewPwAttribute(@NotNull Credentials credentials)
focal_class.class_method_signature: UserAuthentication.impersonate(AuthInfo info, User user)
focal_class.full_signature: private boolean impersonate(AuthInfo info, User user)
focal_class.identifier: impersonate
focal_class.modifiers: private
focal_class.parameters: (AuthInfo info, User user)
focal_class.return: boolean
focal_class.signature: boolean impersonate(AuthInfo info, User user)
focal_class.class_method_signature: UserAuthentication.getPasswordLastModified(User user)
focal_class.full_signature: @Nullable private Long getPasswordLastModified(User user)
focal_class.identifier: getPasswordLastModified
focal_class.modifiers: @Nullable private
focal_class.parameters: (User user)
focal_class.return: Long
focal_class.signature: Long getPasswordLastModified(User user)
focal_class.class_method_signature: UserAuthentication.isPasswordExpired(@NotNull User user)
focal_class.full_signature: private boolean isPasswordExpired(@NotNull User user)
focal_class.identifier: isPasswordExpired
focal_class.modifiers: private
focal_class.parameters: (@NotNull User user)
focal_class.return: boolean
focal_class.signature: boolean isPasswordExpired(@NotNull User user)
focal_method.body: @Override
      public boolean authenticate(@Nullable Credentials credentials) throws LoginException {
          if (credentials == null || loginId == null) {
              return false;
          }
  
          boolean success = false;
          try {
              User user = getValidUser(config.getUserManager(root, NamePathMapper.DEFAULT), loginId);
              if (user == null) {
                  return false;
              }
              if (credentials instanceof SimpleCredentials) {
                  SimpleCredentials creds = (SimpleCredentials) credentials;
                  Credentials userCreds = user.getCredentials();
                  if (loginId.equals(creds.getUserID()) && userCreds instanceof CredentialsImpl) {
                      success = PasswordUtil.isSame(((CredentialsImpl) userCreds).getPasswordHash(), creds.getPassword());
                  }
                  checkSuccess(success, "UserId/Password mismatch.");
  
                  // change the password if the credentials object has the UserConstants.CREDENTIALS_ATTRIBUTE_NEWPASSWORD attribute set
                  if (isPasswordExpired(user) && !changePassword(user, creds)) {
                      throw new CredentialExpiredException("User password has expired");
                  }
              } else if (credentials instanceof ImpersonationCredentials) {
                  ImpersonationCredentials ipCreds = (ImpersonationCredentials) credentials;
                  AuthInfo info = ipCreds.getImpersonatorInfo();
                  success = equalUserId(ipCreds, loginId) && impersonate(info, user);
                  checkSuccess(success, "Impersonation not allowed.");
              } else {
                  // guest login is allowed if an anonymous user exists in the content (see get user above)
                  success = (credentials instanceof GuestCredentials) || credentials == PreAuthenticatedLogin.PRE_AUTHENTICATED;
              }
              userId = user.getID();
              principal = user.getPrincipal();
          } catch (RepositoryException e) {
              throw new LoginException(e.getMessage());
          } finally {
              removeNewPwAttribute(credentials);
          }
          return success;
      }
focal_method.class_method_signature: UserAuthentication.authenticate(@Nullable Credentials credentials)
focal_method.full_signature: @Override public boolean authenticate(@Nullable Credentials credentials)
focal_method.identifier: authenticate
focal_method.invocations: getValidUser getUserManager getCredentials equals getUserID isSame getPasswordHash getPassword checkSuccess isPasswordExpired changePassword getImpersonatorInfo equalUserId impersonate checkSuccess getID getPrincipal getMessage removeNewPwAttribute
focal_method.modifiers: @Override public
focal_method.parameters: (@Nullable Credentials credentials)
focal_method.return: boolean
focal_method.signature: boolean authenticate(@Nullable Credentials credentials)