当前位置: 首页>>代码示例>>Java>>正文


Java HexUtils类代码示例

本文整理汇总了Java中org.apache.tomcat.util.buf.HexUtils的典型用法代码示例。如果您正苦于以下问题:Java HexUtils类的具体用法?Java HexUtils怎么用?Java HexUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HexUtils类属于org.apache.tomcat.util.buf包,在下文中一共展示了HexUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Digest

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * Digest password using the algorithm specified and
 * convert the result to a corresponding hex string.
 * If exception, the plain credentials string is returned
 *
 * @param credentials Password or other credentials to use in
 *  authenticating this username
 * @param algorithm Algorithm used to do the digest
 * @param encoding Character encoding of the string to digest
 */
public static final String Digest(String credentials, String algorithm,
                                  String encoding) {

    try {
        // Obtain a new message digest with "digest" encryption
        MessageDigest md =
            (MessageDigest) MessageDigest.getInstance(algorithm).clone();

        // encode the credentials
        // Should use the digestEncoding, but that's not a static field
        if (encoding == null) {
            md.update(credentials.getBytes());
        } else {
            md.update(credentials.getBytes(encoding));
        }

        // Digest the credentials and return as hexadecimal
        return (HexUtils.toHexString(md.digest()));
    } catch(Exception ex) {
        log.error(ex);
        return credentials;
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:35,代码来源:RealmBase.java

示例2: dump

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * Dump the contents of the message, prefixed with the given String.
 */
public void dump(String msg) {
    if (log.isDebugEnabled()) {
        log.debug(msg + ": " + HexUtils.toHexString(buf) + " " + pos +"/" + (len + 4));
    }
    int max = pos;
    if (len + 4 > pos)
        max = len+4;
    if (max > 1000)
        max = 1000;
    if (log.isDebugEnabled()) {
        for (int j = 0; j < max; j += 16) { 
            log.debug(hexLine(buf, j, len));
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:AjpMessage.java

示例3: AjpProcessor

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
public AjpProcessor(int packetSize, JIoEndpoint endpoint) {

        this.endpoint = endpoint;

        request = new Request();
        request.setInputBuffer(new SocketInputBuffer());

        response = new Response();
        response.setHook(this);
        response.setOutputBuffer(new SocketOutputBuffer());
        request.setResponse(response);

        requestHeaderMessage = new AjpMessage(packetSize);
        responseHeaderMessage = new AjpMessage(packetSize);
        bodyMessage = new AjpMessage(packetSize);
        
        // Set the get body message buffer
        AjpMessage getBodyMessage = new AjpMessage(16);
        getBodyMessage.reset();
        getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
        getBodyMessage.appendInt(packetSize - Constants.READ_HEAD_LEN);
        getBodyMessage.end();
        getBodyMessageArray = new byte[getBodyMessage.getLen()];
        System.arraycopy(getBodyMessage.getBuffer(), 0, getBodyMessageArray, 
                0, getBodyMessage.getLen());

        // Cause loading of HexUtils
        int foo = HexUtils.DEC[0];

        // Cause loading of HttpMessages
        HttpMessages.getMessage(200);

    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:AjpProcessor.java

示例4: Http11Processor

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
public Http11Processor(int headerBufferSize, JIoEndpoint endpoint) {

        this.endpoint = endpoint;
        
        request = new Request();
        inputBuffer = new InternalInputBuffer(request, headerBufferSize);
        request.setInputBuffer(inputBuffer);

        response = new Response();
        response.setHook(this);
        outputBuffer = new InternalOutputBuffer(response, headerBufferSize);
        response.setOutputBuffer(outputBuffer);
        request.setResponse(response);

        initializeFilters();

        // Cause loading of HexUtils
        int foo = HexUtils.DEC[0];

        // Cause loading of FastHttpDateFormat
        FastHttpDateFormat.getCurrentDate();

    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:Http11Processor.java

示例5: Digest

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * Digest password using the algorithm specified and convert the result to a
 * corresponding hex string. If exception, the plain credentials string is
 * returned
 *
 * @param credentials
 *            Password or other credentials to use in authenticating this
 *            username
 * @param algorithm
 *            Algorithm used to do the digest
 * @param encoding
 *            Character encoding of the string to digest
 */
public static final String Digest(String credentials, String algorithm, String encoding) {

	try {
		// Obtain a new message digest with "digest" encryption
		MessageDigest md = (MessageDigest) MessageDigest.getInstance(algorithm).clone();

		// encode the credentials
		// Should use the digestEncoding, but that's not a static field
		if (encoding == null) {
			md.update(credentials.getBytes());
		} else {
			md.update(credentials.getBytes(encoding));
		}

		// Digest the credentials and return as hexadecimal
		return (HexUtils.toHexString(md.digest()));
	} catch (Exception ex) {
		log.error(ex);
		return credentials;
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:36,代码来源:RealmBase.java

示例6: dump

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * Dump the contents of the message, prefixed with the given String.
 */
public void dump(String msg) {
	if (log.isDebugEnabled()) {
		log.debug(msg + ": " + HexUtils.toHexString(buf) + " " + pos + "/" + (len + 4));
	}
	int max = pos;
	if (len + 4 > pos)
		max = len + 4;
	if (max > 1000)
		max = 1000;
	if (log.isDebugEnabled()) {
		for (int j = 0; j < max; j += 16) {
			log.debug(hexLine(buf, j, len));
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:19,代码来源:AjpMessage.java

示例7: process

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * splits and stores the digested value into the separate salt, iterations, and password.
 */
private final void process()
{
	final String[] sections = this.Value.split(Digest.DELIMETER);
	switch (sections.length)
	{
		case 1:
			this.salt = new byte[0];
			this.iterations = 1;
			this.encodedPassword = this.Value;
			break;
		case 3:
			this.salt = HexUtils.fromHexString(sections[0]);
			this.iterations = Integer.parseInt(sections[1]);
			this.encodedPassword = sections[2];
			break;
		default:
			throw new IllegalArgumentException("Digest format incorrect");
	}
}
 
开发者ID:logdyn,项目名称:yeovil_microsoft_cognitive_ai,代码行数:23,代码来源:Digest.java

示例8: Digest

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * Digest password using the algorithm specified and
 * convert the result to a corresponding hex string.
 * If exception, the plain credentials string is returned
 *
 * @param credentials Password or other credentials to use in
 *  authenticating this username
 * @param algorithm Algorithm used to do the digest
 * @param encoding Character encoding of the string to digest
 */
public static final String Digest(String credentials, String algorithm,
                                  String encoding) {

    try {
        // Obtain a new message digest with "digest" encryption
        MessageDigest md =
            (MessageDigest) MessageDigest.getInstance(algorithm).clone();

        // encode the credentials
        // Should use the digestEncoding, but that's not a static field
        if (encoding == null) {
            md.update(credentials.getBytes());
        } else {
            md.update(credentials.getBytes(encoding));                
        }

        // Digest the credentials and return as hexadecimal
        return (HexUtils.toHexString(md.digest()));
    } catch(Exception ex) {
        log.error(ex);
        return credentials;
    }

}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:35,代码来源:RealmBase.java

示例9: doWrite

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * Write some bytes.
 * 
 * @return number of bytes written by the filter
 */
@Override
public int doWrite(ByteChunk chunk, Response res)
    throws IOException {

    int result = chunk.getLength();

    if (result <= 0) {
        return 0;
    }

    // Calculate chunk header
    int pos = 7;
    int current = result;
    while (current > 0) {
        int digit = current % 16;
        current = current / 16;
        chunkLength[pos--] = HexUtils.getHex(digit);
    }
    chunkHeader.setBytes(chunkLength, pos + 1, 9 - pos);
    buffer.doWrite(chunkHeader, res);

    buffer.doWrite(chunk, res);

    chunkHeader.setBytes(chunkLength, 8, 2);
    buffer.doWrite(chunkHeader, res);

    return result;

}
 
开发者ID:sdw2330976,项目名称:apache-tomcat-7.0.57,代码行数:35,代码来源:ChunkedOutputFilter.java

示例10: digest

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * Digest the password using the specified algorithm and
 * convert the result to a corresponding hexadecimal string.
 * If exception, the plain credentials string is returned.
 *
 * @param credentials Password or other credentials to use in
 *  authenticating this username
 */
protected String digest(String credentials)  {

    // If no MessageDigest instance is specified, return unchanged
    if (hasMessageDigest() == false)
        return (credentials);

    // Digest the user credentials and return as hexadecimal
    synchronized (this) {
        try {
            md.reset();

            byte[] bytes = null;
            try {
                bytes = credentials.getBytes(getDigestCharset());
            } catch (UnsupportedEncodingException uee) {
                log.error("Illegal digestEncoding: " + getDigestEncoding(), uee);
                throw new IllegalArgumentException(uee.getMessage());
            }
            md.update(bytes);

            return (HexUtils.toHexString(md.digest()));
        } catch (Exception e) {
            log.error(sm.getString("realmBase.digest"), e);
            return (credentials);
        }
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:37,代码来源:RealmBase.java

示例11: toString

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * Returns a String useful for debugging (especially within a debugger.)
 *
 * @return a String useful for debugging.
 */
@SuppressWarnings("boxing") // OK to ignore boxing here
@Override
public String toString() {
    return String.format("%s[buffer=%s, currentLinePos=%s, eof=%s, " +
            "ibitWorkArea=%s, lbitWorkArea=%s, modulus=%s, pos=%s, " +
            "readPos=%s]", this.getClass().getSimpleName(),
            HexUtils.toHexString(buffer), currentLinePos, eof,
            ibitWorkArea, lbitWorkArea, modulus, pos, readPos);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:15,代码来源:BaseNCodec.java

示例12: AjpAprProcessor

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
public AjpAprProcessor(int packetSize, AprEndpoint endpoint) {

        this.endpoint = endpoint;

        request = new Request();
        request.setInputBuffer(new SocketInputBuffer());

        response = new Response();
        response.setHook(this);
        response.setOutputBuffer(new SocketOutputBuffer());
        request.setResponse(response);

        requestHeaderMessage = new AjpMessage(packetSize);
        responseHeaderMessage = new AjpMessage(packetSize);
        bodyMessage = new AjpMessage(packetSize);
        
        // Allocate input and output buffers
        inputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
        inputBuffer.limit(0);
        outputBuffer = ByteBuffer.allocateDirect(packetSize * 2);

        // Set the get body message buffer
        AjpMessage getBodyMessage = new AjpMessage(16);
        getBodyMessage.reset();
        getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
        getBodyMessage.appendInt(packetSize - Constants.READ_HEAD_LEN);
        getBodyMessage.end();
        getBodyMessageBuffer =
            ByteBuffer.allocateDirect(getBodyMessage.getLen());
        getBodyMessageBuffer.put(getBodyMessage.getBuffer(), 0,
                getBodyMessage.getLen());

        // Cause loading of HexUtils
        int foo = HexUtils.DEC[0];

        // Cause loading of HttpMessages
        HttpMessages.getMessage(200);

    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:AjpAprProcessor.java

示例13: doWrite

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * Write some bytes.
 * 
 * @return number of bytes written by the filter
 */
public int doWrite(ByteChunk chunk, Response res)
    throws IOException {

    int result = chunk.getLength();

    if (result <= 0) {
        return 0;
    }

    // Calculate chunk header
    int pos = 7;
    int current = result;
    while (current > 0) {
        int digit = current % 16;
        current = current / 16;
        chunkLength[pos--] = HexUtils.HEX[digit];
    }
    chunkHeader.setBytes(chunkLength, pos + 1, 9 - pos);
    buffer.doWrite(chunkHeader, res);

    buffer.doWrite(chunk, res);

    chunkHeader.setBytes(chunkLength, 8, 2);
    buffer.doWrite(chunkHeader, res);

    return result;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:ChunkedOutputFilter.java

示例14: digest

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * Digest the password using the specified algorithm and convert the result
 * to a corresponding hexadecimal string. If exception, the plain
 * credentials string is returned.
 *
 * @param credentials
 *            Password or other credentials to use in authenticating this
 *            username
 */
protected String digest(String credentials) {

	// If no MessageDigest instance is specified, return unchanged
	if (hasMessageDigest() == false)
		return (credentials);

	// Digest the user credentials and return as hexadecimal
	synchronized (this) {
		try {
			md.reset();

			byte[] bytes = null;
			try {
				bytes = credentials.getBytes(getDigestCharset());
			} catch (UnsupportedEncodingException uee) {
				log.error("Illegal digestEncoding: " + getDigestEncoding(), uee);
				throw new IllegalArgumentException(uee.getMessage());
			}
			md.update(bytes);

			return (HexUtils.toHexString(md.digest()));
		} catch (Exception e) {
			log.error(sm.getString("realmBase.digest"), e);
			return (credentials);
		}
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:38,代码来源:RealmBase.java

示例15: doWrite

import org.apache.tomcat.util.buf.HexUtils; //导入依赖的package包/类
/**
 * Write some bytes.
 * 
 * @return number of bytes written by the filter
 */
@Override
public int doWrite(ByteChunk chunk, Response res) throws IOException {

	int result = chunk.getLength();

	if (result <= 0) {
		return 0;
	}

	// Calculate chunk header
	int pos = 7;
	int current = result;
	while (current > 0) {
		int digit = current % 16;
		current = current / 16;
		chunkLength[pos--] = HexUtils.getHex(digit);
	}
	chunkHeader.setBytes(chunkLength, pos + 1, 9 - pos);
	buffer.doWrite(chunkHeader, res);

	buffer.doWrite(chunk, res);

	chunkHeader.setBytes(chunkLength, 8, 2);
	buffer.doWrite(chunkHeader, res);

	return result;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:34,代码来源:ChunkedOutputFilter.java


注:本文中的org.apache.tomcat.util.buf.HexUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。