當前位置: 首頁>>代碼示例>>Java>>正文


Java NtlmPasswordAuthentication類代碼示例

本文整理匯總了Java中jcifs.smb.NtlmPasswordAuthentication的典型用法代碼示例。如果您正苦於以下問題:Java NtlmPasswordAuthentication類的具體用法?Java NtlmPasswordAuthentication怎麽用?Java NtlmPasswordAuthentication使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NtlmPasswordAuthentication類屬於jcifs.smb包,在下文中一共展示了NtlmPasswordAuthentication類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: connectingWithSmbServer

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
public SmbFile connectingWithSmbServer(String[] auth,boolean anonym) {
    try {
        String yourPeerIP=auth[0];
        String path = "smb://" + yourPeerIP;
        smbPath=path;
        SmbFile smbFile;
        if(anonym){
            SmbAnonym=true;
           smbFile = new SmbFile(path,NtlmPasswordAuthentication.ANONYMOUS);
        }
        else {
            SmbAnonym=false;
            smbUser=auth[1];
            smbPass=auth[2];
            NtlmPasswordAuthentication auth1 = new NtlmPasswordAuthentication(
                    null, auth[1], auth[2]);
             smbFile = new SmbFile(path, auth1);
        }return smbFile;
    } catch (Exception e) {
        e.printStackTrace();
        Log.e("Connected", e.getMessage());
        return null;
    }
}
 
開發者ID:DeFuture,項目名稱:AmazeFileManager-master,代碼行數:25,代碼來源:Main.java

