Создание Web-сервиса осуществляющего цифровую подпись

Автор работы: Пользователь скрыл имя, 03 Мая 2014 в 18:37, курсовая работа

Краткое описание

В данной курсовой работе рассматривается создание программного продукта, который позволит удаленно совершать цифровую подпись документов и проверять её подлинность.

Содержание

Цели и задачи курсовой работы 5
Подготовка и порядок выполнения работы 6
1. Теоретические сведения 7
1. 1. Построение Web – сервиса с функцией электронной подписи 7
2. CryptoAPI 9
3. Windows Communication Foundation 10
4. Описание программы 12
5. Сравнение программы с другими программными продуктами 13
Заключение 14
Список первоисточников 15
Приложения 16
Руководство пользователя 16
Руководство администратора 16
Руководство разработчика 17
Снимок с экрана работающей программы 18
Техническое задание 19
Исходный код программы 22

Прикрепленные файлы: 1 файл

Пояснительная записка Трошагин.docx

— 121.32 Кб (Скачать документ)

                                            ErrorText="Обязательное поле" ErrorTextPosition="Bottom" ValidationGroup="entryGroup"

                                            SetFocusOnError="true">

                                            <RequiredField ErrorText="Обязательное поле" IsRequired="True" />

                                            <ErrorFrameStyle CssClass="ValidateText">

                                            </ErrorFrameStyle>

                                        </ValidationSettings>

                            </dxe:ASPxTextBox>

                        </td>

                    </tr>

                    <tr>

                        <td>

                            <dxe:ASPxLabel ID="lNewPassword" runat="server" AssociatedControlID="tbNewPassword"

                                CssClass="Label" Text="Введите пароль:">

                            </dxe:ASPxLabel>

                        </td>

                        <td>

                        <dxe:ASPxTextBox ID="tbNewPassword" runat="server" Width="170px"

                        ClientInstanceName="tbNewPassword" EnableClientSideAPI="True" Password="True"

                                MaxLength="12" ToolTip="Введите новый пароль мин. длина 8 мак. 12">

                                        <ValidationSettings CausesValidation="True" EnableCustomValidation="True" ErrorDisplayMode="Text"

                                            ErrorText="Обязательное поле" ErrorTextPosition="Bottom" ValidationGroup="passwordGroup"

                                            SetFocusOnError="true">

                                            <RequiredField ErrorText="Обязательное поле" IsRequired="True" />

                                            <ErrorFrameStyle CssClass="ValidateText">

                                            </ErrorFrameStyle>

                                            <RegularExpression ErrorText="Ваш пароль должен содержать не менее 8 символов. Из букв латинского алфавита (минимум 1 прописной буквы и 1 буквы нижнего регистра) и минимум 1 числа."

                                                ValidationExpression="^((?=.*[^a-zA-Z])(?=.*[a-z])(?=.*[A-Z])(?!.*\s).{8,12})$" />

                                        </ValidationSettings>

                                        <ClientSideEvents  LostFocus="function(s, e) {LostFocusValid(s, e, 'passwordGroup')}" />

                        </dxe:ASPxTextBox>

                        </td>

                    </tr>

                    <tr>

                        <td colspan="2">

                            <dxe:ASPxValidationSummary  ShowErrorAsLink="true" ValidationGroup="passwordGroup"

                                Width="450" runat="server" ID="summaryValidationPassword" RenderMode="Table">

                            </dxe:ASPxValidationSummary>

                        </td>

                    </tr>

                    <tr>

                        <td>

                            <dxe:ASPxLabel ID="lNewPasswordConfirm" runat="server" AssociatedControlID="tbNewPasswordConfirm"

                                CssClass="Label" Text="Подтвердите пароль:">

                            </dxe:ASPxLabel>

                        </td>

                        <td>

                        <dxe:ASPxTextBox ID="tbNewPasswordConfirm" runat="server" Width="170px"

                            ClientInstanceName="tbNewPasswordConfirm" EnableClientSideAPI="True"

                                Password="True" MaxLength="12"

                                ToolTip="Введите новый пароль мин. длина 8 мак. 10">

                                        <ClientSideEvents Validation="function(s, e) {

e.isValid = (tbNewPassword.GetValue() == tbNewPasswordConfirm.GetValue());

if (!e.isValid)

