本文整理匯總了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;
}
}