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


Java MessageBytes.toBytes方法代码示例

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


在下文中一共展示了MessageBytes.toBytes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processParameters

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
public void processParameters( MessageBytes data, String encoding ) {
    if( data==null || data.isNull() || data.getLength() <= 0 ) {
        return;
    }

    if( data.getType() != MessageBytes.T_BYTES ) {
        data.toBytes();
    }
    ByteChunk bc=data.getByteChunk();
    processParameters( bc.getBytes(), bc.getOffset(),
                       bc.getLength(), getCharset(encoding));
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:Parameters.java

示例2: processParameters

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
public void processParameters(MessageBytes data, String encoding) {
    if (data == null || data.isNull() || data.getLength() <= 0)
        return;

    if (data.getType() != MessageBytes.T_BYTES) {
        data.toBytes();
    }
    ByteChunk bc = data.getByteChunk();
    processParameters(bc.getBytes(), bc.getOffset(), bc.getLength(),
            encoding);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:Parameters.java

示例3: processParameters

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
public void processParameters(MessageBytes data, String encoding) {
	if (data == null || data.isNull() || data.getLength() <= 0) {
		return;
	}

	if (data.getType() != MessageBytes.T_BYTES) {
		data.toBytes();
	}
	ByteChunk bc = data.getByteChunk();
	processParameters(bc.getBytes(), bc.getOffset(), bc.getLength(), getCharset(encoding));
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:12,代码来源:Parameters.java

示例4: processCookies

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/** Add all Cookie found in the headers of a request.
 */
public  void processCookies( MimeHeaders headers ) {
    if( headers==null ) {
        return;// nothing to process
    }
    // process each "cookie" header
    int pos=0;
    while( pos>=0 ) {
        // Cookie2: version ? not needed
        pos=headers.findHeader( "Cookie", pos );
        // no more cookie headers headers
        if( pos<0 ) {
            break;
        }

        MessageBytes cookieValue=headers.getValue( pos );
        if( cookieValue==null || cookieValue.isNull() ) {
            pos++;
            continue;
        }

        if( cookieValue.getType() != MessageBytes.T_BYTES ) {
            Exception e = new Exception();
            log.warn("Cookies: Parsing cookie as String. Expected bytes.",
                    e);
            cookieValue.toBytes();
        }
        if(log.isDebugEnabled()) {
            log.debug("Cookies: Parsing b[]: " + cookieValue.toString());
        }
        ByteChunk bc=cookieValue.getByteChunk();
        if (CookieSupport.PRESERVE_COOKIE_HEADER) {
            int len = bc.getLength();
            if (len > 0) {
                byte[] buf = new byte[len];
                System.arraycopy(bc.getBytes(), bc.getOffset(), buf, 0, len);
                processCookieHeader(buf, 0, len);
            }
        } else {
            processCookieHeader( bc.getBytes(),
                    bc.getOffset(),
                    bc.getLength());
        }
        pos++;// search from the next position
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:48,代码来源:Cookies.java

示例5: authenticate

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Authenticate the user making this request, based on the specified login
 * configuration. Return <code>true</code> if any specified constraint has
 * been satisfied, or <code>false</code> if we have created a response
 * challenge already.
 *
 * @param request
 *            Request we are processing
 * @param response
 *            Response we are creating
 * @param config
 *            Login configuration describing how authentication should be
 *            performed
 *
 * @exception IOException
 *                if an input/output error occurs
 */
@Override
public boolean authenticate(Request request, HttpServletResponse response, LoginConfig config) throws IOException {

	if (checkForCachedAuthentication(request, response, true)) {
		return true;
	}

	// Validate any credentials already included with this request
	String username = null;
	String password = null;

	MessageBytes authorization = request.getCoyoteRequest().getMimeHeaders().getValue("authorization");

	if (authorization != null) {
		authorization.toBytes();
		ByteChunk authorizationBC = authorization.getByteChunk();
		if (authorizationBC.startsWithIgnoreCase("basic ", 0)) {
			authorizationBC.setOffset(authorizationBC.getOffset() + 6);

			byte[] decoded = Base64.decodeBase64(authorizationBC.getBuffer(), authorizationBC.getOffset(),
					authorizationBC.getLength());

			// Get username and password
			int colon = -1;
			for (int i = 0; i < decoded.length; i++) {
				if (decoded[i] == ':') {
					colon = i;
					break;
				}
			}

			if (colon < 0) {
				username = new String(decoded, B2CConverter.ISO_8859_1);
			} else {
				username = new String(decoded, 0, colon, B2CConverter.ISO_8859_1);
				password = new String(decoded, colon + 1, decoded.length - colon - 1, B2CConverter.ISO_8859_1);
			}

			authorizationBC.setOffset(authorizationBC.getOffset() - 6);
		}

		Principal principal = context.getRealm().authenticate(username, password);
		if (principal != null) {
			register(request, response, principal, HttpServletRequest.BASIC_AUTH, username, password);
			return (true);
		}
	}

	StringBuilder value = new StringBuilder(16);
	value.append("Basic realm=\"");
	if (config.getRealmName() == null) {
		value.append(REALM_NAME);
	} else {
		value.append(config.getRealmName());
	}
	value.append('\"');
	response.setHeader(AUTH_HEADER_NAME, value.toString());
	response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
	return (false);

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

示例6: processCookies

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Add all Cookie found in the headers of a request.
 */
public void processCookies(MimeHeaders headers) {
	if (headers == null) {
		return;// nothing to process
	}
	// process each "cookie" header
	int pos = 0;
	while (pos >= 0) {
		// Cookie2: version ? not needed
		pos = headers.findHeader("Cookie", pos);
		// no more cookie headers headers
		if (pos < 0) {
			break;
		}

		MessageBytes cookieValue = headers.getValue(pos);
		if (cookieValue == null || cookieValue.isNull()) {
			pos++;
			continue;
		}

		if (cookieValue.getType() != MessageBytes.T_BYTES) {
			Exception e = new Exception();
			log.warn("Cookies: Parsing cookie as String. Expected bytes.", e);
			cookieValue.toBytes();
		}
		if (log.isDebugEnabled()) {
			log.debug("Cookies: Parsing b[]: " + cookieValue.toString());
		}
		ByteChunk bc = cookieValue.getByteChunk();
		if (CookieSupport.PRESERVE_COOKIE_HEADER) {
			int len = bc.getLength();
			if (len > 0) {
				byte[] buf = new byte[len];
				System.arraycopy(bc.getBytes(), bc.getOffset(), buf, 0, len);
				processCookieHeader(buf, 0, len);
			}
		} else {
			processCookieHeader(bc.getBytes(), bc.getOffset(), bc.getLength());
		}
		pos++;// search from the next position
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:46,代码来源:Cookies.java


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