示例2: listFiles

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
public void listFiles() {
    try {
        NtlmPasswordAuthentication authentication = new NtlmPasswordAuthentication(
                null, USER, PASSWORD);
        SmbFile home = new SmbFile("smb://localhost:8445/user/", authentication);

        if(home.isDirectory()) {
            List<SmbFile> files = Arrays.asList(home.listFiles());
            for(SmbFile file: files) {
                if(file.isDirectory()) {
                    System.out.println("Directory: " + file.getName());
                }
                if(file.isFile()) {
                    System.out.println("File: " + file.getName());
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:thebagchi,項目名稱:heimdall-proxy,代碼行數:22,代碼來源:SambaTester.java

示例3: uploadFiles

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
@Override
public void uploadFiles(NtlmPasswordAuthentication auth, List<UploadFile> files) {
    List<UploadFile> workFiles = files;

    for (UploadFile file : files) {
        uploadSingleFile(auth, file, new Callback() {
            @Override
            public void onSuccess() {
                // do nothing
            }

            @Override
            public void onError() {
                // do nothing
            }
        });
        workFiles.remove(file);
    }
}
 
開發者ID:ibiBgOR,項目名稱:android-nas-backup,代碼行數:20,代碼來源:FileMoverImpl.java

示例4: init

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
@Override
protected void init(final ProcessorInitializationContext context) {
    final List<PropertyDescriptor> properties = new ArrayList<PropertyDescriptor>();
    properties.add(DIRECTORY);
    properties.add(FILE_FILTER);
    properties.add(BATCH_SIZE);
    properties.add(KEEP_SOURCE_FILE);
    properties.add(POLLING_INTERVAL);
    this.properties = Collections.unmodifiableList(properties);

    final Set<Relationship> relationships = new HashSet<Relationship>();
    relationships.add(REL_SUCCESS);
    this.relationships = Collections.unmodifiableSet(relationships);
    String user = "ubuntu";
    String pass ="ubuntu";
    auth = new NtlmPasswordAuthentication("",user, pass);
 
}
 
開發者ID:dream-lab,項目名稱:echo,代碼行數:19,代碼來源:GetSmbFiles.java

示例5: init

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
@Override
protected void init(final ProcessorInitializationContext context) {
    // relationships
    final Set<Relationship> procRels = new HashSet<Relationship>();
    procRels.add(REL_SUCCESS);
    procRels.add(REL_FAILURE);
    relationships = Collections.unmodifiableSet(procRels);

    // descriptors
    final List<PropertyDescriptor> supDescriptors = new ArrayList<PropertyDescriptor>();
    supDescriptors.add(DIRECTORY);
    supDescriptors.add(CONFLICT_RESOLUTION);
    supDescriptors.add(CREATE_DIRS);
    supDescriptors.add(MAX_DESTINATION_FILES);
    supDescriptors.add(CHANGE_LAST_MODIFIED_TIME);
    supDescriptors.add(CHANGE_PERMISSIONS);
    supDescriptors.add(CHANGE_OWNER);
    supDescriptors.add(CHANGE_GROUP);
    properties = Collections.unmodifiableList(supDescriptors);
    String user = "ubuntu";
    String pass ="ubuntu";
    auth = new NtlmPasswordAuthentication("",user, pass);
}
 
開發者ID:dream-lab,項目名稱:echo,代碼行數:24,代碼來源:PutSmbFiles.java

示例6: initialize

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
public void initialize(String rootPath) throws Exception {
		System.out.println("debut init");
		
//		this.getParamValues().put("server", "smb://192.168.1.21/Documents");
//		this.getParamValues().put("login", "anonymous");
//		this.getParamValues().put("pwd", "");
		
		serverAdress=this.getParamValues().get(hostnameKey);
		if (!serverAdress.startsWith("smb://")) serverAdress="smb://"+serverAdress;
		if (!serverAdress.endsWith("/")) serverAdress+="/";
		String userName = this.getParamValues().get(loginKey);
		String pwd = this.getParamValues().get(pwdKey);
		if (userName==null || "".equals(userName)){
			userName="guest";
			pwd="";
		}
		authentication = new NtlmPasswordAuthentication("",userName, pwd); // domain, user, password
		System.out.println("fin init");
	}
 
開發者ID:starn,項目名稱:encdroidMC,代碼行數:20,代碼來源:FileProvider3.java

示例7: renewCredentials

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
/**
 * {@inheritDoc}
 *
 * @see jcifs.CIFSContext#renewCredentials(java.lang.String, java.lang.Throwable)
 */
@Override
public boolean renewCredentials ( String locationHint, Throwable error ) {
    Credentials cred = getCredentials();
    if ( cred instanceof SmbRenewableCredentials ) {
        SmbRenewableCredentials renewable = (SmbRenewableCredentials) cred;
        CredentialsInternal renewed = renewable.renew();
        if ( renewed != null ) {
            this.creds = renewed;
        }
    }
    NtlmAuthenticator auth = NtlmAuthenticator.getDefault();
    if ( auth != null ) {
        NtlmPasswordAuthentication newAuth = NtlmAuthenticator
                .requestNtlmPasswordAuthentication(auth, locationHint, ( error instanceof SmbAuthException ) ? (SmbAuthException) error : null);
        if ( newAuth != null ) {
            this.creds = newAuth;
            return true;
        }
    }
    return false;
}
 
開發者ID:AgNO3,項目名稱:jcifs-ng,代碼行數:27,代碼來源:CIFSContextCredentialWrapper.java

示例8: testFixedCredentials

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
@Test
public void testFixedCredentials () {
    Credentials guestCreds = this.context.withGuestCrendentials().getCredentials();
    assertThat(guestCreds, CoreMatchers.is(CoreMatchers.instanceOf(NtlmPasswordAuthentication.class)));
    NtlmPasswordAuthentication ntlmGuestCreds = guestCreds.unwrap(NtlmPasswordAuthentication.class);
    assertEquals("GUEST", ntlmGuestCreds.getUsername());
    assertThat("anonymous", ntlmGuestCreds.isAnonymous(), CoreMatchers.is(true));

    Credentials anonCreds = this.context.withAnonymousCredentials().getCredentials();
    assertThat(anonCreds, CoreMatchers.is(CoreMatchers.instanceOf(NtlmPasswordAuthentication.class)));
    NtlmPasswordAuthentication ntlmAnonCreds = anonCreds.unwrap(NtlmPasswordAuthentication.class);
    assertEquals("", ntlmAnonCreds.getUsername());
    assertEquals("", ntlmAnonCreds.getPassword());
    assertThat("anonymous", ntlmAnonCreds.isAnonymous(), CoreMatchers.is(true));

    CIFSContext testCtx = this.context.withCredentials(new NtlmPasswordAuthentication(this.context, "TEST", "test-user", "test-pw"));
    Credentials setCreds = testCtx.getCredentials();
    assertThat(setCreds, CoreMatchers.is(CoreMatchers.instanceOf(NtlmPasswordAuthentication.class)));
    NtlmPasswordAuthentication setCredsNtlm = setCreds.unwrap(NtlmPasswordAuthentication.class);
    assertEquals("TEST", setCredsNtlm.getUserDomain());
    assertEquals("test-user", setCredsNtlm.getUsername());
    assertEquals("test-pw", setCredsNtlm.getPassword());
    assertThat("anonymous", setCredsNtlm.isAnonymous(), CoreMatchers.is(false));
}
 
開發者ID:AgNO3,項目名稱:jcifs-ng,代碼行數:25,代碼來源:ContextConfigTest.java

示例9: getSmbFile

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
private SmbFile getSmbFile(String filename, StorageCredentials storageCredentials)
throws MalformedURLException, SmbException 
{
	SmbCredentials fileCredentials = SmbCredentials.create(new SmbServerShare(filename), 
			storageCredentials);
	SmbCredentials directoryCredentials = SmbCredentials.create(new SmbServerShare(this.getDirectory(filename)),
			storageCredentials);
	SmbFile file = null;
	SmbFile directory = null;

	NtlmPasswordAuthentication ntPassAuth = 
		new NtlmPasswordAuthentication(fileCredentials.getDomain(),
				fileCredentials.getUsername(),
				fileCredentials.getPassword());
	directory = new SmbFile(directoryCredentials.getSmbServerShare().getSmbPath(), ntPassAuth);
	if (!directory.exists()){
		directory.mkdirs();
	}
	file = new SmbFile(fileCredentials.getSmbServerShare().getSmbPath(), ntPassAuth);
	return file;
}
 
開發者ID:VHAINNOVATIONS,項目名稱:Telepathology,代碼行數:22,代碼來源:SmbStorageUtility.java

示例10: _userInfo

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
private static String _userInfo (NtlmPasswordAuthentication auth,boolean addAtSign) {
	String result = "";
	if( auth != null) {
		if( !StringUtils.isEmpty( auth.getDomain() ) ) {
			result += auth.getDomain() + ";";
		}
		if( !StringUtils.isEmpty( auth.getUsername() ) ) {
			result += auth.getUsername() + ":";
		}
		if( !StringUtils.isEmpty( auth.getPassword() ) ) {
			result += auth.getPassword();
		}
		if( addAtSign && !StringUtils.isEmpty( result ) ) {
			result += "@";
		}
	}
	return result;
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:19,代碼來源:SMBResource.java

示例11: uploadSingleFile

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
private void uploadSingleFile(final NtlmPasswordAuthentication auth, final UploadFile file, final Callback callback) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            uploadFileToServer(auth, file, new Callback() {
                @Override
                public void onSuccess() {
                    Log.i(TAG, "Yey");
                    callback.onSuccess();
                }

                @Override
                public void onError() {
                    Log.i(TAG, "Oh damn");
                    callback.onError();
                }
            });
        }
    }).start();
}
 
開發者ID:ibiBgOR,項目名稱:android-nas-backup,代碼行數:21,代碼來源:FileMoverImpl.java

示例12: startTempThread

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
public static void startTempThread() {
    Log.i(TAG, "Start tempthread");
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("", "usr", "pass");
                String[] domains = (new SmbFile("smb://" + "address", auth)).list();
                for (String file : domains) {
                    Log.d(TAG, file);
                }
            } catch (SmbException e1) {
                e1.printStackTrace();
            } catch (MalformedURLException e2) {
                e2.printStackTrace();
            }
        }
    }

    ).start();
}
 
