Allows retrieval of the full token.

@return the encoded header, claims and crypto segments concatenated with "."
characters
176982
@Override
	public byte[] bytes() {
		return concat(b64UrlEncode(header.bytes()), JwtHelper.PERIOD,
				b64UrlEncode(content), JwtHelper.PERIOD, b64UrlEncode(crypto));
	}
680148
@Override
    public List<String> getTokens() {
        //List<String> tokens = new ArrayList<>();
        if (!tokens.isEmpty())
            return tokens;

        log.info("Starting prebuffering...");
        while (streamHasMoreTokens()) {
            tokens.add(nextTokenFromStream());
        }
        log.info("Tokens prefetch finished. Tokens size: [" + tokens.size() + "]");
        return tokens;
    }
1339935
private String[] extractAndDecodeHeader(String header) throws IOException {

        byte[] base64Token = header.substring(6).getBytes(CREDENTIALS_CHARSET);
        byte[] decoded;
        try {
            decoded = Base64.decode(base64Token);
        } catch (IllegalArgumentException e) {
            throw new BadCredentialsException("Failed to decode basic authentication token");
        }

        String token = new String(decoded, CREDENTIALS_CHARSET);

        int delim = token.indexOf(":");

        if (delim == -1) {
            throw new BadCredentialsException("Invalid basic authentication token");
        }
        return new String[] {token.substring(0, delim), token.substring(delim + 1)};
    }
1017494
public String getHexEncodedBytes() {
        buffer.b().flip();
        byte bytes[] = new byte[buffer.b().remaining()];
        buffer.b().get(bytes);
        String hex = Encoder.hexEncode(bytes);
        buffer.discard();
        return hex;
    }
753151
private static String getToken(URI blobId) {
        String[] parts = blobId.getSchemeSpecificPart().split("/");
        if (parts.length == 2) {
            return parts[1];
        } else if (parts.length == 4) {
            return parts[1] + "+"  + uriDecode(parts[2]) + "+"
                    + uriDecode(parts[3]);
        } else {
            throw new IllegalArgumentException("Malformed token-as-blobId: "
                    + blobId);
        }
    }
469834
public String getHeader() {
        String authPair = username + ':' + apiKey;
        return "Basic " + Base64.getEncoder().encodeToString(authPair.getBytes());
    }
