Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4602,35 +4602,35 @@ public static GxStringCollection DefaultApplicationPoolIdentity()
GxStringCollection usernames = new GxStringCollection();
try
{
DirectoryEntry Entry = GetAppPoolEntry();
if (Entry != null)
{
PropertyCollection Properties = Entry.Properties;
string AppPoolIdentityType = Properties["AppPoolIdentityType"][0].ToString().Trim();
switch (AppPoolIdentityType)
using (DirectoryEntry Entry = GetAppPoolEntry()) {
if (Entry != null)
{
case APPPOOL_IDENTITY_TYPE_APPPOOL:
PropertyCollection Properties = Entry.Properties;
string AppPoolIdentityType = Properties["AppPoolIdentityType"][0].ToString().Trim();
switch (AppPoolIdentityType)
{
case APPPOOL_IDENTITY_TYPE_APPPOOL:
#if NETCORE
usernames.Add(IDENTITY_NETCORE_APPPOOL);
usernames.Add(IDENTITY_NETCORE_APPPOOL);
#else
usernames.Add(IDENTITY_CLASSIC_APPPOOL);
usernames.Add(IDENTITY_INTEGRATED_APPPOOL_FW35);
usernames.Add(IDENTITY_INTEGRATED_APPPOOL_FW40);
#endif
break;
case APPPOOL_IDENTITY_TYPE_NETWORKSERVICE:
case APPPOOL_IDENTITY_TYPE_LOCALSYSTEM:
usernames.Add(IDENTITY_NETWORK_SERVICE);
break;
case APPPOOL_IDENTITY_TYPE_LOCALSERVICE:
usernames.Add(IDENTITY_LOCAL_SERVICE);
break;
case APPPOOL_IDENTITY_TYPE_SPECIFICUSER:
usernames.Add(Properties["WAMUserName"][0].ToString());
break;
break;
case APPPOOL_IDENTITY_TYPE_NETWORKSERVICE:
case APPPOOL_IDENTITY_TYPE_LOCALSYSTEM:
usernames.Add(IDENTITY_NETWORK_SERVICE);
break;
case APPPOOL_IDENTITY_TYPE_LOCALSERVICE:
usernames.Add(IDENTITY_LOCAL_SERVICE);
break;
case APPPOOL_IDENTITY_TYPE_SPECIFICUSER:
usernames.Add(Properties["WAMUserName"][0].ToString());
break;
}
}
}

}
catch (Exception ex)
{
Expand Down
16 changes: 9 additions & 7 deletions dotnet/src/dotnetframework/GxClasses/Domain/GXLDAP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,16 @@ public GxSimpleCollection<string> GetAttribute(string name, string context, GXPr
context1 = "/" + context;
AuthenticationTypes at = getAuthentication();
_entry = new DirectoryEntry("LDAP://" + getPath() + context1, _user, _password, at);
DirectorySearcher ds = new DirectorySearcher(_entry, filter, new string[] { name });
foreach (SearchResult result in ds.FindAll())
using (DirectorySearcher ds = new DirectorySearcher(_entry, filter, new string[] { name }))
{
PropertyValueCollection values = (PropertyValueCollection)(result.GetDirectoryEntry().Properties[name]);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < values.Count; i++)
sb.Append(values[i].ToString() + " ");
sc.Add(sb.ToString());
foreach (SearchResult result in ds.FindAll())
{
PropertyValueCollection values = (PropertyValueCollection)(result.GetDirectoryEntry().Properties[name]);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < values.Count; i++)
sb.Append(values[i].ToString() + " ");
sc.Add(sb.ToString());
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions dotnet/src/dotnetframework/GxClasses/Printer/GxPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1526,8 +1526,10 @@ void DrawBitmap(string bitmap, Point p1, Point p2)
"\\pichgoal"+(height * LOGICAL2TWIP).ToString()+
"\n";
streamToWrite.Write( sBuffer);
Bitmap bm = new Bitmap(bitmap);
bm.Save( streamToWrite.BaseStream, ImageFormat.Emf);
using (Bitmap bm = new Bitmap(bitmap))
{
bm.Save(streamToWrite.BaseStream, ImageFormat.Emf);
}
streamToWrite.Write( "}}\n");
}
void DrawText(string text, Point p1, Point p2, Font fnt, int align, Color foreColor, Color backColor)
Expand Down
48 changes: 23 additions & 25 deletions dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ public ArrayList ParseStmtFile(ReorgScriptType time)

public bool BeginResume()
{
StreamReader input = null;

try
{
if (createDataBase || ignoreResume)
Expand All @@ -235,27 +233,29 @@ public bool BeginResume()
}
else if (File.Exists(RESUME_REOR_FILE))
{
input = File.OpenText(RESUME_REOR_FILE);
String statement = input.ReadLine();
if (!string.IsNullOrEmpty(statement))
{
string timeStamp;
Config.GetValueOf("VER_STAMP", out timeStamp);
if (statement!=timeStamp)
{
AddMsg(GXResourceManager.GetMessage("GXM_lastreorg_failed1"), null);
AddMsg(GXResourceManager.GetMessage("GXM_lastreorg_failed2"), null);
AddMsg(GXResourceManager.GetMessage("GXM_lastreorg_failed3"), null);
GXReorganization.Error = true;
return false;
}
}
while (statement != null)
{
executedStatements[statement] = null;
statement = input.ReadLine();
}
executingResume = true;
using (StreamReader input = File.OpenText(RESUME_REOR_FILE))
{
String statement = input.ReadLine();
if (!string.IsNullOrEmpty(statement))
{
string timeStamp;
Config.GetValueOf("VER_STAMP", out timeStamp);
if (statement != timeStamp)
{
AddMsg(GXResourceManager.GetMessage("GXM_lastreorg_failed1"), null);
AddMsg(GXResourceManager.GetMessage("GXM_lastreorg_failed2"), null);
AddMsg(GXResourceManager.GetMessage("GXM_lastreorg_failed3"), null);
GXReorganization.Error = true;
return false;
}
}
while (statement != null)
{
executedStatements[statement] = null;
statement = input.ReadLine();
}
executingResume = true;
}
}
return true;
}
Expand All @@ -268,8 +268,6 @@ public bool BeginResume()
finally
{
#if !NETCORE
if (input != null)
input.Close();
SerializeExecutedStatements();
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,51 +309,55 @@ private bool loadPublicKeyFromFile(string path, string alias, string password)
private bool loadPublicKeyFromPEMFile(string path)
{
bool flag = false;
StreamReader streamReader = new StreamReader(path);
PemReader pemReader = new PemReader(streamReader);
Object obj = pemReader.ReadObject();
if (obj.GetType() == typeof(AsymmetricKeyParameter))
{
this.error.setError("CE007", "The file contains a private key");
flag = false;
}

if (obj.GetType() == typeof(ECPublicKeyParameters))
{
/*ECPublicKeyParameters ecParms = (ECPublicKeyParameters)obj;
this.subjectPublicKeyInfo = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(ecParms);
this.publicKeyAlgorithm = ecParms.AlgorithmName;
this.hasPublicKey = true;
return true;*/
this.error.setError("CE008", "Invalid X509 Certificate format");
return false;
}

if (obj.GetType() == typeof(System.Security.Cryptography.X509Certificates.X509Certificate))
{
Org.BouncyCastle.X509.X509Certificate cert = (Org.BouncyCastle.X509.X509Certificate)obj;
castCertificate(cert);
closeReaders(streamReader, pemReader);
return true;

}
if (obj.GetType() == typeof(Org.BouncyCastle.X509.X509Certificate))
{
Org.BouncyCastle.X509.X509Certificate cert = (Org.BouncyCastle.X509.X509Certificate)obj;
castCertificate(cert);
closeReaders(streamReader, pemReader);
return true;
}
if (obj.GetType() == typeof(X509CertificateStructure))
{
Org.BouncyCastle.X509.X509Certificate cert = (Org.BouncyCastle.X509.X509Certificate)obj;
castCertificate(cert);
closeReaders(streamReader, pemReader);
return true;
}

closeReaders(streamReader, pemReader);
return flag;
using (StreamReader streamReader = new StreamReader(path))
{
PemReader pemReader = new PemReader(streamReader);
Object obj = pemReader.ReadObject();
try
{
if (obj.GetType() == typeof(AsymmetricKeyParameter))
{
this.error.setError("CE007", "The file contains a private key");
flag = false;
}

if (obj.GetType() == typeof(ECPublicKeyParameters))
{
/*ECPublicKeyParameters ecParms = (ECPublicKeyParameters)obj;
this.subjectPublicKeyInfo = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(ecParms);
this.publicKeyAlgorithm = ecParms.AlgorithmName;
this.hasPublicKey = true;
return true;*/
this.error.setError("CE008", "Invalid X509 Certificate format");
return false;
}

if (obj.GetType() == typeof(System.Security.Cryptography.X509Certificates.X509Certificate))
{
Org.BouncyCastle.X509.X509Certificate cert = (Org.BouncyCastle.X509.X509Certificate)obj;
castCertificate(cert);
return true;

}
if (obj.GetType() == typeof(Org.BouncyCastle.X509.X509Certificate))
{
Org.BouncyCastle.X509.X509Certificate cert = (Org.BouncyCastle.X509.X509Certificate)obj;
castCertificate(cert);
return true;
}
if (obj.GetType() == typeof(X509CertificateStructure))
{
Org.BouncyCastle.X509.X509Certificate cert = (Org.BouncyCastle.X509.X509Certificate)obj;
castCertificate(cert);
return true;
}
}finally
{
pemReader.Reader.Close();
}
}
return flag;


}

Expand Down Expand Up @@ -509,26 +513,6 @@ private bool loadPublicKeyFromPKCS12File(string path, string password)
return flag;
}

/// <summary>
/// Excecute close methods of PemReader and StreamReader data types
/// </summary>
/// <param name="streamReader">StreamReader type</param>
/// <param name="pemReader">PemReader type</param>
private void closeReaders(StreamReader streamReader, PemReader pemReader)
{
try
{
streamReader.Close();
pemReader.Reader.Close();
}
#pragma warning disable CA1031 // Do not catch general exception types
catch
#pragma warning restore CA1031 // Do not catch general exception types
{
this.error.setError("CE015", "Error closing StreamReader/ PemReader for certificates");
}
}

private void castCertificate(Org.BouncyCastle.X509.X509Certificate cert)
{
this.subjectPublicKeyInfo = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(cert.GetPublicKey());
Expand Down
Loading