開發者ID:ibiBgOR,項目名稱:android-nas-backup,代碼行數:22,代碼來源:NetUtils.java

示例13: run

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
/**
 * Runs the command, once command-line parameters are processed.
 */
public void run() throws Exception
{
    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain, username, password);
    String url = String.format("smb://%s/%s/%s/", hostname, sharename, dirpath);
    SmbFile file = new SmbFile(url, auth);

    if (!file.exists())
    {
        System.out.println(String.format("invalid file path -- doesn't exist [%s:%s:%s]", hostname, sharename, dirpath));
        return;
    }

    if (atime != -1)
    {
        file.setAccessTime(atime);
    }

    if (mtime != -1)
    {
        file.setLastModified(mtime);
    }
}
 
開發者ID:felixion,項目名稱:flxsmb,代碼行數:26,代碼來源:UpdateFileMetadataCommand.java

示例14: testLookupSIDs

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
@Test
public void testLookupSIDs() throws Exception
{
    SmbFile shareRoot = getShareRoot(getWritableShare());

    _logger.info(String.format("Testing server time for \"%s\"", shareRoot));

    SID[] sids = SID.getFromNames("datamaster.storediq.com", new NtlmPasswordAuthentication("storediq", "testadmin", "test123"), new String[] {"storediq\\testadmin"});

    for (SID sid : sids)
    {
        System.out.println(sid + " - " + sid.toDisplayString());
        System.out.println(sid.getRid());
        System.out.println(sid.getTypeText());

    }
}
 
