jdk/src/share/classes/com/sun/security/ntlm/Client.java
changeset 10348 7d1a82029332
parent 6517 151856936fd8
child 14342 8435a30053c1
equal deleted inserted replaced
10347:1c9efe1ec7d3 10348:7d1a82029332
    67      * @param domain domain of {@code username}, can be null
    67      * @param domain domain of {@code username}, can be null
    68      * @param password password for {@code username}, must not be not null.
    68      * @param password password for {@code username}, must not be not null.
    69      * This method does not make any modification to this parameter, it neither
    69      * This method does not make any modification to this parameter, it neither
    70      * needs to access the content of this parameter after this method call,
    70      * needs to access the content of this parameter after this method call,
    71      * so you are free to modify or nullify this parameter after this call.
    71      * so you are free to modify or nullify this parameter after this call.
    72      * @throws NullPointerException if {@code username} or {@code password} is null.
    72      * @throws NTLMException if {@code username} or {@code password} is null,
    73      * @throws NTLMException if {@code version} is illegal
    73      * or {@code version} is illegal.
       
    74      *
    74      */
    75      */
    75     public Client(String version, String hostname, String username,
    76     public Client(String version, String hostname, String username,
    76             String domain, char[] password) throws NTLMException {
    77             String domain, char[] password) throws NTLMException {
    77         super(version);
    78         super(version);
    78         if ((username == null || password == null)) {
    79         if ((username == null || password == null)) {
    79             throw new NullPointerException("username/password cannot be null");
    80             throw new NTLMException(NTLMException.PROTOCOL,
       
    81                     "username/password cannot be null");
    80         }
    82         }
    81         this.hostname = hostname;
    83         this.hostname = hostname;
    82         this.username = username;
    84         this.username = username;
    83         this.domain = domain;
    85         this.domain = domain;
    84         this.pw1 = getP1(password);
    86         this.pw1 = getP1(password);
   115      * Generates the Type 3 message
   117      * Generates the Type 3 message
   116      * @param type2 the responding Type 2 message from server, must not be null
   118      * @param type2 the responding Type 2 message from server, must not be null
   117      * @param nonce random 8-byte array to be used in message generation,
   119      * @param nonce random 8-byte array to be used in message generation,
   118      * must not be null except for original NTLM v1
   120      * must not be null except for original NTLM v1
   119      * @return the message generated
   121      * @return the message generated
   120      * @throws NullPointerException if {@code type2} or {@code nonce} is null
   122      * @throws NTLMException if the incoming message is invalid, or
   121      * for NTLM v1.
   123      * {@code nonce} is null for NTLM v1.
   122      * @throws NTLMException if the incoming message is invalid
       
   123      */
   124      */
   124     public byte[] type3(byte[] type2, byte[] nonce) throws NTLMException {
   125     public byte[] type3(byte[] type2, byte[] nonce) throws NTLMException {
   125         if (type2 == null || (v != Version.NTLM && nonce == null)) {
   126         if (type2 == null || (v != Version.NTLM && nonce == null)) {
   126             throw new NullPointerException("type2 and nonce cannot be null");
   127             throw new NTLMException(NTLMException.PROTOCOL,
       
   128                     "type2 and nonce cannot be null");
   127         }
   129         }
   128         debug("NTLM Client: Type 2 received\n");
   130         debug("NTLM Client: Type 2 received\n");
   129         debug(type2);
   131         debug(type2);
   130         Reader r = new Reader(type2);
   132         Reader r = new Reader(type2);
   131         byte[] challenge = r.readBytes(24, 8);
   133         byte[] challenge = r.readBytes(24, 8);