Package org.ntlmv2.liferay

Examples of org.ntlmv2.liferay.NetlogonConnection


      log.info("Domain controller IP address: " + domainController);
      log.info("Domain controller hostname: " + domainControllerHostName);
      log.info("Computer account name: " + serviceAccount);
      log.info("Computer account password: " + servicePassword);
     
      ntlmManager = new NtlmManager(
          domain, domainController, domainControllerHostName, serviceAccount,
          servicePassword);
     
    } catch (Exception e) {
      throw new ServletException("NTLM filter initialization failed. Reason: " + e, e);
View Full Code Here


        sendWwwAuthenticateResponse(response);

        return;
      }

      NtlmUserAccount ntlmUserAccount = null;
      try {
        log.debug("Try authenticating user now...");
        ntlmUserAccount = ntlmManager.authenticate(
          src, serverChallenge);
        log.info("Authentication was successful. Creating session.");
        session = request.getSession(true);
        session.setAttribute(NTLM_USER_ACCOUNT, ntlmUserAccount);
      } catch (Exception e) {
        log.error("NTLM authentication failed: " + e, e);
      } finally {
        synchronized(cache) {
          cache.remove(request.getRemoteAddr());
        }
      }

      if (ntlmUserAccount == null) {
        // No NTLM user in session yet, or authentication failed
        sendWwwAuthenticateResponse(response);
        return;
      }

      if (log.isDebugEnabled()) {
        log.debug("NTLM remote user " + ntlmUserAccount.getUserName());
      }
    }

    // Check if NTLM user account has already been stored in session
    NtlmUserAccount ntlmUserAccount = null;
    if (session != null) {
      ntlmUserAccount = (NtlmUserAccount)session.getAttribute(
          NTLM_USER_ACCOUNT);
    }

    HttpServletRequest filteredReq = request;
    if (ntlmUserAccount == null) {
      log.debug("No NTLM user set yet, begin authentication...");
      sendWwwAuthenticateResponse(response);
      return;
    }
   
    log.debug("NTLM user in session: " + ntlmUserAccount.getUserName());
    if(!(request instanceof NtlmV2HttpRequestWrapper)) {
      // Wrap original request only once
      filteredReq = new NtlmV2HttpRequestWrapper(request, ntlmUserAccount.getUserName());
    }
   
    filterChain.doFilter(filteredReq, res);
  }
View Full Code Here

      netlogonConnection.connect(
        _domainController, _domainControllerName, _ntlmServiceAccount,
        _secureRandom);

      NetlogonAuthenticator netlogonAuthenticator =
        netlogonConnection.computeNetlogonAuthenticator();

      NetlogonIdentityInfo netlogonIdentityInfo =
        new NetlogonIdentityInfo(
          domain, 0x00000820, 0, 0, userName, workstation);

      NetlogonNetworkInfo netlogonNetworkInfo = new NetlogonNetworkInfo(
        netlogonIdentityInfo, serverChallenge, ntResponse, lmResponse);

      NetrLogonSamLogon netrLogonSamLogon = new NetrLogonSamLogon(
        _domainControllerName, _ntlmServiceAccount.getComputerName(),
        netlogonAuthenticator, new NetlogonAuthenticator(), 2,
        netlogonNetworkInfo, 2, new NetlogonValidationSamInfo(), 0);

      DcerpcHandle dcerpcHandle = netlogonConnection.getDcerpcHandle();

      dcerpcHandle.sendrecv(netrLogonSamLogon);
View Full Code Here

    Encdec.enc_uint32le(input, _clientCredential, 0);

    byte[] credential = computeNetlogonCredential(
      _clientCredential, _sessionKey);

    return new NetlogonAuthenticator(credential, timestamp);
  }
View Full Code Here

        _secureRandom);

      NetlogonAuthenticator netlogonAuthenticator =
        netlogonConnection.computeNetlogonAuthenticator();

      NetlogonIdentityInfo netlogonIdentityInfo =
        new NetlogonIdentityInfo(
          domain, 0x00000820, 0, 0, userName, workstation);

      NetlogonNetworkInfo netlogonNetworkInfo = new NetlogonNetworkInfo(
        netlogonIdentityInfo, serverChallenge, ntResponse, lmResponse);