開發者ID:felixion,項目名稱:flxsmb,代碼行數:18,代碼來源:LookupAccountNamesTests.java

示例15: doAuthentication

import jcifs.smb.NtlmPasswordAuthentication; //導入依賴的package包/類
@Override
protected final HandlerResult doAuthentication(
        final Credential credential) throws GeneralSecurityException, PreventedException {

    final SpnegoCredential ntlmCredential = (SpnegoCredential) credential;
    final byte[] src = ntlmCredential.getInitToken();

    UniAddress dc = null;

    boolean success = false;
    try {
        if (this.loadBalance) {
            // find the first dc that matches the includepattern
            if (StringUtils.isNotBlank(this.includePattern)) {
                final NbtAddress[] dcs = NbtAddress.getAllByName(this.domainController, NBT_ADDRESS_TYPE, null, null);
                for (final NbtAddress dc2 : dcs) {
                    if(dc2.getHostAddress().matches(this.includePattern)){
                        dc = new UniAddress(dc2);
                        break;
                    }
                }
            } else {
                dc = new UniAddress(NbtAddress.getByName(this.domainController, NBT_ADDRESS_TYPE, null));
            }
        } else {
            dc = UniAddress.getByName(this.domainController, true);
        }
        final byte[] challenge = SmbSession.getChallenge(dc);

        switch (src[NTLM_TOKEN_TYPE_FIELD_INDEX]) {
            case NTLM_TOKEN_TYPE_ONE:
                logger.debug("Type 1 received");
                final Type1Message type1 = new Type1Message(src);
                final Type2Message type2 = new Type2Message(type1,
                        challenge, null);
                logger.debug("Type 2 returned. Setting next token.");
                ntlmCredential.setNextToken(type2.toByteArray());
                break;
            case NTLM_TOKEN_TYPE_THREE:
                logger.debug("Type 3 received");
                final Type3Message type3 = new Type3Message(src);
                final byte[] lmResponse = type3.getLMResponse() == null ? new byte[0] : type3.getLMResponse();
                final byte[] ntResponse = type3.getNTResponse() == null ? new byte[0] : type3.getNTResponse();
                final NtlmPasswordAuthentication ntlm = new NtlmPasswordAuthentication(
                        type3.getDomain(), type3.getUser(), challenge,
                        lmResponse, ntResponse);
                logger.debug("Trying to authenticate {} with domain controller", type3.getUser());
                try {
                    SmbSession.logon(dc, ntlm);
                    ntlmCredential.setPrincipal(this.principalFactory.createPrincipal(type3.getUser()));
                    success = true;
                } catch (final SmbAuthException sae) {
                    throw new FailedLoginException(sae.getMessage());
                }
                break;
            default:
                logger.debug("Unknown type: {}", src[NTLM_TOKEN_TYPE_FIELD_INDEX]);
        }
    } catch (final Exception e) {
        throw new FailedLoginException(e.getMessage());
    }

    if (!success) {
        throw new FailedLoginException();
    }
    return new DefaultHandlerResult(this, new BasicCredentialMetaData(ntlmCredential), ntlmCredential.getPrincipal());
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:68,代碼來源:NtlmAuthenticationHandler.java


注:本文中的jcifs.smb.NtlmPasswordAuthentication類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。