872131
public BytesRef getPayload() throws IOException {

    // initial bits - position
    if (mtasToken.checkPositionType(MtasPosition.POSITION_SINGLE)) {
      byteStream.writeBit(0);
      byteStream.writeBit(0);
    } else if (mtasToken.checkPositionType(MtasPosition.POSITION_RANGE)) {
      byteStream.writeBit(1);
      byteStream.writeBit(0);
    } else if (mtasToken.checkPositionType(MtasPosition.POSITION_SET)) {
      byteStream.writeBit(0);
      byteStream.writeBit(1);
    } else {
      byteStream.writeBit(1);
      byteStream.writeBit(1);
    }
    // initial bits - offset
    if ((encodingFlags & ENCODE_OFFSET) == ENCODE_OFFSET
        && mtasToken.checkOffset()) {
      byteStream.writeBit(1);
    } else {
      byteStream.writeBit(0);
    }
    // initial bits - realOffset
    if ((encodingFlags & ENCODE_REALOFFSET) == ENCODE_REALOFFSET
        && mtasToken.checkRealOffset()) {
      byteStream.writeBit(1);
    } else {
      byteStream.writeBit(0);
    }
    // initial bits - parentId
    if ((encodingFlags & ENCODE_PARENT) == ENCODE_PARENT
        && mtasToken.checkParentId()) {
      byteStream.writeBit(1);
    } else {
      byteStream.writeBit(0);
    }
    // initial bits - original payload
    if ((encodingFlags & ENCODE_PAYLOAD) == ENCODE_PAYLOAD
        && mtasToken.getPayload() != null) {
      byteStream.writeBit(1);
    } else {
      byteStream.writeBit(0);
    }
    if (mtasToken.getType().equals(MtasTokenString.TOKEN_TYPE)) {
      byteStream.writeBit(0);
    } else {
      // to add other token types later on
      byteStream.writeBit(1);
    }
    // add id (EliasGammaCoding)
    byteStream.writeEliasGammaCodingNonNegativeInteger(mtasToken.getId());
    // add position info (EliasGammaCoding)
    if (mtasToken.checkPositionType(MtasPosition.POSITION_SINGLE)) {
      // do nothing
    } else if (mtasToken.checkPositionType(MtasPosition.POSITION_RANGE)) {
      // write length
      byteStream.writeEliasGammaCodingPositiveInteger(
          1 + mtasToken.getPositionEnd() - mtasToken.getPositionStart());
    } else if (mtasToken.checkPositionType(MtasPosition.POSITION_SET)) {
      // write number of positions
      int[] positionList = mtasToken.getPositions();
      byteStream.writeEliasGammaCodingPositiveInteger(positionList.length);
      int previousPosition = positionList[0];
      for (int i = 1; i < positionList.length; i++) {
        byteStream.writeEliasGammaCodingPositiveInteger(
            positionList[i] - previousPosition);
        previousPosition = positionList[i];
      }
    } else {
      // do nothing
    }
    // add offset info (EliasGammaCoding)
    if ((encodingFlags & ENCODE_OFFSET) == ENCODE_OFFSET
        && mtasToken.checkOffset()) {
      byteStream
          .writeEliasGammaCodingNonNegativeInteger(mtasToken.getOffsetStart());
      byteStream.writeEliasGammaCodingPositiveInteger(
          1 + mtasToken.getOffsetEnd() - mtasToken.getOffsetStart());
    }
    // add realOffset info (EliasGammaCoding)
    if ((encodingFlags & ENCODE_REALOFFSET) == ENCODE_REALOFFSET
        && mtasToken.checkRealOffset()) {
      if ((encodingFlags & ENCODE_OFFSET) == ENCODE_OFFSET
          && mtasToken.checkOffset()) {
        byteStream.writeEliasGammaCodingInteger(
            mtasToken.getRealOffsetStart() - mtasToken.getOffsetStart());
        byteStream.writeEliasGammaCodingPositiveInteger(
            1 + mtasToken.getRealOffsetEnd() - mtasToken.getRealOffsetStart());
      } else {
        byteStream.writeEliasGammaCodingNonNegativeInteger(
            mtasToken.getRealOffsetStart());
        byteStream.writeEliasGammaCodingPositiveInteger(
            1 + mtasToken.getRealOffsetEnd() - mtasToken.getRealOffsetStart());
      }
    }
    // add parent info (EliasGammaCoding)
    if ((encodingFlags & ENCODE_PARENT) == ENCODE_PARENT
        && mtasToken.checkParentId()) {
      byteStream.writeEliasGammaCodingInteger(
          mtasToken.getParentId() - mtasToken.getId());
    }
    // add minimal number of zero-bits to get round number of bytes
    byteStream.createByte();
    // finally add original payload bytes
    if ((encodingFlags & ENCODE_PAYLOAD) == ENCODE_PAYLOAD
        && mtasToken.getPayload() != null) {
      BytesRef payload = mtasToken.getPayload();
      byteStream.write(Arrays.copyOfRange(payload.bytes, payload.offset,
          (payload.offset + payload.length)));
    }
    // construct new payload
    return new BytesRef(byteStream.toByteArray());
  }
592362
static String[] splitToken(String token) throws JWTDecodeException {
        String[] parts = token.split("\\.");
        if (parts.length == 2 && token.endsWith(".")) {
            //Tokens with alg='none' have empty String as Signature.
            parts = new String[]{parts[0], parts[1], ""};
        }
        if (parts.length != 3) {
            throw new JWTDecodeException(String.format("The token was expected to have 3 parts, but got %s.", parts.length));
        }
        return parts;
    }
