550
551 return tokens[j];
552 }
553 }
554 }
555 }
556
557 return null; // none found
558 }
559
560 /**
561 * Returns digest-response suitable for an initial authentication.
562 *
563 * The following are qdstr-val (quoted string values) as per RFC 2831,
564 * which means that any embedded quotes must be escaped.
565 * realm-value
566 * nonce-value
567 * username-value
568 * cnonce-value
569 * authzid-value
570 * @returns <tt>digest-response</tt> in a byte array
571 * @throws SaslException if there is an error generating the
572 * response value or the cnonce value.
573 */
574 private byte[] generateClientResponse(byte[] charset) throws IOException {
575
576 ByteArrayOutputStream digestResp = new ByteArrayOutputStream();
577
578 if (useUTF8) {
579 digestResp.write("charset=".getBytes(encoding));
580 digestResp.write(charset);
581 digestResp.write(',');
582 }
583
584 digestResp.write(("username=\"" +
585 quotedStringValue(username) + "\",").getBytes(encoding));
586
587 if (negotiatedRealm.length() > 0) {
588 digestResp.write(("realm=\"" +
589 quotedStringValue(negotiatedRealm) + "\",").getBytes(encoding));
590 }
|
550
551 return tokens[j];
552 }
553 }
554 }
555 }
556
557 return null; // none found
558 }
559
560 /**
561 * Returns digest-response suitable for an initial authentication.
562 *
563 * The following are qdstr-val (quoted string values) as per RFC 2831,
564 * which means that any embedded quotes must be escaped.
565 * realm-value
566 * nonce-value
567 * username-value
568 * cnonce-value
569 * authzid-value
570 * @return {@code digest-response} in a byte array
571 * @throws SaslException if there is an error generating the
572 * response value or the cnonce value.
573 */
574 private byte[] generateClientResponse(byte[] charset) throws IOException {
575
576 ByteArrayOutputStream digestResp = new ByteArrayOutputStream();
577
578 if (useUTF8) {
579 digestResp.write("charset=".getBytes(encoding));
580 digestResp.write(charset);
581 digestResp.write(',');
582 }
583
584 digestResp.write(("username=\"" +
585 quotedStringValue(username) + "\",").getBytes(encoding));
586
587 if (negotiatedRealm.length() > 0) {
588 digestResp.write(("realm=\"" +
589 quotedStringValue(negotiatedRealm) + "\",").getBytes(encoding));
590 }
|