Esempio n. 1
0
  /**
   * Method description
   *
   * @param request
   * @param response
   * @param username
   * @param password
   * @return
   */
  @Override
  public AuthenticationResult authenticate(
      HttpServletRequest request, HttpServletResponse response, String username, String password) {
    String applicationName = request.getRequestURI().split("/")[3];
    AssertUtil.assertIsNotEmpty(username);
    AssertUtil.assertIsNotEmpty(password);
    AssertUtil.assertIsNotEmpty(applicationName);
    AppFactoryConfiguration configuration =
        (AppFactoryConfiguration)
            PrivilegedCarbonContext.getCurrentContext()
                .getOSGiService(AppFactoryConfiguration.class);

    if (authenticateRemotely(username, password, applicationName, configuration)) {
      return new AuthenticationResult(getUser(username), getGroups(applicationName));
    }

    return AuthenticationResult.FAILED;
  }