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


Java B64Code类代码示例

本文整理汇总了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);
       }

}
 
开发者ID:spyder007,项目名称:teamcity-msteams-notifier,代码行数:35,代码来源:MsTeamsNotificationTestProxyServer.java

示例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)));
}
 
开发者ID:christiangda,项目名称:pigiptools,代码行数:33,代码来源:Base64Encode.java

示例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;
    }
}
 
开发者ID:christiangda,项目名称:pigiptools,代码行数:38,代码来源:Base64Decode.java


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