[jbpm-cvs] jbpm.3/designer/jpdl/org.jbpm.gd.jpdl/src/org/jbpm/gd/jpdl/util ...

Koen Aers <[email protected]> Fri, 20 Feb 2009 08:54:01 -0500
Newsgroups gmane.comp.jbpm.cvs
Message-ID <[email protected]>
  User: kaers   
  Date: 09/02/20 08:54:01

  Modified:    designer/jpdl/org.jbpm.gd.jpdl/src/org/jbpm/gd/jpdl/util 
                        Tag: branch_jbpm_jpdl_gpd_3_1_x
                        ProcessDeployer.java
  Log:
  GPD-297
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.2   +93 -5     jbpm.3/designer/jpdl/org.jbpm.gd.jpdl/src/org/jbpm/gd/jpdl/util/Attic/ProcessDeployer.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ProcessDeployer.java
  ===================================================================
  RCS file: /cvsroot/jbpm/jbpm.3/designer/jpdl/org.jbpm.gd.jpdl/src/org/jbpm/gd/jpdl/util/Attic/ProcessDeployer.java,v
  retrieving revision 1.1.4.1
  retrieving revision 1.1.4.2
  diff -u -b -r1.1.4.1 -r1.1.4.2
  --- ProcessDeployer.java	20 Feb 2009 06:35:19 -0000	1.1.4.1
  +++ ProcessDeployer.java	20 Feb 2009 13:54:01 -0000	1.1.4.2
  @@ -9,6 +9,7 @@
   import java.io.InputStream;
   import java.net.Authenticator;
   import java.net.ConnectException;
  +import java.net.HttpURLConnection;
   import java.net.MalformedURLException;
   import java.net.PasswordAuthentication;
   import java.net.URL;
  @@ -195,11 +196,6 @@
   	}
   
   	private void deployProcessWithServlet(byte[] parBytes) throws Exception {
  -		Authenticator.setDefault(new Authenticator() {
  -		    protected PasswordAuthentication getPasswordAuthentication() {
  -		    	return new PasswordAuthentication("user", "user".toCharArray());
  -		    }
  -		});
   		URL url = new URL("http://" + serverName + ":" + serverPort + serverDeployer);
   		URLConnection urlConnection = url.openConnection();
   		urlConnection.setDoInput(true);
  @@ -207,6 +203,8 @@
   		urlConnection.setUseCaches(false);
   		urlConnection.setRequestProperty("Content-Type",
   				"multipart/form-data; boundary=AaB03x");
  +		String encoding = Base64Converter.encode("user:user".getBytes());
  +		urlConnection.setRequestProperty ("Authorization", "Basic " + encoding);
   		DataOutputStream dataOutputStream = new DataOutputStream(urlConnection
   				.getOutputStream());
   		dataOutputStream.writeBytes("--" + boundary + "\r\n");
  @@ -330,4 +328,94 @@
   		return urls;
   	}
   	
  +    public static class  Base64Converter
  +    //////////////////////////////////////////////////////////////////////
  +    //////////////////////////////////////////////////////////////////////
  +    {
  +
  +   public static final char [ ]  alphabet = {
  +      'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',   //  0 to  7
  +      'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',   //  8 to 15
  +      'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',   // 16 to 23
  +      'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',   // 24 to 31
  +      'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',   // 32 to 39
  +      'o', 'p', 'q', 'r', 's', 't', 'u', 'v',   // 40 to 47
  +      'w', 'x', 'y', 'z', '0', '1', '2', '3',   // 48 to 55
  +      '4', '5', '6', '7', '8', '9', '+', '/' }; // 56 to 63
  +
  +   //////////////////////////////////////////////////////////////////////
  +    //////////////////////////////////////////////////////////////////////
  +
  +   public static String  encode ( String  s )
  +    //////////////////////////////////////////////////////////////////////
  +    {
  +      return encode ( s.getBytes ( ) );
  +    }
  +
  +   public static String  encode ( byte [ ]  octetString )
  +    //////////////////////////////////////////////////////////////////////
  +    {
  +      int  bits24;
  +      int  bits6;
  +
  +     char [ ]  out
  +        = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];
  +
  +     int outIndex = 0;
  +      int i        = 0;
  +
  +     while ( ( i + 3 ) <= octetString.length )
  +      {
  +        // store the octets
  +        bits24  = ( octetString [ i++ ] & 0xFF ) << 16; 
  +        bits24 |= ( octetString [ i++ ] & 0xFF ) <<  8; 
  +        bits24 |= ( octetString [ i++ ] & 0xFF ) <<  0;
  +
  +       bits6 = ( bits24 & 0x00FC0000 ) >> 18; 
  +        out [ outIndex++ ] = alphabet [ bits6 ];
  +        bits6 = ( bits24 & 0x0003F000 ) >> 12; 
  +        out [ outIndex++ ] = alphabet [ bits6 ];
  +        bits6 = ( bits24 & 0x00000FC0 ) >> 6; 
  +        out [ outIndex++ ] = alphabet [ bits6 ];
  +        bits6 = ( bits24 & 0x0000003F );
  +        out [ outIndex++ ] = alphabet [ bits6 ]; 
  +      }
  +
  +     if ( octetString.length - i == 2 )
  +      {
  +        // store the octets 
  +        bits24  = ( octetString [ i     ] & 0xFF ) << 16; 
  +        bits24 |= ( octetString [ i + 1 ] & 0xFF ) <<  8;
  +
  +       bits6 = ( bits24 & 0x00FC0000 ) >> 18;
  +        out [ outIndex++ ] = alphabet [ bits6 ]; 
  +        bits6 = ( bits24 & 0x0003F000 ) >> 12; 
  +        out [ outIndex++ ] = alphabet [ bits6 ]; 
  +        bits6 = ( bits24 & 0x00000FC0 ) >> 6; 
  +        out [ outIndex++ ] = alphabet [ bits6 ];
  +
  +       // padding
  +        out [ outIndex++ ] = '='; 
  +      }
  +      else if ( octetString.length - i == 1 )
  +      {
  +        // store the octets 
  +        bits24 = ( octetString [ i ] & 0xFF ) << 16;
  +
  +       bits6 = ( bits24 & 0x00FC0000 ) >> 18;
  +        out [ outIndex++ ] = alphabet [ bits6 ];
  +        bits6 = ( bits24 & 0x0003F000 ) >> 12; 
  +        out [ outIndex++ ] = alphabet [ bits6 ];
  +
  +       // padding
  +        out [ outIndex++ ] = '='; 
  +        out [ outIndex++ ] = '='; 
  +      }
  +
  +     return new String ( out );
  +    }
  +
  +   //////////////////////////////////////////////////////////////////////
  +    //////////////////////////////////////////////////////////////////////
  +    }
   }
  
  
  

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H