本文整理汇总了Java中org.mortbay.jetty.security.B64Code类的典型用法代码示例。如果您正苦于以下问题:Java B64Code类的具体用法?Java B64Code怎么用?Java B64Code使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
B64Code类属于org.mortbay.jetty.security包,在下文中一共展示了B64Code类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: service
import org.mortbay.jetty.security.B64Code; //导入依赖的package包/类
@Override
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
System.out.println("Handling Proxy request for " + ((Request) req).getUri().toString());
if ( authRequired )
{
final HttpServletRequest request = (HttpServletRequest) req;
final HttpServletResponse response = (HttpServletResponse) res;
String proxyAuthorization = request.getHeader( "Proxy-Authorization" );
if ( proxyAuthorization != null && proxyAuthorization.startsWith( "Basic " ) )
{
String proxyAuth = proxyAuthorization.substring( 6 );
String authorization = B64Code.decode( proxyAuth );
String[] authTokens = authorization.split( ":" );
String user = authTokens[0];
String password = authTokens[1];
if ( user.equals(this.proxyUsername) && password.equals( this.proxyPassword ) )
{
super.service(req, res);
return;
}
}
// Proxy-Authenticate Basic realm="CCProxy Authorization"
response.addHeader( "Proxy-Authenticate", "Basic realm=\"Jetty Proxy Authorization\"" );
response.setStatus( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED );
System.out.println("Proxy Auth Creds not supplied");
} else {
super.service(req, res);
}
}
示例2: exec
import org.mortbay.jetty.security.B64Code; //导入依赖的package包/类
@Override
public String exec(Tuple input) throws IOException {
// validate input
if (input == null || input.size() == 0 || input.get(0) == null) {
return null;
}
//
if (input.get(0) == "") {
return input.get(0).toString();
}
if (input.size() > 1) {
throw new ExecException("Wrong number of arguments > 1", PigException.ERROR);
}
//
String str;
//Validating arguments
Object arg0 = input.get(0);
if (arg0 instanceof String)
str = (String) arg0;
else {
String msg = "Invalid data type for argument " + DataType.findTypeName(arg0);
throw new ExecException(msg, PigException.ERROR);
}
//decode
return new String(B64Code.encode(str.getBytes(StringUtil.__UTF8)));
}
示例3: exec
import org.mortbay.jetty.security.B64Code; //导入依赖的package包/类
@Override
public String exec(Tuple input) throws IOException {
// validate input
if (input == null || input.size() == 0 || input.get(0) == null) {
return null;
}
//
if (input.get(0) == "") {
return input.get(0).toString();
}
if (input.size() > 1) {
throw new ExecException("Wrong number of arguments > 1", PigException.ERROR);
}
//
String str;
//Validating arguments
Object arg0 = input.get(0);
if (arg0 instanceof String)
str = (String) arg0;
else {
String msg = "Invalid data type for argument " + DataType.findTypeName(arg0);
throw new ExecException(msg, PigException.ERROR);
}
try {
String strDecoded = B64Code.decode(str, StringUtil.__UTF8);
return new String(strDecoded);
} catch (IllegalArgumentException iae) {
return null;
}
}