238253
public String nextToken() 
  {
    int delPos;
    /* Scan for the next delimiter or end of data */
    for (delPos = position; delPos < dataLength; delPos++)
    {
      char c = data.charAt (delPos);
      if (delimiters.indexOf (c) != -1)
        break;
    }
    /* Find out what the token should be */
    String ret = data.substring (position, delPos);
    /* Set the position to the next position */
    position = delPos+1;
    return ret;
  }
780104
public byte[] getPayload() {

        ByteString ret = getChaincodeEvent().getPayload();
        if (null == ret) {
            return null;
        }

        return ret.toByteArray();

    }
1263932
public String getText()
    {
        StringBuilder text = new StringBuilder();
        Token t = firstToken;
        while ( t!=null ) {
            text.append(t.image);
            if ( !t.image.equals(".") )
                text.append(" ");
            if ( t==lastToken ||
                t.image.equals("{") || t.image.equals(";") )
                break;
            t=t.next;
        }

        return text.toString();
    }
1185156
public String toHeader() {
		StringBuilder header = new StringBuilder();
		header.append(name).append('=').append(value);
		if (domain != null) {
			header.append("; ").append("Domain=").append(domain);
		}
		if (path != null) {
			header.append("; ").append("Path=").append(path);
		}
		if (expireTime > -1) {
			header.append("; ").append("Expires=").append(RFC_DATEFORMAT.format(new Date(expireTime)));
		}
		if (secure) {
			header.append("; ").append("Secure");
		}
		return header.toString();
	}
1038870
private String getAuthenticationToken() {

        String token = request.getParameter("token");
        if (token != null && !token.isEmpty())
            return token;
        
        return null;

    }
321501
public String toJwt() {
        Map<String, Object> headers = new HashMap<>();
        headers.put("typ", "JWT");
        headers.putAll(this.getHeaders());

        JwtBuilder builder =
            Jwts.builder()
                .signWith(this.algorithm, this.secretKey)
                .setHeaderParams(headers)
                .setIssuer(this.issuer)
                .setExpiration(expiration);

        if (this.getClaims() != null) {
            for (Map.Entry<String, Object> entry : this.getClaims().entrySet()) {
                builder.claim(entry.getKey(), entry.getValue());
            }
        }

        if (this.getId() != null) {
            builder.setId(this.getId());
        }

        if (this.getSubject() != null) {
            builder.setSubject(this.getSubject());
        }

        if (this.getNbf() != null) {
            builder.setNotBefore(this.getNbf());
        }

        return builder.compact();
    }
1072113
public Set<Character> tokens() {
    return root().getChildrenMap().keySet().stream()
      .filter(c -> c != END_OF_STRING && c != FALLBACK && c != ESCAPE)
      .collect(Collectors.toSet());
  }
369154
private String getAuthorizationToken(final HttpHeaders headers) {
        if (headers.getCookies() != null) {
            for (Map.Entry<String, Cookie> entry : headers.getCookies().entrySet()) {
                if (AuthorizationTokenCookie.COOKIE_NAME.equals(entry.getValue().getName())) {
                    return entry.getValue().getValue();
                }
            }
        }
        final List<String> header = headers.getRequestHeader("Authorization");
        if (header != null) {
            final String bearer = header.get(0);
            if (bearer != null) {
                return bearer.substring("Bearer ".length());
            }
        }
        return null;
    }
553756
public String getAuthString() {
        String credentials = this.username + ":" + this.password;
        try {

            String encoded = new Base64().encodeAsString(credentials.getBytes("ascii"));
            return "Basic " + encoded;

        } catch (final UnsupportedEncodingException e) {

            throw new InvalidRequestException("It must be possible to encode credentials as ascii", credentials, e);

        }
    }