简体   繁体   中英

NTLM Authentication invalid character

I have a problem. When I try to access on my web application I have this error

Response header 'WWW-Authenticate' value of 'NTLM TlRMTVNTUAACAAAAAAAAACgAAAABggAAAAICAgAAAAAAAAAAAAAAAA==\\n' contains invalid characters, aborting request

I read about the NTLM Authentication and how it works but I don't understand why there is the special character \\n in the response and how I can fix it.

Anyone has the same problem?

RESOLVED

byte[] msg1 = { (byte) 'N', (byte) 'T', (byte) 'L',
                        (byte) 'M', (byte) 'S', (byte) 'S', (byte) 'P', z,
                        (byte) 2, z, z, z, z, z, z, z, (byte) 40, z, z, z,
                        (byte) 1, (byte) 130, z, z, z, (byte) 2, (byte) 2,
                        (byte) 2, z, z, z, z, z, z, z, z, z, z, z, z };
                res.setHeader("WWW-Authenticate", "NTLM "
                        + new sun.misc.BASE64Encoder().encodeBuffer(msg1).trim());
                res.sendError(HttpServletResponse.SC_UNAUTHORIZED);

In this case I added the trim() function and that s work for me!!

RESOLVED

byte[] msg1 = { (byte) 'N', (byte) 'T', (byte) 'L',
                        (byte) 'M', (byte) 'S', (byte) 'S', (byte) 'P', z,
                        (byte) 2, z, z, z, z, z, z, z, (byte) 40, z, z, z,
                        (byte) 1, (byte) 130, z, z, z, (byte) 2, (byte) 2,
                        (byte) 2, z, z, z, z, z, z, z, z, z, z, z, z };
                res.setHeader("WWW-Authenticate", "NTLM "
                        + new sun.misc.BASE64Encoder().encodeBuffer(msg1).trim());
                res.sendError(HttpServletResponse.SC_UNAUTHORIZED);

In this case I added the trim() function and that s work for me!! – travis_91

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM