You are on page 1of 48

9/28/2017 AUMS Core Framework

Developer Manual

Pc
INFORMATION NEWTWORK SECURITY AGENCYI
Document metrics

Project: AUMS Core Framework Upgrading


Product ID:
Document owner: INSA
Document version: 1.0

Approval status: ☒ draft ☐ for review ☐ approved


Storage location:

Change history

Version Date Author Change description

0.1 4/5/2017 Seble Girma Document creation (Section 1 and 4)


09/15/2017 Zubeir Ahemd Adding description on AUMS Core Framework
on java perspective

Document reviewers

Version Date Reviewer Review comments


Table of Contents

1. Integrating AUMS Core Framework with ASP.net Web application...............................................3

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

3. Integrate AUMS frameworks with Java Web Application Projects. ............................................. 30

4. Works done on AUMS Core framework ..................................................................................... 36

5. Preparing Deployment Package for Core Framework ................................................................. 46

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: Remove Default Authentication Services from the project.

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.

Step 3. Copy and paste the following dll in the folder.

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.

Step 5: Copy Willy.cfg file to the path

 For debugging on Visual studio “C:\Program Files (x86)\IIS Express” and


“C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0”.
 For deploying on IIS “C:\Windows\System32\inetsrv” and
“C:\WINDOWS\SysWOW64\inetsrv”
Note: Willy.cfg is a cfg file which contains a connection string to the GBK schema.

Step 6: Add the following code in global.asax.cs file.

void Application_Start(object sender, EventArgs e)


{
// Code that runs on application startup
Lic.SkipCheckLic = true;
SA.InitializeDataBase("Willy.cfg");
// Include your custome codes here
}
Step 7: Design the Login Page.

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.

protected void LogIn(object sender, EventArgs e)


{
try
{

if (SA.SignIn(UserName.Text, Password.Text, SessionHandler.DatabaseSet,


RememberMe.Checked))
{
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.Redirect("~/Dashboard.aspx",false);
}
else
{
FailureText.Text = "Invalid Username or Password.";
}
}
catch (Exception ex)
{
FailureText.Text = "An Error has occurred connecting with authentication services.";
} }
Step 10: Include Login View

Add the following controls to the Master page

<asp:LoginView runat="server" ViewStateMode="Disabled">


<AnonymousTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server href="~/Account/Login">Login</a></li>
</ul>
</AnonymousTemplate>
<LoggedInTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Manage" title="Manage your
account">Hello,
<asp:LoginName ID="HeadLoginName" runat="server" /> !</a></li>
<li>
<asp:LoginStatus runat="server" LogoutAction="Redirect"
LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
</li>
</ul>
</LoggedInTemplate>
</asp:LoginView>

Step 11: Add the following Code on page_Load event of the Master page

 All Page should inherited the same master page.


 There should be an error page that shows “Access Denied” Message.
 Params: "ERP"- the name of the application.
o "PMS"- the name of the module.
o "~/Account/Login.aspx"- the path w/c the login page found.
o "~/AccessDeniedError.aspx" the path w/c the page found
protected void Page_Load(object sender, EventArgs e)
{
INSASecurityInterface sec = new
INSASecurityInterface("ERP","PMS","~/Account/Login.aspx", "~/AccessDeniedError.aspx");
}

Step 12: Include Authorization on Pages and Method (Asp.net Events) Level (Optional)

Described in section 1.3.

Step 13: Add the following Code on logout Button Click event of the Master page

protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e)


{
SA.SignOut();
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.Redirect("~/Account/Login.aspx");
}

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: Remove Default Authentication Services from the project.

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

Step 4: Include the following Code on Login_Click Event On Login Button


Note: AdministrationClient and UserSession are classes found in web service.

