Package jcifs.smb

Examples of jcifs.smb.NtlmPasswordAuthentication


         if(smbFileName.getUriWithoutAuth().startsWith("smb://_master_/_browser_")) {
           path = smbFileName.getUriWithoutAuth().replaceAll("/_master_/_browser_", "");
         } else
           path = smbFileName.getUriWithoutAuth();

        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(
            smbFileName.getDomain(), smbFileName.getUserName(), smbFileName.getPassword());
        SmbFile file = new SmbFile(path, auth);

        if (file.isDirectory() && !file.toString().endsWith("/"))
        {
View Full Code Here


    public void doFilter( ServletRequest request,
                ServletResponse response,
                FilterChain chain ) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest)request;
        HttpServletResponse resp = (HttpServletResponse)response;
        NtlmPasswordAuthentication ntlm;

        if ((ntlm = negotiate( req, resp, false )) == null) {
            return;
        }
View Full Code Here

    protected NtlmPasswordAuthentication negotiate( HttpServletRequest req,
                HttpServletResponse resp,
                boolean skipAuthentication ) throws IOException, ServletException {
        UniAddress dc;
        String msg;
        NtlmPasswordAuthentication ntlm = null;
        msg = req.getHeader( "Authorization" );
        boolean offerBasic = enableBasic && (insecureBasic || req.isSecure());

        if( msg != null && (msg.startsWith( "NTLM " ) ||
                    (offerBasic && msg.startsWith("Basic ")))) {
            if (msg.startsWith("NTLM ")) {
                HttpSession ssn = req.getSession();
                byte[] challenge;

                if( loadBalance ) {
                    NtlmChallenge chal = (NtlmChallenge)ssn.getAttribute( "NtlmHttpChal" );
                    if( chal == null ) {
                        chal = SmbSession.getChallengeForDomain();
                        ssn.setAttribute( "NtlmHttpChal", chal );
                    }
                    dc = chal.dc;
                    challenge = chal.challenge;
                } else {
                    dc = UniAddress.getByName( domainController, true );
                    challenge = SmbSession.getChallenge( dc );
                }

                if(( ntlm = NtlmSsp.authenticate( req, resp, challenge )) == null ) {
                    return null;
                }
                /* negotiation complete, remove the challenge object */
                ssn.removeAttribute( "NtlmHttpChal" );
            } else {
                String auth = new String(Base64.decode(msg.substring(6)),
                        "US-ASCII");
                int index = auth.indexOf(':');
                String user = (index != -1) ? auth.substring(0, index) : auth;
                String password = (index != -1) ? auth.substring(index + 1) :
                        "";
                index = user.indexOf('\\');
                if (index == -1) index = user.indexOf('/');
                String domain = (index != -1) ? user.substring(0, index) :
                        defaultDomain;
                user = (index != -1) ? user.substring(index + 1) : user;
                ntlm = new NtlmPasswordAuthentication(domain, user, password);
                dc = UniAddress.getByName( domainController, true );
            }
            try {

                SmbSession.logon( dc, ntlm );

                if( log.level > 2 ) {
                    log.println( "NtlmHttpFilter: " + ntlm +
                            " successfully authenticated against " + dc );
                }
            } catch( SmbAuthException sae ) {
                if( log.level > 1 ) {
                    log.println( "NtlmHttpFilter: " + ntlm.getName() +
                            ": 0x" + jcifs.util.Hexdump.toHexString( sae.getNtStatus(), 8 ) +
                            ": " + sae );
                }
                if( sae.getNtStatus() == sae.NT_STATUS_ACCESS_VIOLATION ) {
                    /* Server challenge no longer valid for
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

        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 );
View Full Code Here

        this.password = options.get(PASSWORD);
        int unmappedCifsPort = options.getInteger(CIFS_PORT, CIFS_PORT_DEFAULT);
        InetSocketAddress addressCifsPort = mapper.map(createUnresolved(unmappedAddress, unmappedCifsPort));
        this.cifsPort = addressCifsPort.getPort();
        this.encoder = new PathEncoder(null, null, this.address, cifsPort, options.get(PATH_SHARE_MAPPINGS, PATH_SHARE_MAPPINGS_DEFAULT));
        this.authentication = new NtlmPasswordAuthentication(null, username, password);
    }
View Full Code Here

            System.out.print("password: ");
            password = readLine();
            if (password.length() == 0) {
                return null;
            }
            return new NtlmPasswordAuthentication(domain, username, password);
        } catch (Exception e) {
            //empty
        }
        return null;
    }
View Full Code Here

    public final SMBFileSystemType getType() {
        return type;
    }

    protected NtlmPasswordAuthentication getNtlmPasswordAuthentication() {
        return new NtlmPasswordAuthentication("", device.getUser(), device.getPassword());
    }
View Full Code Here

        return new JIDefaultAuthInfoImpl("", userName, Secret.toString(password));
    }

    private NtlmPasswordAuthentication createSmbAuth() {
        JIDefaultAuthInfoImpl auth = createAuth();
        return new NtlmPasswordAuthentication(auth.getDomain(), auth.getUserName(), auth.getPassword());
    }
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.