CoreFramwork Developer Manual
CoreFramwork Developer Manual
CoreFramwork Developer Manual
Developer Manual
Pc
INFORMATION NEWTWORK SECURITY AGENCYI
Document metrics
Change history
Document reviewers
1.1. Steps to add Authentication service to the ASP.net Web application by adding AUMS
Libraries to the project folder. ......................................................................................................3
1.2. Steps to add Authentication service to the ASP.net Web application using Web Service....9
1.3. Steps to add Authorization service to the ASP.net Web application. ................................ 14
1.4. Steps to register Resources (public Name of Pages and Methods) in the AUMS Core
Framework ................................................................................................................................. 17
1.5. Deploying the web Service on IIS server .......................................................................... 23
1.6. Steps to Include Change Password ........................................................................................ 24
2. Registering Java Web Projects Information Using AUMS frameworks. ........................................ 25
6. Troubleshooting ....................................................................................................................... 47
1. Integrating AUMS Core Framework with ASP.net Web application
1.1. Steps to add Authentication service to the ASP.net Web application by adding AUMS Libraries
to the project folder.
Step 1.1 Remove all Pages and classes in Account folder excluding LoginPage.
Step 1.2 Remove <%@ Register Src="~/Account/OpenAuthProviders.ascx"
TagPrefix="uc" TagName="OpenAuthProviders" %> From Login.Aspx.
Step 1.3 Remove IdentityModel.cs from Model Folder.
Step 1.4 remove the following libraries from project reference.
Microsoft.AspNet.Identity;
Microsoft.AspNet.Identity.EntityFramework;
Microsoft.AspNet.Identity.Core;
Microsoft.Owin;
Microsoft.AspNet.Identity.Owin;
Microsoft.Owin.*;
System.Security.Claims;
Step 1.5 Remove all codes which are affected while deleting the above listed libraries.
Remove startup.cs from the project
Step 1.6 On Web Config remove
<add namespace="Microsoft.AspNet.Identity"/>
Step 1.7 On Web Config , Add/Modify
<authentication mode="Forms"/> inside System.web element.
Step 1.8 Remove <remove name="FormsAuthenticationModule"/> if any.
Step 2: Create a new folder name AUMSCoreFramwork inside the project directory.
Note: the .Net Framework version of your project should be greater or equal to the .net
version of these libraries. The default is .Net ver 6.1.0.
Step 4. Include the following libraries in the Asp.net project (only in GUI layer) Reference.
Note: Don’t use Asp.Net Login Control. Just use text boxes and buttons.
Step 8: Copy and Paste INSASecurityInterface.cs class in your project (GUI) folder.
Step 9: Include the following Code on Login_Click Event On Login Button.
Step 11: Add the following Code on page_Load event of the Master page
Step 12: Include Authorization on Pages and Method (Asp.net Events) Level (Optional)
Step 13: Add the following Code on logout Button Click event of the Master page
Step 14: Before testing check if all pages and events are registered in AUMS Administration
module using steps defined in section 1.4.
1.2. Steps to add Authentication service to the ASP.net Web application using Web
Service.
Note: the web service should be deployed (section 1.5 ) before doing this step.
Step 1.1 Remove all Pages and classes in Account folder excluding LoginPage.
Step 1.2 Remove <%@ Register Src="~/Account/OpenAuthProviders.ascx"
TagPrefix="uc" TagName="OpenAuthProviders" %> From Login.Aspx.
Step 1.3 Remove IdentityModel.cs from AppCode/Model Folder.
Step 1.4 the following libraries from project reference.
Microsoft.AspNet.Identity;
Microsoft.AspNet.Identity.EntityFramework;
Microsoft.AspNet.Identity.Core;
Microsoft.Owin;
Microsoft.AspNet.Identity.Owin;
Microsoft.Owin.*;
System.Security.Claims;
Step 1.5 Remove all codes which are affected while deleting the above listed libraries.
For example
Step 1.6 On Web Config remove
<add namespace="Microsoft.AspNet.Identity"/>
Step 1.7 On Web Config , Add/Modify
<authentication mode="Forms"/> inside System.web element.
Step 1.8 Remove <remove name="FormsAuthenticationModule"/>
Step 2: Add the web service as service reference
Step 3: Design Login Page
using WebApplication1.INSA.Web.SecurityWS;
protected void LogIn(object sender, EventArgs e)
{
try
{
using WebApplication1.INSA.Web.SecurityWS;
Step 8: Add the following Code on logout Button Click event of the Master page
Step 9: Include Authorization on Pages and Method (Asp.net Events) Level (Optional)
Step 10: Register the dill and all Security Attributes using AUMS Administration module on
Manage Module form. Just follow section 1.4.
Step 11: check if the login authentication for a webpage works well.
1.3. Steps to add Authorization service to the ASP.net Web application.
Step 2: Add Security Attribute for cs. class of each Page that you would like to add
authorization.
Note:
1. The public Name “ERP-PMS-About” in [Security ("ERP-PMS-About "……)] is
“ERP” is the name of the application
“PMS” is the name of the module.
“About” should be same as the Name of the Page. E.g. For the Code
below, the Name of the Security Attribute is “About” and the Name
of the page is “About.aspx”
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using INSA.Web.Administration;
namespace FramworkTest
{
[Security("ERP-PMS-About", "Any text that describes the class", " Any text that describes
the class ", false)]
public partial class About : Page
{
}
}
}
Step 3: Add Security Attribute for cs. class of each Methods or events that you would like to
add authorization.
Notes:
1. The public Name “ERP-PMS-RegisterUser” in [Security ("PMS RegisterUser", true
)] is
“ERP” is the name of the application
“PMS” is the name of the module.
“RegisterUser” describes what the method/event does.
2. Use the following code to check access on method or event level.
SA.CheckAccess(PublicName))
PublicName = “ERP-PMS-RegisterUser”
returns true if the user has privilege to access the resource defined by the
public Name
To use the libraries use the following code
using INSA.Web.Administration;
namespace WebApplication1
{
public partial class About : System.Web.UI.Page
{
[Security ("ERP-PMS-RegisterUser ", true )]
protected void btnRegister_Click(object sender, EventArgs e)
{
if (SA.CheckAccess(PublicName))
{
//Your Codes here
}
}
}
}
namespace WebApplication1
{
public partial class About : System.Web.UI.Page
{
[Security ("ERP-PMS-RegisterUser ", true )]
protected void btnRegister_Click(object sender, EventArgs e)
{
AdministrationClient ad = new AdministrationClient();
if (!ad.CheckAccess(SessionHandler.UserID, PublicName,
SessionHandler.DatabaseSet))
{
//Your Codes here
}
}
}
}
Step 4: (Optional) Include the following code on AssemInfo.cs file of your project which found
inside properties.
using INSA.Web.Common;
[assembly: AssemblyAuthor("YourName")]
Step 5: Make sure the project is compiled using .Net framework Version [x] ([x] is the .net
version of core framework) and the “[YourAsp.NetProjectName].dll” is found in bin folder.
Note: You Can Change it back to any .Net Framework version after the dill is
registered in AUMS admin Module.
Step 6: Register all Public Names (security attributes) in AUMS core framework follow Section
1.4.
1.4. Steps to register Resources (public Name of Pages and Methods) in the AUMS
Core Framework
For Java projects, please create Class Library in Visual studio and Add your Module to the
libraries. Follow steps defined in section 2.
Step 2: Register the module (e.g the name of the module used above on security Attribute
i.e ‘PMS’ in ERP-PMS-RegisterUser should be registered. If it is already registered,
select it from the list and click ‘Next’. But if it is not registered, click ‘add’ icon and
register it, select it and click next)
Note: Application: select the application where the module is found.
Modle1: a symbol that describe the Module. Should be two characters and should
be Unique e.g(use PM for project management, HR for Human Resource
management )
Module2: The name of the module. Don’t use short form.
Responsible: The user who is Responsible for the module. Select from
pickingList.
Active: If selected, the module will be active (accessible). If not, it is inactive (not
accessable).
Step 3: Register subsystems of the module (e.g HRMS may have different subsystem i.e
recurrent, promotion). If subsystems are already registered inside the module, select it
from the list and click ‘Next’ button. If they are not registered, click ‘add’ icon and
register it, select it and click next
Step 4: Register the library (dll) that contains all Security attributes. If it is already
registered, select it and click ‘Next’ button. If it is not registered, click ‘add’ icon and register
it, select it and click ‘Next)
Step 6: (Optional) if you want to assign a data rage for the Select modifier from the
selected programs, select Modifier. Otherwise click OK button.
1.5. Deploying the web Service on IIS server
Step 1: Copy Willy.cfg file to the following path on the server on which the Web service is
deployed.
Step 2: Copy the folder which contain web service files and paste it inside IIS folder
(C:\inetpub\wwwroot).
Step 3: Open IIS window and change the Folder to Application.
if (txtNewPassword.Text == txtConfirmNewPassword.Text)
{
AdministrationClient ad = new AdministrationClient();
FailureText.Text = ad.ChangePassword(SessionHandler.UserID,
txtOldPassword.Text, txtNewPassword.Text, SessionHandler.DatabaseSet);
}
Note 1: No need to include method implementation inside C# class. Only the method
Name and Name specified inside the [Security()]Attribute is needed.
Note 2: Only Pages (classes) and Methods, which needs security (should be given to
authorized user), should be included in C# class. Other classes and methods can be
omitted.
Steps to create .Net class library
Step 3.1 Right click on Reference (inside Class library found in Solution Explorer (on
the Right side) and then select “Add Reference”.
Step 3.2: Click “Browse” Button, then browse to where the libraries of AUMS
libraries found. Then Select all four libraries and click “add” then “OK” button.
The libraries will be added to the project as you can see it below.
Step 4: Create classes inside the class library. (For One java page, one C# class should be
created). Every classes found in the Module (e.g FMS) should be added by following this step.
Step 4.1: Right click On the Class library found in Solution Explorer (on the
Right side)
Step 5.2: Select Add>Class.
Step 5.3: Give Name to The class, which should be same as the Name of the Java
Page. Click ‘Add’ button.
Step 5.4: Add “using INSA.Web.Administration” above the Name space declaration.
Step 5.5: Change class to “Public” and Add “[Security (“Page_Name”,false)]” above the
class declaration.
Step 5.6: Add Methods (only which needs to be secured) inside the class declaration.
Note 1: No method implementation is needed. The method Name should be exactly same
as Java Methods.
Step 6.2: Right click on the project. Select “Properties” and change Target Framework to
version “4.6.1”. If you couldn’t find it inside the list. Please install DotNetFramwork
4.6.1 on your machine.
Step 6.3: select Build>Build Solution on the menu
Step 6.4: make sure NO Error found while building the solution.
Step 6.5 make sure that you find a dll file inside the project directory> bin>debug folder.
Note: The Dll file will be used later to register classes and method in AUMS
administration module. Follow steps defined in section 1.4 to Register it.
3. Integrate AUMS frameworks with Java Web Application Projects.
Step 1: Add the following xml files to the web package
Login. xhtml
Accessdenied.xhtml
ChangePassword.xhtml
SecuPageTemp.xml(this xhtml file will be called first line on the
login and accessdenied xhtml page so we have to correct the
location of SecuPageTemp on xml files )
<ui:composition template="./resources/temp/SecuPageTemp.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:jsp="http://java.sun.com/JSP/Page">
LogIn.java
accessdenied.java
ChangePassword.java
Header.java
SessionInvalidate.java
SecBundle.property
securityServer.property inside cfg package
copy and paste the following code to face-config.xml file
<application>
<resource-bundle>
<base-name>/secBundle</base-name>
<var>secBundle</var>
</resource-bundle>
</application>
Step 5: Add following code on xml file of the Header part the web project. Used to add the Logout
and change password links.
<ul id="securitySubMenu">
<li>
<h:commandLink id="cmdLnkChangePassword" action="#{headerBack.toChangePassword()}"
value="ChangePassword"/>
</li>
<li>
<h:commandLink action="#{headerBack.cmdLkLogOut_action}" id="cmdLkLogOut"
value="Logout"/>
</li>
<li>
<h:commandLink id="cmdLnkHelp" value="Help"/>
</li>
</ul>
Step 6: For Adding access privilege on method level which are registered on AUMS Core
framework just call the Following method.
import webService.EventEntry;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
Step 2: Change to the active solution platform. If you install 32 bit Oracle Client
and ODAC, the core framework libraries should be built in x86 platform. If you
install 64 bit Oracle Client and ODAC, the core framework libraries should be
built in x64 platform
2. Create/Modify the cfg file (Willy.cfg) using CFGINSAEditor.exe.
CFGINSAEditor.exe allows you to create connection string to only GBK schema.
3. Save the cfg file in bin/debug/ folder.
4.2.Fixing Exceptions and Errors
Exception: “Oldb.oracle is not registerd on you matchine”
This happen when
i. If you didn’t install Oracle Client and ODAC
If the Oracle Client and ODAC is x86, your application
should be built as X86 and If the Oracle Client and ODAC
is x64, your application should be built as X64.
namespace Telmax.Data.Structure.BLL.Db
{
public class SerializableDictionary<T1, T2>
{
[XmlRoot("Dictionary")]
public class SerializableDictionary<TKey, TValue>
: Dictionary<TKey, TValue>, IXmlSerializable
{
#region IXmlSerializable Members
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
if (wasEmpty)
return;
reader.ReadStartElement("Key");
TKey key = (TKey)keySerializer.Deserialize(reader);
reader.ReadEndElement();
reader.ReadStartElement("Value");
TValue value = (TValue)valueSerializer.Deserialize(reader);
reader.ReadEndElement();
this.Add(key, value);
reader.ReadEndElement();
reader.MoveToContent();
}
reader.ReadEndElement();
}
writer.WriteStartElement("Key");
keySerializer.Serialize(writer, key);
writer.WriteEndElement();
writer.WriteStartElement("Value");
TValue value = this[key];
valueSerializer.Serialize(writer, value);
writer.WriteEndElement();
writer.WriteEndElement();
}
}
#endregion
}
}
}
2. On Login click:
Exception: “Failed to authorize the user for reasons other than invalid password.
Notify the system administrator.
Error: Time difference between system and database is too large! Please contact
your administrator. Unable to work!
Solution: change the date and time of the database server. It should equals to the
date and time of the MDA server.
4. After Logged in to the bulletin (by changing the app to bulletin mode using (b=t)
on command line), on bulletin Administration form, inside GBK configuration
tab, after click on GBK database configuration and click on create new Cfg file
for GBK database, the following error occurred.
Error: Value cannot be null. Parameter name: item in
\Telmax.Biling.Biuletyn\GUI\FrmConnectionParams.cs
Solution:
4. New Methods created for accessing authentication from Web Service in SA class.
public static bool SignInForService(string userName, string password, bool
createPersistentCookie)
{
// FormsAuthentication.SignOut();
if (BeforeCreateSID != null)
BeforeCreateSID(null, EventArgs.Empty);
Sid = new SID(userName, password, "mda", null);
if (Sid != null)
{
string komunikat = string.Empty;
if
(GBK.GBKManager.MustChangePassword(GBK.GBKManager.GetUserId(userNa
me), ref komunikat))
return false;
LogUserLogin();
}
//if (!string.IsNullOrEmpty(Sid.Login))
// FormsAuthentication.SetAuthCookie(userName,
createPersistentCookie);
return (Sid.Login != null);
}
///////////////////////////////////////////////
public static void LogOffForService(int SessionID)
{
// FormsAuthentication.SignOut();
GBK.GBKManager.CreateConnections("mda", null);
try
{
DalcUsersLogons.UpdateLogoutDate(SessionID,
TxCalendar.GetCurrentDateTime());
}
catch (Exception ex)
{
TxExceptionsManager.LogException(ex);
}
finally
{
if (UserLoggedOut != null)
UserLoggedOut(null, EventArgs.Empty);
}
}/////////////////////////////////////////////////////////////////////////////
public static bool CheckAccessForService
(string UserID, string rightName)
{
return CheckAccess(UserID, new SecurityAttribute(rightName));
}
public static bool IsSecured (string rightName)
{
try
{ return DalcRights.GetNRights(rightName);
}
catch (Exception ex)
{
TxExceptionsManager.LogException(ex);
}
return false;
}
public static bool IsSecuredService(string rightName)
{
GBK.GBKManager.CreateConnections("mda", null);
try
{
return DalcRights.GetNRights(rightName);
}
catch (Exception ex)
{
TxExceptionsManager.LogException(ex);
}
return false;
}
5. We created the following libraries based on Asseco libraries and put it in bin
folder of the core framework.
if (objs.Length > 0)
{
SecurityAttribute sa = (SecurityAttribute)objs[0];
if (dtDotNetPrograms.Select("program = '" +
sa.PublicName + "'").Length == 0)
{
if
(DalcStructure.IsProgramRegistered(sa.PublicName))
dtDotNetPrograms.Rows.Add(new object[] {
sa.PublicName, sa.Description, (bool)sa.IsMenuItem, sa.MenuLabel, idDll,
"D", author, sa.IconId, false, true, true });
else
dtDotNetPrograms.Rows.Add(new object[] {
sa.PublicName, sa.Description, (bool)sa.IsMenuItem, sa.MenuLabel, idDll,
"D", author, sa.IconId, false, false, false });
}
}
else
{
objs =
type.GetCustomAttributes(typeof(INSA.Web.Administration.SecurityAttribute
), false);
if (objs.Length > 0)
{
INSA.Web.Administration.SecurityAttribute sa =
((INSA.Web.Administration.SecurityAttribute)objs[0]);
if (dtDotNetPrograms.Select("program = '" +
sa.PublicName + "'").Length == 0)
{
if
(DalcStructure.IsProgramRegistered(sa.PublicName))
dtDotNetPrograms.Rows.Add(new object[] {
sa.PublicName, sa.Description, (bool)sa.IsMenuItem, sa.MenuLabel, idDll,
"D", author, 0, false, true, true });
else
dtDotNetPrograms.Rows.Add(new object[] {
sa.PublicName, sa.Description, (bool)sa.IsMenuItem, sa.MenuLabel, idDll,
"D", author, 0, false, false, false });
}
}
}
//foreach (MethodInfo mi in type.GetMethods(
// BindingFlags.DeclaredOnly |
// BindingFlags.Public |
// BindingFlags.Instance | BindingFlags.Static))
foreach (MethodInfo mi in type.GetMethods(
BindingFlags.DeclaredOnly | BindingFlags.NonPublic |
BindingFlags.Public |
BindingFlags.Instance | BindingFlags.Static))
{
object[] attrs =
mi.GetCustomAttributes(typeof(SecurityAttribute), true);
if (attrs.Length > 0)
{
SecurityAttribute sa =
(SecurityAttribute)attrs[0];
ListViewItem lvItem = new ListViewItem(new
string[]{
sa.MenuLabel, sa.PublicName});
if (dtDotNetPrograms.Select("program = '" +
sa.PublicName + "'").Length == 0)
{
if
(DalcStructure.IsProgramRegistered(sa.PublicName))
dtDotNetPrograms.Rows.Add(new object[] {
sa.PublicName, sa.Description, (bool)sa.IsMenuItem, sa.MenuLabel, idDll,
"D", author, sa.IconId, false, true, true });
else
dtDotNetPrograms.Rows.Add(new object[] {
sa.PublicName, sa.Description, (bool)sa.IsMenuItem, sa.MenuLabel, idDll,
"D", author, sa.IconId, false, false, false });
}
}
else
{
attrs =
mi.GetCustomAttributes(typeof(INSA.Web.Administration.SecurityAttribute),
false);
if (attrs.Length > 0)
{
INSA.Web.Administration.SecurityAttribute sa
= ((INSA.Web.Administration.SecurityAttribute)attrs[0]);
if (dtDotNetPrograms.Select("program = '" +
sa.PublicName + "'").Length == 0)
{
if
(DalcStructure.IsProgramRegistered(sa.PublicName))
dtDotNetPrograms.Rows.Add(new
object[] { sa.PublicName, sa.Description, (bool)sa.IsMenuItem,
sa.MenuLabel, idDll, "D", author, 0, false, true, true });
else
dtDotNetPrograms.Rows.Add(new
object[] { sa.PublicName, sa.Description, (bool)sa.IsMenuItem,
sa.MenuLabel, idDll, "D", author, 0, false, false, false });
}
}
}
}
private string GetAuthorFromAssembly(Assembly a)method which found
in Telmax.Billing.Administracja.FrmDotNetPrograms is modified to the
following code
Step2: Make sure all projects build into same output path.
6.2. Integrating core framework with asp.net application using web service.
1. Error: Could not find default endpoint element that references contract
'sr.IAdministration' in the ServiceModel client configuration section. This might
be because no configuration file was found for your application, or because no
endpoint element matching this contract could be found in the client element.
Solution:
Replace Application startup to
pAssembly.GetEntryAssembly().)Location.ToLower(CultureInfo.InvariantCultur
e) (AppHelper)
6.3. Deploying Web Service
1. Error: “Could not load file or assembly 'MDA.Analyses' or one of its
dependencies. An attempt was made to load a program with an incorrect format.”
Solution
If you try to run 32-bit app on IIS you will get the error. So, from IIS, Right click
on the application pool and click Advanced Setting and change”Enable 32-bit
Application” to “True”.