View Full Code Here

      NetlogonIdentityInfo netlogonIdentityInfo =
        new NetlogonIdentityInfo(
          domain, 0x00000820, 0, 0, userName, workstation);

      NetlogonNetworkInfo netlogonNetworkInfo = new NetlogonNetworkInfo(
        netlogonIdentityInfo, serverChallenge, ntResponse, lmResponse);

      NetrLogonSamLogon netrLogonSamLogon = new NetrLogonSamLogon(
        _domainControllerName, _ntlmServiceAccount.getComputerName(),
        netlogonAuthenticator, new NetlogonAuthenticator(), 2,
View Full Code Here

        netlogonIdentityInfo, serverChallenge, ntResponse, lmResponse);

      NetrLogonSamLogon netrLogonSamLogon = new NetrLogonSamLogon(
        _domainControllerName, _ntlmServiceAccount.getComputerName(),
        netlogonAuthenticator, new NetlogonAuthenticator(), 2,
        netlogonNetworkInfo, 2, new NetlogonValidationSamInfo(), 0);

      DcerpcHandle dcerpcHandle = netlogonConnection.getDcerpcHandle();

      dcerpcHandle.sendrecv(netrLogonSamLogon);

      if (netrLogonSamLogon.getStatus() == 0) {
        NetlogonValidationSamInfo netlogonValidationSamInfo =
          netrLogonSamLogon.getNetlogonValidationSamInfo();

        UnicodeString name = new UnicodeString(
          netlogonValidationSamInfo.getEffectiveName(), false);

        return new NtlmUserAccount(name.toString());
      }
      else {
        SmbException smbe = new SmbException(
View Full Code Here

          domain, 0x00000820, 0, 0, userName, workstation);

      NetlogonNetworkInfo netlogonNetworkInfo = new NetlogonNetworkInfo(
        netlogonIdentityInfo, serverChallenge, ntResponse, lmResponse);

      NetrLogonSamLogon netrLogonSamLogon = new NetrLogonSamLogon(
        _domainControllerName, _ntlmServiceAccount.getComputerName(),
        netlogonAuthenticator, new NetlogonAuthenticator(), 2,
        netlogonNetworkInfo, 2, new NetlogonValidationSamInfo(), 0);

      DcerpcHandle dcerpcHandle = netlogonConnection.getDcerpcHandle();

      dcerpcHandle.sendrecv(netrLogonSamLogon);

      if (netrLogonSamLogon.getStatus() == 0) {
        NetlogonValidationSamInfo netlogonValidationSamInfo =
          netrLogonSamLogon.getNetlogonValidationSamInfo();

        UnicodeString name = new UnicodeString(
          netlogonValidationSamInfo.getEffectiveName(), false);

        return new NtlmUserAccount(name.toString());
      }
      else {
        SmbException smbe = new SmbException(
          netrLogonSamLogon.getStatus(), false);

        throw new NtlmLogonException(
          "Unable to authenticate user: " + smbe.getMessage());
      }
    }
View Full Code Here

      netrServerReqChallenge.getServerChallenge());

    byte[] clientCredential = computeNetlogonCredential(
      clientChallenge, sessionKey);

    NetrServerAuthenticate3 netrServerAuthenticate3 =
      new NetrServerAuthenticate3(
        domainControllerName, ntlmServiceAccount.getAccountName(), 2,
        ntlmServiceAccount.getComputerName(), clientCredential,
        new byte[8], _negotiateFlags);

    dcerpcHandle.sendrecv(netrServerAuthenticate3);

    byte[] serverCredential = computeNetlogonCredential(
      netrServerReqChallenge.getServerChallenge(), sessionKey);

    if (!Arrays.equals(
        serverCredential,
        netrServerAuthenticate3.getServerCredential())) {

      throw new NtlmLogonException("Session key negotiation failed");
    }

    _clientCredential = clientCredential;
View Full Code Here

    byte[] clientChallenge = new byte[8];

    secureRandom.nextBytes(clientChallenge);

    NetrServerReqChallenge netrServerReqChallenge =
      new NetrServerReqChallenge(
        domainControllerName, ntlmServiceAccount.getComputerName(),
        clientChallenge, new byte[8]);

    dcerpcHandle.sendrecv(netrServerReqChallenge);

    MD4 md4 = new MD4();

    md4.update(ntlmServiceAccount.getPassword().getBytes("UTF-16LE"));

    byte[] sessionKey = computeSessionKey(
      md4.digest(), clientChallenge,
      netrServerReqChallenge.getServerChallenge());

    byte[] clientCredential = computeNetlogonCredential(
      clientChallenge, sessionKey);

    NetrServerAuthenticate3 netrServerAuthenticate3 =
      new NetrServerAuthenticate3(
        domainControllerName, ntlmServiceAccount.getAccountName(), 2,
        ntlmServiceAccount.getComputerName(), clientCredential,
        new byte[8], _negotiateFlags);

    dcerpcHandle.sendrecv(netrServerAuthenticate3);

    byte[] serverCredential = computeNetlogonCredential(
      netrServerReqChallenge.getServerChallenge(), sessionKey);

    if (!Arrays.equals(
        serverCredential,
        netrServerAuthenticate3.getServerCredential())) {
View Full Code Here

TOP

Related Classes of org.ntlmv2.liferay.NetlogonConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.