Code for Change Master Password
This commit is contained in:
		| @@ -487,6 +487,12 @@ namespace Novell.CASA | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		internal void closeSecretStore(IntPtr hSC) | ||||||
|  | 		{ | ||||||
|  | 			SSCS_EXT_T ext = new SSCS_EXT_T(); | ||||||
|  | 			miCASACloseSecretStoreCache(hSC, 0, ext); | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		internal Secret getSecret( | 		internal Secret getSecret( | ||||||
| 			IntPtr pHsc, | 			IntPtr pHsc, | ||||||
| 			string sKeyChainID, | 			string sKeyChainID, | ||||||
| @@ -1228,9 +1234,9 @@ namespace Novell.CASA | |||||||
| 					null, | 					null, | ||||||
| 					new SSCS_EXT_T()); | 					new SSCS_EXT_T()); | ||||||
| 			} | 			} | ||||||
| 			catch(Exception) | 			catch(Exception e) | ||||||
| 			{ | 			{ | ||||||
| 				//Console.WriteLine(e.ToString()); | 				Console.WriteLine(e.ToString()); | ||||||
| 			} | 			} | ||||||
| 			return rcode; | 			return rcode; | ||||||
| 		} | 		} | ||||||
| @@ -1241,6 +1247,8 @@ namespace Novell.CASA | |||||||
| 			if (null != id && "" !=id) | 			if (null != id && "" !=id) | ||||||
| 			{ | 			{ | ||||||
| 				SSCS_SECRET_ID_T secretID = new SSCS_SECRET_ID_T(); | 				SSCS_SECRET_ID_T secretID = new SSCS_SECRET_ID_T(); | ||||||
|  | 				try  | ||||||
|  | 				{ | ||||||
| 					if(ssFlags == 0) | 					if(ssFlags == 0) | ||||||
| 					{ | 					{ | ||||||
| 						secretID.len = id.Length; | 						secretID.len = id.Length; | ||||||
| @@ -1256,6 +1264,11 @@ namespace Novell.CASA | |||||||
| 							new SSCS_EXT_T()); | 							new SSCS_EXT_T()); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
|  | 				catch (Exception e) | ||||||
|  | 				{ | ||||||
|  | 					Console.WriteLine(e.ToString()); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
| 			 | 			 | ||||||
| 			if(rcode == 1) | 			if(rcode == 1) | ||||||
| 				return true; | 				return true; | ||||||
| @@ -1419,6 +1432,19 @@ namespace Novell.CASA | |||||||
| 			} | 			} | ||||||
| 			return sb.ToString(); | 			return sb.ToString(); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		internal static bool ResetMasterPassword(string sCurrentPassword, string sNewPassword) | ||||||
|  | 		{ | ||||||
|  | 			ResetMasterPassword rmp = new ResetMasterPassword(sCurrentPassword, sNewPassword); | ||||||
|  | 			ResetMasterPassword o = (ResetMasterPassword)MiCasa.Communication.MiCasaRequestReply.Send( | ||||||
|  | 				MiCasaRequestReply.VERB_RESET_MASTER_PASSWORD, | ||||||
|  | 				rmp); | ||||||
|  |  | ||||||
|  | 			if (o.rcode != 0) | ||||||
|  | 				return false; | ||||||
|  | 			else  | ||||||
|  | 				return true; | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -31,41 +31,22 @@ namespace Novell.CASA | |||||||
| 		public static SecretStore getInstance() | 		public static SecretStore getInstance() | ||||||
| 		{ | 		{ | ||||||
| 			SecretStore newSS = new SecretStore();		 | 			SecretStore newSS = new SecretStore();		 | ||||||
| 			 |  | ||||||
| 			// Test code for new APIS |  | ||||||
| 			/* |  | ||||||
| 			miCASA.SetCredential(0, "MyTestApp", null, 0, "MyTestAPPName", "MyTestAPPPassword");			 |  | ||||||
| 			BasicCredential bc = miCASA.GetCredential(0, "MyTestApp", "Network", 0); |  | ||||||
| 			if (bc != null) |  | ||||||
| 			{ |  | ||||||
| 				Console.WriteLine("------"); |  | ||||||
| 				Console.WriteLine("Username = " + bc.GetUsername()); |  | ||||||
| 				Console.WriteLine("Password = " + bc.GetPassword()); |  | ||||||
| 				Console.WriteLine("------"); |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 			miCASA.RemoveCredential(0, "MyTestApp", null); |  | ||||||
|  |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				miCASA.RemoveCredential(0, "MyTestApp", null); |  | ||||||
| 			} |  | ||||||
| 			catch (Exception e) |  | ||||||
| 			{ |  | ||||||
| 				Console.WriteLine("ClearCredential returned " + e.ToString()); |  | ||||||
| 			} |  | ||||||
| 			*/ |  | ||||||
| 			// end test code |  | ||||||
|  |  | ||||||
| 			return newSS; | 			return newSS; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		public void ReleaseInstance() | ||||||
|  | 		{ | ||||||
|  | 			if (m_hsc != IntPtr.Zero) | ||||||
|  | 				m_NativeCalls.closeSecretStore(m_hsc); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		/* | ||||||
| 		public static void ReleaseInstance() | 		public static void ReleaseInstance() | ||||||
| 		{ | 		{ | ||||||
| 			// TODO: | 			// TODO: | ||||||
|  |  | ||||||
| 		} | 		} | ||||||
|  | 		*/ | ||||||
|  |  | ||||||
|  |  | ||||||
| 		internal Secret getSecret(string sKeyChainID, uint ssFlags, string sSecretID, int iSecretType, string sEPPassword) | 		internal Secret getSecret(string sKeyChainID, uint ssFlags, string sSecretID, int iSecretType, string sEPPassword) | ||||||
|   | |||||||
| @@ -116,5 +116,18 @@ namespace Novell.CASA | |||||||
| 			return NativeCalls.IsSecretPersistent(ssFlags,secretID); | 			return NativeCalls.IsSecretPersistent(ssFlags,secretID); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		public static bool ChangeMasterPassword(string sCurrentPassword, string sNewPassword) | ||||||
|  | 		{ | ||||||
|  | 			if (sCurrentPassword == null || sNewPassword == null) | ||||||
|  | 			{ | ||||||
|  | 				throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM); | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			if (sNewPassword.Length < 8) | ||||||
|  | 				throw new miCasaException(miCasaException.NSSCS_E_MP_PWORD_NOT_ALLOWED); | ||||||
|  | 			 | ||||||
|  | 			return NativeCalls.ResetMasterPassword(sCurrentPassword, sNewPassword); | ||||||
|  |  | ||||||
|  | 		}                 | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user