Changeset 21
- Timestamp:
- 06/22/04 23:05:07
- Files:
-
- trunk/SubversionSharp/dev/src/SubversionSharp.prjx (modified) (1 diff)
- trunk/SubversionSharp/dev/src/Svn.cs (modified) (1 diff)
- trunk/SubversionSharp/dev/src/SvnAuthBaton.cs (added)
- trunk/SubversionSharp/dev/src/SvnAuthProvider.cs (modified) (5 diffs)
- trunk/SubversionSharp/test/src/Main.cs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/SubversionSharp/dev/src/SubversionSharp.prjx
r19 r21 11 11 <File name="./SvnAuthCred.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 12 12 <File name="./SvnAuthSslServerCertInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 13 <File name="./SvnAuthBaton.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 13 14 </Contents> 14 15 <References> trunk/SubversionSharp/dev/src/Svn.cs
r19 r21 142 142 svn_auth_ssl_client_cert_pw_prompt_func_t prompt_func, 143 143 IntPtr prompt_baton, int retry_limit, IntPtr pool); 144 #endregion 145 146 #region AuthBaton 147 [DllImport("svn_client-1")] static extern 148 internal void svn_auth_open(out IntPtr auth_baton, IntPtr providers, IntPtr pool); 149 150 [DllImport("svn_client-1")] static extern 151 internal void svn_auth_set_parameter(IntPtr auth_baton, IntPtr name, IntPtr value); 152 153 [DllImport("svn_client-1")] static extern 154 internal IntPtr svn_auth_get_parameter(IntPtr auth_baton, IntPtr name); 144 155 #endregion 145 156 } trunk/SubversionSharp/dev/src/SvnAuthProvider.cs
r19 r21 17 17 public struct SvnAuthProviderObject 18 18 { 19 IntPtr mAuthProviderObject; 19 private IntPtr mAuthProviderObject; 20 internal SvnAuthProvider mAuthProvider; 20 21 21 22 #region Generic embedding functions of an IntPtr … … 23 24 { 24 25 mAuthProviderObject = ptr; 26 mAuthProvider = null; 27 } 28 29 private SvnAuthProviderObject(IntPtr ptr, SvnAuthProvider authProvider) 30 { 31 mAuthProviderObject = ptr; 32 mAuthProvider = authProvider; 25 33 } 26 34 … … 85 93 86 94 #region Wrapper client method 87 public static SvnAuthProviderObject Get SimplePromptProvider(95 public static SvnAuthProviderObject GetPromptProvider( 88 96 SimplePrompt promptFunc, 89 97 IntPtr promptBaton, int retryLimit, AprPool pool) 90 98 { 91 99 IntPtr authObj; 92 throw new NotImplementedException(); 93 //return(new SvnAuthProviderObject()); 100 SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 101 Svn.svn_client_get_simple_prompt_provider(out authObj, 102 (Svn.svn_auth_simple_prompt_func_t) auth.Wrapper, 103 promptBaton, retryLimit, pool); 104 return(new SvnAuthProviderObject(authObj,auth)); 94 105 } 95 106 96 public static SvnAuthProviderObject Get UsernamePromptProvider(107 public static SvnAuthProviderObject GetPromptProvider( 97 108 UsernamePrompt promptFunc, 98 109 IntPtr promptBaton, int retryLimit, AprPool pool) 99 110 { 100 111 IntPtr authObj; 101 throw new NotImplementedException(); 102 //return(new SvnAuthProviderObject()); 112 SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 113 Svn.svn_client_get_username_prompt_provider(out authObj, 114 (Svn.svn_auth_username_prompt_func_t) auth.Wrapper, 115 promptBaton, retryLimit, pool); 116 return(new SvnAuthProviderObject(authObj,auth)); 103 117 } 104 118 … … 138 152 } 139 153 140 public static SvnAuthProviderObject Get SslServerTrustPromptProvider(154 public static SvnAuthProviderObject GetPromptProvider( 141 155 SslServerTrustPrompt promptFunc, 142 156 IntPtr promptBaton, AprPool pool) 143 157 { 144 158 IntPtr authObj; 145 throw new NotImplementedException(); 146 //return(new SvnAuthProviderObject()); 147 } 148 149 public static SvnAuthProviderObject GetSslClientCertPromptProvider( 159 SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 160 Svn.svn_client_get_ssl_server_trust_prompt_provider(out authObj, 161 (Svn.svn_auth_ssl_server_trust_prompt_func_t) auth.Wrapper, 162 promptBaton, pool); 163 return(new SvnAuthProviderObject(authObj,auth)); 164 } 165 166 public static SvnAuthProviderObject GetPromptProvider( 150 167 SslClientCertPrompt promptFunc, 151 168 IntPtr promptBaton, int retryLimit, AprPool pool) 152 169 { 153 170 IntPtr authObj; 154 throw new NotImplementedException(); 155 //return(new SvnAuthProviderObject()); 156 } 157 158 public static SvnAuthProviderObject GetSslClientCertPwPromptProvider( 171 SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 172 Svn.svn_client_get_ssl_client_cert_prompt_provider(out authObj, 173 (Svn.svn_auth_ssl_client_cert_prompt_func_t) auth.Wrapper, 174 promptBaton, retryLimit, pool); 175 return(new SvnAuthProviderObject(authObj,auth)); 176 } 177 178 public static SvnAuthProviderObject GetPromptProvider( 159 179 SslClientCertPwPrompt promptFunc, 160 180 IntPtr promptBaton, int retryLimit, AprPool pool) 161 181 { 162 182 IntPtr authObj; 163 throw new NotImplementedException(); 164 //return(new SvnAuthProviderObject()); 183 SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 184 Svn.svn_client_get_ssl_client_cert_pw_prompt_provider(out authObj, 185 (Svn.svn_auth_ssl_client_cert_pw_prompt_func_t) auth.Wrapper, 186 promptBaton, retryLimit, pool); 187 return(new SvnAuthProviderObject(authObj,auth)); 165 188 } 166 189 #endregion 167 190 } 168 191 169 publicclass SvnAuthProvider192 internal class SvnAuthProvider 170 193 { 171 194 object mFunc; 195 object mWrapperFunc; 196 197 public SvnAuthProvider(SvnAuthProviderObject.SimplePrompt func) 198 { 199 mFunc = func; 200 mWrapperFunc = new Svn.svn_auth_simple_prompt_func_t(SvnAuthSimplePrompt); 201 } 202 203 public SvnAuthProvider(SvnAuthProviderObject.UsernamePrompt func) 204 { 205 mFunc = func; 206 mWrapperFunc = new Svn.svn_auth_username_prompt_func_t(SvnAuthUsernamePrompt); 207 } 208 209 public SvnAuthProvider(SvnAuthProviderObject.SslServerTrustPrompt func) 210 { 211 mFunc = func; 212 mWrapperFunc = new Svn.svn_auth_ssl_server_trust_prompt_func_t(SvnAuthSslServerTrustPrompt); 213 } 214 215 public SvnAuthProvider(SvnAuthProviderObject.SslClientCertPrompt func) 216 { 217 mFunc = func; 218 mWrapperFunc = new Svn.svn_auth_ssl_client_cert_prompt_func_t(SvnAuthSslClientCertPrompt); 219 } 220 221 public SvnAuthProvider(SvnAuthProviderObject.SslClientCertPwPrompt func) 222 { 223 mFunc = func; 224 mWrapperFunc = new Svn.svn_auth_ssl_client_cert_pw_prompt_func_t(SvnAuthSslClientCertPwPrompt); 225 } 226 227 public object Wrapper 228 { 229 get 230 { 231 return(mWrapperFunc); 232 } 233 } 172 234 173 235 private IntPtr SvnAuthSimplePrompt(out IntPtr cred, IntPtr baton, … … 227 289 } 228 290 229 [CLSCompliant(false)]291 //[CLSCompliant(false)] 230 292 private IntPtr SvnAuthSslServerTrustPrompt(out IntPtr cred, IntPtr baton, 231 293 IntPtr realm, uint failures, trunk/SubversionSharp/test/src/Main.cs
r7 r21 2 2 using System; 3 3 using System.Diagnostics; 4 using System.Collections; 4 5 using Softec.AprSharp; 5 6 using Softec.SubversionSharp; … … 15 16 SvnClientContext ctx = SvnClientContext.Create(pool); 16 17 ctx.Config = SvnConfig.GetConfig(pool); 17 AprHash ctxcfg = ctx.Config; 18 foreach(AprHashEntry cfg in ctxcfg) 19 { 20 Console.WriteLine("{0}\t{1:X}",cfg.KeyAsString,cfg.Value.ToInt32()); 21 } 18 19 ArrayList authObj = new ArrayList(); 20 authObj.Add(SvnAuthProviderObject.GetSimpleProvider(pool)); 21 authObj.Add(SvnAuthProviderObject.GetUsernameProvider(pool)); 22 authObj.Add(SvnAuthProviderObject.GetSslServerTrustFileProvider(pool)); 23 authObj.Add(SvnAuthProviderObject.GetSslClientCertFileProvider(pool)); 24 authObj.Add(SvnAuthProviderObject.GetSslClientCertPwFileProvider(pool)); 25 authObj.Add(SvnAuthProviderObject.GetPromptProvider( 26 new SvnAuthProviderObject.SimplePrompt(SimpleAuth), 27 IntPtr.Zero, 2, pool)); 28 authObj.Add(SvnAuthProviderObject.GetPromptProvider( 29 new SvnAuthProviderObject.UsernamePrompt(UsernameAuth), 30 IntPtr.Zero, 2, pool)); 31 32 22 33 pool.Destroy(); 23 34 } 35 36 public static SvnError SimpleAuth(out SvnAuthCredSimple cred, IntPtr baton, 37 AprString realm, AprString username, 38 bool maySave, AprPool pool) 39 { 40 Console.WriteLine("Simple Authentication"); 41 Console.WriteLine("---------------------"); 42 Console.WriteLine("Realm: {0}", realm); 43 Console.WriteLine(""); 44 45 bool valid = false; 46 string line; 47 48 while(!valid) 49 { 50 if (!username.IsNull) 51 Console.Write("Enter Username ({0}): ", username); 52 else 53 Console.Write("Enter Username: "); 54 55 line = Console.ReadLine(); 56 57 if (line.Trim().Length == 0 && !username.IsNull) 58 { 59 line = username.ToString(); 60 valid = true; 61 } 62 else if (line.Trim().Length > 0) 63 { 64 valid = true; 65 } 66 } 67 68 cred = SvnAuthCredSimple.Alloc(pool); 69 cred.Username = new AprString(pool, line); 70 Console.Write("Enter Password: "); 71 cred.Password = new AprString(pool, Console.ReadLine()); 72 cred.MaySave = maySave; 73 return(SvnError.NoError); 74 } 75 76 public static SvnError UsernameAuth(out SvnAuthCredUsername cred, IntPtr baton, 77 AprString realm, bool maySave, AprPool pool) 78 { 79 Console.WriteLine("Username Authentication:"); 80 Console.WriteLine("------------------------"); 81 Console.WriteLine("Realm: {0}", realm); 82 Console.WriteLine(""); 83 84 bool valid = false; 85 string line; 86 87 while(!valid) 88 { 89 Console.Write("Enter Username: "); 90 91 line = Console.ReadLine(); 92 93 if (line.Trim().Length > 0) 94 { 95 valid = true; 96 } 97 } 98 99 cred = SvnAuthCredUsername.Alloc(pool); 100 cred.Username = new AprString(pool, line); 101 cred.MaySave = maySave; 102 return(SvnError.NoError); 103 } 24 104 }