Package jcifs.ntlmssp

Examples of jcifs.ntlmssp.Type3Message


                Type1Message type1 = new Type1Message(src);
                Type2Message type2 = new Type2Message(type1, challenge, null);
                msg = Base64.encode(type2.toByteArray());
                resp.setHeader( "WWW-Authenticate", "NTLM " + msg );
            } else if (src[8] == 3) {
                Type3Message type3 = new Type3Message(src);
                byte[] lmResponse = type3.getLMResponse();
                if (lmResponse == null) lmResponse = new byte[0];
                byte[] ntResponse = type3.getNTResponse();
                if (ntResponse == null) ntResponse = new byte[0];
                return new NtlmPasswordAuthentication(type3.getDomain(),
                        type3.getUser(), challenge, lmResponse, ntResponse);
            }
        } else {
            resp.setHeader("WWW-Authenticate", "NTLM");
        }
        resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
View Full Code Here


                response = parseResponseCode();
                if (response != HTTP_UNAUTHORIZED &&
                        response != HTTP_PROXY_AUTH) {
                    return;
                }
                Type3Message type3 = (Type3Message)
                        attemptNegotiation(response);
                if (type3 == null) return;
                connection.setRequestProperty(authProperty, authMethod + ' ' +
                        Base64.encode(type3.toByteArray()));
                connection.connect(); // send type 3
                if (cachedOutput != null && doOutput) {
                    OutputStream output = connection.getOutputStream();
                    cachedOutput.writeTo(output);
                    output.flush();
View Full Code Here

                    user = auth.getUserName();
                    password = new String(auth.getPassword());
                } catch (Exception ex) { }
            }
            Type2Message type2 = (Type2Message) message;
            message = new Type3Message(type2, password, domain, user,
                    Type3Message.getDefaultWorkstation(), 0);
        }
        return message;
    }
View Full Code Here

     *        in response to a {@link Type1Message} message previously sent.
     * @return a {@link Type3Message} to continue the authentication process.
     */
    public Type3Message createType3Message(NTCredentials ntCredentials, Type2Message type2Message)
    {
        return new Type3Message(type2Message, ntCredentials.getPassword(), type2Message.getTarget(),
                                ntCredentials.getUserName(), ntCredentials.getHost(), DEFAULT_TYPE_3_MESSAGE_FLAGS);
    }
View Full Code Here

                    log.debug("Type 2 returned. Setting next token.");
                    ntlmCredentials.setNextToken(type2.toByteArray());
                    return false;
                case 3:
                    log.debug("Type 3 received");
                    final Type3Message type3 = new Type3Message(src);
                    final byte[] lmResponse = type3.getLMResponse() == null
                        ? new byte[0] : type3.getLMResponse();
                    byte[] ntResponse = type3.getNTResponse() == null
                        ? new byte[0] : type3.getNTResponse();
                    final NtlmPasswordAuthentication ntlm = new NtlmPasswordAuthentication(
                        type3.getDomain(), type3.getUser(), challenge,
                        lmResponse, ntResponse);
                    log.debug("Trying to authenticate " + type3.getUser()
                        + " with domain controller");
                    try {
                        SmbSession.logon(dc, ntlm);
                        ntlmCredentials.setPrincipal(new SimplePrincipal(type3
                            .getUser()));
                        return true;
                    } catch (final SmbAuthException sae) {
                        log.debug("Authentication failed", sae);
                        return false;
View Full Code Here

            String domain = credentials.substring(0, credentials.indexOf("\\"));
            String user = credentials.substring(domain.length()+1, credentials.indexOf(":"));
            String password = credentials.substring(domain.length()+user.length()+2);
            Type2Message type2 = (Type2Message) message;
            flags ^= NtlmFlags.NTLMSSP_NEGOTIATE_OEM;
            message = new Type3Message(type2, password, domain, user, null, flags);
        }
        return authMethod + " " + Base64.encode(message.toByteArray());
    }
View Full Code Here

     *        in response to a {@link Type1Message} message previously sent.
     * @return a {@link Type3Message} to continue the authentication process.
     */
    public Type3Message createType3Message(NTCredentials ntCredentials, Type2Message type2Message)
    {
        return new Type3Message(type2Message, ntCredentials.getPassword(), type2Message.getTarget(),
                                ntCredentials.getUserName(), ntCredentials.getHost(), DEFAULT_TYPE_3_MESSAGE_FLAGS);
    }
View Full Code Here

  }

  public NtlmUserAccount authenticate(byte[] material, byte[] serverChallenge)
    throws IOException, NoSuchAlgorithmException, NtlmLogonException {

    Type3Message type3Message = new Type3Message(material);

    if (type3Message.getFlag(
        _NTLMSSP_NEGOTIATE_EXTENDED_SESSION_SECURITY) &&
      (type3Message.getNTResponse().length == 24)) {

      MessageDigest messageDigest = MessageDigest.getInstance("MD5");

      byte[] bytes = new byte[16];

      System.arraycopy(serverChallenge, 0, bytes, 0, 8);
      System.arraycopy(type3Message.getLMResponse(), 0, bytes, 8, 8);

      messageDigest.update(bytes);

      serverChallenge = messageDigest.digest();
    }

    return _netlogon.logon(
       type3Message.getDomain(), type3Message.getUser(),
       type3Message.getWorkstation(), serverChallenge,
       type3Message.getNTResponse(), type3Message.getLMResponse());
  }
View Full Code Here

        try {
            t2m = new Type2Message(Base64.decode(challenge));
        } catch (IOException ex) {
            throw new NTLMEngineException("Invalid Type2 message", ex);
        }
        Type3Message t3m = new Type3Message(t2m, password, domain, username, workstation);
        return Base64.encode(t3m.toByteArray());
    }
View Full Code Here

            return Base64.encode(type1Message.toByteArray());
        }

        public String generateType3Msg(String username, String password, String domain, String workstation, String challenge) throws NTLMEngineException {
            Type2Message type2Message = decodeType2Message(challenge);
            Type3Message type3Message = new Type3Message(type2Message, password, domain, username, workstation, Type3Message.getDefaultFlags());
            return Base64.encode(type3Message.toByteArray());
        }
View Full Code Here

TOP

Related Classes of jcifs.ntlmssp.Type3Message

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.