Package jcifs.smb

Examples of jcifs.smb.NtlmPasswordAuthentication


        Logging.connectors.debug("Connecting to: " + "smb://" + ((domain==null)?"":domain)+";"+username+":<password>@" + server + "/");

      try
      {
        // use NtlmPasswordAuthentication so that we can reuse credential for DFS support
        pa = new NtlmPasswordAuthentication(domain,username,password);
        SmbFile smbconnection = new SmbFile("smb://" + server + "/",pa);
        smbconnectionPath = getFileCanonicalPath(smbconnection);
      }
      catch (MalformedURLException e)
      {
View Full Code Here


        System.setProperty("jcifs.smb.client.disablePlainTextPasswords",
                            "false" );
        try {
            UniAddress mydomaincontroller = UniAddress.getByName(
                                                getDomainController());
            NtlmPasswordAuthentication mycreds = new
                                NtlmPasswordAuthentication(
                                        getDomainName(),
                                        super.getId(),
                                        password);
            SmbSession.logon( mydomaincontroller, mycreds );
View Full Code Here

  public static SmbFile connectToRootDirectoryWithAuthentication(String smbURL, String domain, String login,
      String password) throws Exception {
    StopWatch sw = new StopWatch();

    // Create authentication object
    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain, login, password);
    // Connect to share using the samba URL specified
    sw.start();
    SmbFile root = new SmbFile(smbURL, auth);
    // Force connection with the share to be established before the first
    // use of the file reference object
View Full Code Here

        Logging.connectors.debug("Connecting to: " + "smb://" + ((domain==null)?"":domain)+";"+username+":<password>@" + server + "/");

      try
      {
        // use NtlmPasswordAuthentication so that we can reuse credential for DFS support
        pa = new NtlmPasswordAuthentication(domain,username,password);
        SmbFile smbconnection = new SmbFile("smb://" + server + "/",pa);
        smbconnectionPath = getFileCanonicalPath(smbconnection);
      }
      catch (MalformedURLException e)
      {
View Full Code Here

    public boolean authenticate(String password) {

        System.setProperty("jcifs.smb.client.disablePlainTextPasswords", "true");
        try {
            UniAddress mydomaincontroller = UniAddress.getByName(getDomainController());
            NtlmPasswordAuthentication mycreds = new NtlmPasswordAuthentication(getDomainName(),
                    super.getId(), password);
            SmbSession.logon(mydomaincontroller, mycreds);
            // SUCCESS
            return true;
        } catch (final SmbAuthException sae) {
View Full Code Here

    public Subject authenticate(String userId, String password) throws AuthenticationException {
        try{
            UniAddress dc = UniAddress.getByName( domainController, true );

            NtlmPasswordAuthentication ntlm =
                new NtlmPasswordAuthentication(domain, userId, password);

            SmbSession.logon( dc, ntlm );
        }catch(SmbAuthException sae) {
            log.error("NT domain did not authenticate user "+userId);
            return fallbackAuthenticate(userId, password);
View Full Code Here

        Logging.connectors.debug("Connecting to: " + "smb://" + ((domain==null)?"":domain)+";"+username+":<password>@" + server + "/");

      try
      {
        // use NtlmPasswordAuthentication so that we can reuse credential for DFS support
        pa = new NtlmPasswordAuthentication(domain,username,password);
        SmbFile smbconnection = new SmbFile("smb://" + server + "/",pa);
        smbconnectionPath = getFileCanonicalPath(smbconnection);
      }
      catch (MalformedURLException e)
      {
View Full Code Here

        Logging.connectors.debug("Connecting to: " + "smb://" + ((domain==null)?"":domain)+";"+username+":<password>@" + server + "/");

      try
      {
        // use NtlmPasswordAuthentication so that we can reuse credential for DFS support
        pa = new NtlmPasswordAuthentication(domain,username,password);
        SmbFile smbconnection = new SmbFile("smb://" + server + "/",pa);
        smbconnectionPath = getFileCanonicalPath(smbconnection);
      }
      catch (MalformedURLException e)
      {
View Full Code Here

          SourcePipelinePojo firstElement = source.getProcessingPipeline().iterator().next();
          source.setFileConfig(firstElement.file);
          source.setUrl(firstElement.file.getUrl());
        }//TESTED
        if (source.getUrl().startsWith("inf://")) { // Infinit.e share/custom object
          NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(source.getCommunityIds().iterator().next().toString(), source.getOwnerId().toString(), null);
          f = InfiniteFile.create(source.getUrl(), auth);
         
          if (f.isDirectory()) {
            InfiniteFile subs[] = f.listFiles();
            for (InfiniteFile sub: subs) {
              if (sub.isDirectory()) { // (can only nest once)
                InfiniteFile subs2[] = sub.listFiles();
                for (InfiniteFile sub2: subs2) {
                  if (sub2.getUrlString().equals(searchFile)) {
                    return sub2;
                  }//TOTEST
                }               
              }//(end loop ove sub-dirs)
              else if (sub.getUrlString().equals(searchFile)) {
                return sub;
              }//TOTEST
            }//(end loop over dirs)
           
          }//TOTEST
         
        }//TODO (INF-2122): TOTEST
        else if( source.getFileConfig() == null || source.getFileConfig().password == null || source.getFileConfig().username == null)
        {
          f = InfiniteFile.create(searchFile);
        }
        else
        {
          if (source.getFileConfig().domain == null) {
            source.getFileConfig().domain = "";
          }
          NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(source.getFileConfig().domain, source.getFileConfig().username, source.getFileConfig().password);
          f = InfiniteFile.create(searchFile, auth);
        }
      }//TESTED
      catch (Exception e) {
 
View Full Code Here

    InfiniteFile file = null;
    _deleteExistingFilesBySourceKey = false;
    try
    {
      if (source.getUrl().startsWith("inf://")) { // Infinit.e share/custom object
        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(Arrays.toString(source.getCommunityIds().toArray()), source.getOwnerId().toString(), null);
        file = InfiniteFile.create(source.getUrl(), auth)

        if (source.getUrl().startsWith("inf://custom/")) {
          _customJob = true;
          // A few cases:
          // 1] If first time, or source has completed:
          // Quick check of share/custom date vs last imported doc in this case:
          ObjectId customLastRecordId = null;
          // Here are the two cases (whether in success/error/success_iteration
          // 1) non-append mode ... any time the first_record.time > last_doc.time then re-run (delete all docs)
          // 2) append-mode ... any time the last_record.time > last_doc.time then re-run/keep going         
          // (the status clause below just determines if you keep going or not)
          // the file.getTime() call will automatically give you the correct version of 1 vs 2 depending on its status)
         
          if ((null == source.getHarvestStatus()) || (HarvestEnum.success == source.getHarvestStatus().getHarvest_status()))
          {         
           
            if (!_context.getDuplicateManager().needsUpdated_Url(new Date(file.getDate()), null, source)) {
              return files;
            }//TESTED     
            else {
              _customLastRecordWritten = _context.getDuplicateManager().getLastModifiedDate();
              customLastRecordId = _context.getDuplicateManager().getLastModifiedDocId();
              _context.getDuplicateManager().resetForNewSource();
                // (reset the saved state since I faked my harvest status)
              _deleteExistingFilesBySourceKey = true;
            }//TESTED
          }
          else { // 2] If in the middle of a multiple harvest cycle....
            // Specifically for custom, need to handle m/r changing ... we'll fake the harvest status
            // to force it to check the last doc's modified time vs the current file time...
           
            HarvestEnum saved = source.getHarvestStatus().getHarvest_status();
            source.getHarvestStatus().setHarvest_status(HarvestEnum.success);
            try {
              if (_context.getDuplicateManager().needsUpdated_Url(new Date(file.getDate()), null, source)) {
                _deleteExistingFilesBySourceKey = true;               
              }
              _customLastRecordWritten = _context.getDuplicateManager().getLastModifiedDate();
              customLastRecordId = _context.getDuplicateManager().getLastModifiedDocId();
              _context.getDuplicateManager().resetForNewSource();
                // (reset the saved state since I faked my harvest status)
            }
            finally { // (rewrite original)
              source.getHarvestStatus().setHarvest_status(saved);
            }
          }//TESTED
          if (_streaming) { // Never delete files...
            _deleteExistingFilesBySourceKey = false;
          }//TESTED
         
          if (null == customLastRecordId) { // no docs, so no need for this
            // (or -in the case of distributed sources- the new harvest has already begun)
            _deleteExistingFilesBySourceKey = false;           
          }//TESTED

          // Custom append mode: never delete anything, only process new objects
          InternalInfiniteFile customHandle = (InternalInfiniteFile)file;
          if (customHandle.isAppendingNotReplacing()) {
            _deleteExistingFilesBySourceKey = false;
          }//TESTED
         
          // Finally, if we wanted to delete the files then go ahead now:
          if (_deleteExistingFilesBySourceKey) {           
            // For now, support only "non-append" mode efficiently:
            // Always delete all the old docs, updated docs will work but inefficiently (will delete and re-create)
            DocumentPojo docRepresentingSrcKey = new DocumentPojo();
            if (null != source.getDistributionFactor()) {
              // If split across multiple docs then need a more expensive delete (note: still indexed)
              docRepresentingSrcKey.setId(customLastRecordId);
            }
            docRepresentingSrcKey.setCommunityId(source.getCommunityIds().iterator().next());
            docRepresentingSrcKey.setSourceKey(source.getKey());
            this.docsToRemove.add(docRepresentingSrcKey);           
          }//TESTED
        }
        else { // share - this is much simpler:
          if (!_context.getDuplicateManager().needsUpdated_Url(new Date(file.getDate()), null, source)) {
            return files;
          }//TESTED         
        }
       
      }//TESTED
      else if( source.getFileConfig() == null || source.getFileConfig().password == null || source.getFileConfig().username == null)
      {
        // Local file: => must be admin to continue
        if (harvestSecureMode) { // secure mode, must be admin
          if (source.getUrl().startsWith("file:")) {
            if (!AuthUtils.isAdmin(source.getOwnerId())) {
              throw new ExtractorSourceLevelMajorException("Permission denied");
            }
          }
        }//TODO (INF-2119): come up with something better than this...(this is at least consistent with SAH/UAH security, apart from allowing admin more rights)
        file = InfiniteFile.create(source.getUrl());
      }
      else
      {
        if (source.getFileConfig().domain == null) {
          source.getFileConfig().domain = "";
        }
        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(source.getFileConfig().domain, source.getFileConfig().username, source.getFileConfig().password);
        file = InfiniteFile.create(source.getUrl(), auth);
      }
      traverse(file, source, maxDepth);
    }
    catch (Exception e) {
View Full Code Here

TOP

Related Classes of jcifs.smb.NtlmPasswordAuthentication

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.