本文整理汇总了Java中org.mortbay.jetty.security.B64Code.decode方法的典型用法代码示例。如果您正苦于以下问题:Java B64Code.decode方法的具体用法?Java B64Code.decode怎么用?Java B64Code.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.security.B64Code
的用法示例。
在下文中一共展示了B64Code.decode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
try {
String strDecoded = B64Code.decode(str, StringUtil.__UTF8);
return new String(strDecoded);
} catch (IllegalArgumentException iae) {
return null;
}
}