當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。