{

e.errorText = &quot;Пароль и  подтверждение пароля не совпадают &quot;;

}   

}" />

                                        <ValidationSettings CausesValidation="True" EnableCustomValidation="True" ErrorDisplayMode="Text"

                                            ErrorText="Подтверждение пароля и пароль не совпадают" ErrorTextPosition="Bottom" ValidationGroup="entryGroup"

                                            SetFocusOnError="true">

                                            <RequiredField ErrorText="Обязательное поле" IsRequired="True" />

                                            <ErrorFrameStyle CssClass="ValidateText">

                                            </ErrorFrameStyle>

                                        </ValidationSettings>

                            </dxe:ASPxTextBox>

                        </td>

                    </tr>

                    <tr>

                        <td>

                           <dxe:ASPxLabel ID="lbChangePass" runat="server"

                                CssClass="Label" Text="!Пароль должен быть изменен!" Visible="False"

                                ForeColor="#FF3300">

                            </dxe:ASPxLabel>

                        <td>

                            &nbsp;

                        </td>

                    </tr>

                    <tr>

                        <td>

                            &nbsp;

                        </td>

                        <td align="right">

                            <dxe:ASPxButton ID="bOk" runat="server" Text="Создать" OnClick="bOk_Click">

                                <ClientSideEvents Click="function(s, e) {

 

e.processOnServer = ASPxClientEdit.ValidateGroup('entryGroup');

}

" />

                            </dxe:ASPxButton>

                        </td>

                    </tr>

                </table>

            </dxp:PanelContent>

        </PanelCollection>

    </dxp:ASPxPanel>

    <dxpc:ASPxPopupControl ID="pcOk" runat="server" HeaderText="Информация"

        PopupHorizontalAlign="WindowCenter" Text="Пользователь успешно создан"

        AllowDragging="True" CloseAction="None" DragElement="Window" Modal="True"

        PopupVerticalAlign="WindowCenter" ShowCloseButton="False" Width="230px">

        <ContentStyle HorizontalAlign="Left">

        </ContentStyle>

        <ContentCollection>

<dxpc:PopupControlContentControl ID="PopupControlContentControl1" runat="server">

<table width="100%"><tr align="center"><td>

    <dxe:ASPxButton ID="bInfoOk" runat="server" Text="Закрыть"

        OnClick="bInfoOk_Click">

    </dxe:ASPxButton>

    </td></tr></table>

            </dxpc:PopupControlContentControl>

</ContentCollection>

    </dxpc:ASPxPopupControl>

</asp:Content>

 

 

Message.aspx.cs

 

<%@ Page Title="" Language="C#" MasterPageFile="~/Client.Master" AutoEventWireup="true"

         CodeBehind="Message.aspx.cs" Inherits="ClientWeb.Message" %>

 

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v12.1.Export, Version=12.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"

             Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgv" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">

    <table>

        <tr>

            <td>

                <dxe:ASPxLabel ID="lPeriod" runat="server" Text="Сообщения за период:" CssClass="Label">

                </dxe:ASPxLabel>

                <br />

                <dxe:ASPxLabel ID="lDateBegin" runat="server" Text="с" AssociatedControlID="tbDateBegin"

                               CssClass="Label">

                </dxe:ASPxLabel>

                <dxe:ASPxDateEdit ID="tbDateBegin" runat="server"

                                  PopupVerticalAlign="BottomSides" Width="170px">

                    <ValidationSettings EnableCustomValidation="True" ValidationGroup="entryGroup" SetFocusOnError="True"

                                        ErrorDisplayMode="Text" ErrorTextPosition="Bottom" CausesValidation="True">

                        <RequiredField ErrorText="Дата начала является обязательной" IsRequired="True" />

                        <ErrorFrameStyle Font-Size="10px">

                            <ErrorTextPaddings PaddingLeft="0px" />

                        </ErrorFrameStyle>

                    </ValidationSettings>

                </dxe:ASPxDateEdit>

                <dxe:ASPxLabel ID="lDateEnd" runat="server" Text="по" AssociatedControlID="tbDateEnd"

                               CssClass="Label">

                </dxe:ASPxLabel>

                <dxe:ASPxDateEdit ID="tbDateEnd" runat="server" Width="170px">

                    <ValidationSettings EnableCustomValidation="True" ValidationGroup="entryGroup" SetFocusOnError="True"

                                        ErrorDisplayMode="Text" ErrorTextPosition="Bottom" CausesValidation="True">

                        <RequiredField ErrorText="Дата конца является обязательной" IsRequired="True" />

                        <ErrorFrameStyle Font-Size="10px">

                            <ErrorTextPaddings PaddingLeft="0px" />

                        </ErrorFrameStyle>

                    </ValidationSettings>

                </dxe:ASPxDateEdit>

                <dxe:ASPxCheckBox ID="cbNotReaded" runat="server" Text="Не прочитанные">

                </dxe:ASPxCheckBox>

                <dxe:ASPxCheckBox ID="cbReaded" runat="server" Text="Прочитанные">

                </dxe:ASPxCheckBox>

            </td>

        </tr>

        <tr>

            <td colspan="2">

                <dxe:ASPxButton ID="btOK" runat="server" Text="Показать" Width="80px">

                    <ClientSideEvents Click="function(s, e) {e.processOnServer = ASPxClientEdit.ValidateGroup('entryGroup');}" />

                </dxe:ASPxButton>

            </td>

        </tr>

    </table>

 

    <dxwgv:ASPxGridView ID="ASPxGridView" runat="server" AutoGenerateColumns="False"

                        Width="100%" KeyFieldName="Id" Theme="Glass">

        <SettingsBehavior AutoExpandAllGroups="True" />

        <Columns>

            <dxwgv:GridViewDataDateColumn Caption="Дата" FieldName="Date" Name="Date"

                                          VisibleIndex="0" Width="20%" SortIndex="0" SortOrder="Descending">

                <PropertiesDateEdit DisplayFormatString="">

                </PropertiesDateEdit>

            </dxwgv:GridViewDataDateColumn>

            <dxwgv:GridViewDataCheckColumn Caption="Прочтено" FieldName="IsRead"

                                           Name="IsRead" VisibleIndex="1">

            </dxwgv:GridViewDataCheckColumn>

            <dxwgv:GridViewDataHyperLinkColumn FieldName="Id" Name="Subject"

                                               VisibleIndex="2" Caption="Тема" Width="100%">

                <PropertiesHyperLinkEdit NavigateUrlFormatString="~\ReadMessage.aspx?Id={0}"

                                         TextField="Subject">

                </PropertiesHyperLinkEdit>

                <CellStyle HorizontalAlign="Left">

                </CellStyle>

            </dxwgv:GridViewDataHyperLinkColumn>

            <dxwgv:GridViewDataCheckColumn FieldName="HaveAttachment" Name="haveAttachment"

                                           VisibleIndex="3" Caption="Att">

                <propertiescheckedit>

                   

                    <displayimagechecked ToolTip="Прикреплен файл"  height="15px"

                                         url="~/Images/attachment.png" width="15px" />

               

 

                    <displayimageunchecked url="~/Images/cleardot.gif" height="15px" width="15px" >  </displayimageunchecked>

                </propertiescheckedit>

            </dxwgv:GridViewDataCheckColumn>

          <dxwgv:GridViewDataTextColumn Caption="Получатель" FieldName="ToUserName"