using WebApplication1.INSA.Web.SecurityWS;
protected void LogIn(object sender, EventArgs e)
{
try
{

AdministrationClient ad = new AdministrationClient(); // the name of webservice


UserSession session = ad.Login(UserName.Text, Password.Text, false);
if (session != null)
{
// authenticated
SessionHandler.SessionID = session.SessionId;
SessionHandler.UserID = session.Login;
FormsAuthentication.SignOut();
FormsAuthentication.SetAuthCookie(UserName.Text, false);
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.Redirect("~/Dashboard.aspx",false);
}
else
{
FailureText.Text = "Invalid Username or Password.";
ErrorMessage.Visible = true;
}
catch (Exception ex)
{
FailureText.Text = "An Error has occurred connecting with authentication services.";
ErrorMessage.Visible = true;
}
}

Step 5: Include Login View

Add the following controls to the Master page

<asp:LoginView runat="server" ViewStateMode="Disabled">


<AnonymousTemplate>
<ul class="nav navbar-nav navbar-right">

<li><a runat="server" href="~/Account/Login">Log in</a></li>


</ul>
</AnonymousTemplate>
<LoggedInTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Manage" title="Manage your
account">Hello, <asp:LoginName ID="HeadLoginName" runat="server" /> !</a></li>
<li>
<asp:LoginStatus runat="server" LogoutAction="Redirect"
LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
</li>
</ul>
</LoggedInTemplate>
</asp:LoginView>

Step 6: Include INSASecurityInterfaceWS.cs class in your project.


Step 7: Add the following Code on page_Load event of the Master page

Note: All Page should inherited the same master page.

There should be an error page that shows “Access Denied” Message.

using WebApplication1.INSA.Web.SecurityWS;

protected void Page_Load(object sender, EventArgs e)


{
INSASecurityInterface sec = new
INSASecurityInterface("ERP","PMS","~/Account/Login.aspx", "~/AccessDenid.aspx");
}

Step 8: Add the following Code on logout Button Click event of the Master page

protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e)


{
AdministrationClient ad = new AdministrationClient();
if (SessionHandler.SessionID == null || ad.LogOff((int)SessionHandler.SessionID,
SessionHandler.DatabaseSet))
{
FormsAuthentication.SignOut();
Session.Abandon();
Response.Redirect("~/Account/Login.aspx");
} //
}

Step 9: Include Authorization on Pages and Method (Asp.net Events) Level (Optional)

Described in section 1.3.

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 1. Include the following libraries in your project reference.

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
{

protected void Page_Load(object sender, EventArgs e)


{

}
}
}

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
}

}
}
}

To use the web service 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)
{
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.

To register the dll files in the AUMS administration module.


Step 1: Select Manage ‘Application Program Structure’ from the menu.

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)

Note: If you add security attribute


Step 5: All Programs found in the library (public names which are decorated by Security
Attribute) will be populated, Select the Programs and click ‘Next’
Step 5: All Programs found in the library (public names which are decorated by Security
Attribute) will be populated, Select the Programs 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.

 For debugging on Visual studio “C:\Program Files (x86)\IIS Express” and


“C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0” AND
C:\Program Files (x86)\IIS Express” and “C:\Program Files (x86)\Common
Files\Microsoft Shared\DevServer\11.0”.
 For deploying on IIS “C:\Windows\System32\inetsrv” and
“C:\WINDOWS\SysWOW64\inetsrv”
Note: Willy.cfg is a cfg file which contains a connection string to the GBK database.

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.

Step 4: Browse on the browser to check the service is working.

1.6. Steps to Include Change Password


Step 1: Design change password form

Step2: Include the following code on Change button click.

For using web service

if (txtNewPassword.Text == txtConfirmNewPassword.Text)
{
AdministrationClient ad = new AdministrationClient();
FailureText.Text = ad.ChangePassword(SessionHandler.UserID,
txtOldPassword.Text, txtNewPassword.Text, SessionHandler.DatabaseSet);
}

For using Library


if (txtNewPassword.Text == txtConfirmNewPassword.Text)
{
AdministrationClient ad = new AdministrationClient();
FailureText.Text = ad.ChangePassword(SessionHandler.UserID,
txtOldPassword.Text, txtNewPassword.Text, SessionHandler.DatabaseSet);
}