Name="colToUser" VisibleIndex="4">

</dxwgv:GridViewDataTextColumn>

        </Columns>

 

        <SettingsBehavior AutoExpandAllGroups="True"></SettingsBehavior>

    </dxwgv:ASPxGridView>

    <dxwgv:ASPxGridViewExporter ID="gridExporter" GridViewID="ASPxGridView" runat="server">

    </dxwgv:ASPxGridViewExporter>

    <dxe:aspxbutton id="BtnExcel" runat="server" style="float: right;" Border-BorderWidth="0" BackgroundImage-ImageUrl="none" BackColor="White" ToolTip="Нажмите для экспорта в Excel" Image-Url="~/Images/excel_icon.gif" Image-AlternateText="Экспортировать в Excel"

                    onclick="BtnExcel_Click" Height="16px" Width="16px" ImagePosition="Top">

    </dxe:aspxbutton>

</asp:Content>

<asp:Content ID="Content4" runat="server" ContentPlaceHolderID="ContextMenu">

    <dxm:ASPxMenu ID="ASPxContextMenu" runat="server" OnItemClick="ASPxContextMenu_ItemClick">

        <Items>

            <dxm:MenuItem Name="Create" Text="Создать" NavigateUrl="~/CreateMessage.aspx">

            </dxm:MenuItem>

        </Items>

    </dxm:ASPxMenu>

</asp:Content>

<asp:Content ID="Content5" runat="server" ContentPlaceHolderID="PageName">

    <dxe:ASPxLabel ID="lPageName" runat="server" CssClass="PageName">

    </dxe:ASPxLabel>

</asp:Content>

 

 

Message.cs

 

                listAttachments.DataSource = attach;

                Domain.MessageAttachment attachment = Global.ServerObject.GetAttachmentById(attach[0].Id);

                int startPos = attachment.FileBody.Length - 128;

                byte[] ecp = new byte[128];

                byte[] file = new byte[attachment.FileBody.Length - 128];

                for (int i = startPos; i < attachment.FileBody.Length; i++)

                {

                    ecp[i - startPos] = attachment.FileBody[i];

                }

                for (int i = 0; i < file.Length; i++)

                    file[i] = attachment.FileBody[i];

 

                AsymmetricSignatureDeformatter df;

                RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024);

                RSAParameters tmp = new RSAParameters();

                BinaryFormatter bf = new BinaryFormatter();

                MemoryStream ms = new MemoryStream(PublicKey, true);

                tmp.Exponent = (byte[])bf.Deserialize(ms);

Информация о работе Создание Web-сервиса осуществляющего цифровую подпись