2. Registering Java Pages and Methods Name as Resource in AUMS


Administration Module.
 We have to create unique java class name and method name for each pages based on
transaction going to be done.
 Create a .Net class library on VisualStudio and create fake c#.Net class file which has
the same class and method names for each java pages need. Follow the steps below to
create .Net class library.

Java Class Equivalent C# class


page name = documentPage.xhtml Class Name: documentPage
method name = loadSelectedElecVersionDoc and Method name: loadSelectedElecVersionDoc and
populateDocumentVersion populateDocumentVersion

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 1: Open Visual studio 2010 or above.

Step 2: Create New Class Library.

Step 2.1 On the Menu, select File>New>Project,


Step 2.2 select class Library from the list and Give Name of the Class Library
(The Name of the Library should be your Module Name. e.g HRMS, FMS,
PMS…) and click OK.

Step 3: Add Reference:

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.

Note 2: Methods and classes should be “public”.


Step 5.7: Add “[Security (“Method_Name”,true)]” above each method declaration.
Step 6: Build the Class Library.

Step 6.1: Right click on the project and select Property

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">

Step 2: Add the following java file to the source package

 LogIn.java
 accessdenied.java
 ChangePassword.java
 Header.java
 SessionInvalidate.java

Step 3: Add property file to the source package

 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 4: Add jar file as a library to the project


 First copy and paste the jar file to the project on the explorer to lib
folder.
 Add the jar file to the project on Library package in a part of war
project.

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.

public StreamedContent loadElectronicFile(Version electronicVersion) throws


Exception {
// We can add Log file here too. optional
AAA securityService = new AAA();
IAdministration security =
securityService.getMetadataExchangeHttpBindingIAdministration();
if(security.checkAccess(userName, "loadElectronicFile", dataset)) {
-----add the code going to be executed
}
else{
// Log file
}
Step 7: For adding Log Information to database just add the following code.

import webService.EventEntry;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;

EventEntry eventEntry = new EventEntry();


eventEntry.setSessionId(sessionBean.getSessionID());
eventEntry.setUserId(sessionBean.getUserId());
QName qualifiedName = new QName("", "project");
JAXBElement<String> test = new JAXBElement<String>
(qualifiedName,String.class,null,sessionBean.getUserName());
eventEntry.setUserLogin(test);

Step 8: Add the following code on SessionBean Scope class

private static String _userName = "UserID";


private static int _userId = -1;
private static int _sessionID = 0;
public static int getUserId() {
return _userId;
}
public static void setUserID(int _userId) {
SessionBean._userId = _userId;
}
public static String getUserName() {
return _userName;
}
public static void setUserName(String _userName) {
SessionBean._userName = _userName;
}
public static int getSessionID() {
return _sessionID;
}
public static void setSessionID(int _sessionID) {
SessionBean._sessionID = _sessionID;
}
4. Works done on AUMS Core framework
4.1.Configuring the core framework for first time use.
1. Make sure the correct oracle client and ODAC versions are installed in your
computer.
To do this,
Step 1: Right click on the solution folder and Select Configuration Manager.

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.

1. Compile time exception:


Exception: “The type or namespace name 'SerializableDictionary' could not be found
(are you missing a using directive or an assembly reference?) DbTranslatedObjects.cs
Telmax.Data.Structure

Solution: The following class added in


“Database>Telmax.Data.Structure>BLL>Translate
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

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;
}

public void ReadXml(System.Xml.XmlReader reader)


{
XmlSerializer keySerializer = new XmlSerializer(typeof(TKey));
XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));

bool wasEmpty = reader.IsEmptyElement;


reader.Read();

if (wasEmpty)
return;

while (reader.NodeType != System.Xml.XmlNodeType.EndElement)


{
reader.ReadStartElement("Item");

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();
}

public void WriteXml(System.Xml.XmlWriter writer)


{
XmlSerializer keySerializer = new XmlSerializer(typeof(TKey));
XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));

foreach (TKey key in this.Keys)


{
writer.WriteStartElement("Item");

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.

Failed to initiate connection provider=oraoledb.oracle;data


source=172.21.35.218/rdbms;

ORA-12514: TNS:listener does not currently know of service requested in connect


descriptor”.

Solution: Modify the connection string of CFG and MDA schema in


FR_DB_CONNECTION table which found in GBK schema. In the above case,
add .gov on SID. “oraoledb.oracle;data source=172.21.35.218/rdbms.gov;”

3. After Successfully logged in:

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.3. Added new functionalities.


1. New Libraries are created based on the telmax libraries.
2. We add if (BeforeCreateSID != null)
BeforeCreateSID(null, EventArgs.Empty);
On Signin() method on SA class in
Tellmax.billing.administration>Administration

3. “mda” hardcoded in sign in method of SA class .


a. “mda” is the name of the dbset. You can use any name of dbset.

public static bool SignIn(string userName, string password, bool


createPersistentCookie)
{
FormsAuthentication.SignOut();
if (BeforeCreateSID != null)
BeforeCreateSID(null, EventArgs.Empty);
Sid = new SID(userName, password, "mda", null);

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.

6. We Include Insa.Web.Adminsitration in Telmax billing.Administrjia as reference


and;
 private void Fill(string biblioteka) method which found in
Telmax.Billing.Administracja.FrmDotNetPrograms is modified to the
following code
private void Fill(string lib)
{
dtDotNetPrograms.Clear();
Assembly a = Assembly.LoadFile(lib);
string author = GetAuthorFromAssembly(a);
Type[] types = a.GetTypes();
foreach (Type type in types)
{
object[] objs =
type.GetCustomAttributes(typeof(SecurityAttribute),false);

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

private string GetAuthorFromAssembly(Assembly a)


{
object[] asmAttrs =
a.GetCustomAttributes(typeof(AssemblyAuthorAttribute), true);
if (asmAttrs.Length == 0)
{
return string.Empty;
// throw new Exception(String.Format(CultureInfo.CurrentCulture,
Strings.ExcLibraryIsNotSignedFmtNoAssemblyAuthorAttribute, a.FullName));
}

string author = ((AssemblyAuthorAttribute)asmAttrs[0]).Login;


//read author

if (author.Length > ConstClass.AuthorLength)


{
throw new Exception(String.Format(CultureInfo.CurrentCulture,
Properties.Strings.ExcTooLongLibraryAuthorFieldFieldValueMaximalValue,
author, ConstClass.AuthorLength));
}
return author;
}
5. Preparing Deployment Package for Core Framework
Step1: Make sure all projects have same .Net framework version.

Step2: Make sure all projects build into same output path.

Step3: Make sure all projects build either X86 or X64Platform.


Step4: Create a folder and copy all files found in MDAProject>Bin>Debug>X86 0r
>X64to your folder.
Step5: Copy all files found in MDAProject>Thirdparty to newly created folder.
Step6: Copy Willy.cfg and Resource folder containing menu file to the newly created
folder.
Step7: The folder is the deployment package of the solution.
6. Troubleshooting
6.1. Integrating core framework with asp.net application
1. Error 48 Unable to resolve type 'DevExpress.Patch.InMemoryPatch,
DevExpress.Patch.Common, Version=7.0.0.0, Culture=neutral,
PublicKeyToken=7fc7bfca2443de66' C:\Users\Pc\Desktop\3-22-2017 PMS
Clone\PMS\PMS\Properties\licenses.licx 1 PMS

Solution: Remove DevExpress.Patch.InMemoryPatch,


DevExpress.Patch.Common, Version=7.0.0.0, Culture=neutral,
PublicKeyToken=7fc7bfca2443de66 from the licence file

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”.

2. Error: “The type 'MdaWcfService.MdmToMda', provided as the Service attribute


value in the ServiceHost directive, or provided in the configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations could not be
found.”
Solution
If the bin folder doesn’t contain dll files of all libreries you will get the error. So,
build the solution and make sure the bin folder contain all required libraries.

You might also like