Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/AC/index.ts
#	app/components/Request/CertificateRequest.tsx
#	app/i18n/EN.ts
#	app/i18n/RU.ts
#	app/trusted/store.ts
  • Loading branch information
algv committed Oct 9, 2018
2 parents 1a7e46b + 496af38 commit bf26583
Show file tree
Hide file tree
Showing 15 changed files with 497 additions and 163 deletions.
69 changes: 42 additions & 27 deletions app/AC/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
REMOVE_ALL_CERTIFICATES, REMOVE_ALL_CONTAINERS, REMOVE_ALL_FILES,
REMOVE_ALL_REMOTE_FILES, SELECT_FILE,
SELECT_SIGNER_CERTIFICATE, SELECT_TEMP_CONTENT_OF_SIGNED_FILES, START,
SUCCESS, TOGGLE_SAVE_TO_DOCUMENTS,
SUCCESS, TOGGLE_SAVE_TO_DOCUMENTS,
VERIFY_CERTIFICATE, VERIFY_SIGNATURE,
} from "../constants";
import { connectedSelector } from "../selectors";
Expand Down Expand Up @@ -67,7 +67,7 @@ export function packageSign(
format: trusted.DataFormat,
folderOut: string,
) {
return (dispatch, getState) => {
return (dispatch: (action: {}) => void, getState: () => any) => {
dispatch({
type: PACKAGE_SIGN + START,
});
Expand Down Expand Up @@ -107,6 +107,7 @@ export function packageSign(
let cms = signs.loadSign(newPath);

if (cms.isDetached()) {
// tslint:disable-next-line:no-conditional-assignment
if (!(cms = signs.setDetachedContent(cms, newPath))) {
throw new Error(("err"));
}
Expand All @@ -116,18 +117,19 @@ export function packageSign(

const normalyzeSignatureInfo: INormalizedSignInfo[] = [];

signatureInfo.forEach((info) => {
signatureInfo.forEach((info: any) => {
const subjectCert = info.certs[info.certs.length - 1];

normalyzeSignatureInfo.push({
subjectFriendlyName: info.subject,
digestAlgorithm: subjectCert.signatureDigestAlgorithm,
issuerFriendlyName: subjectCert.issuerFriendlyName,
notBefore: new Date(subjectCert.notBefore).getTime(),
issuerName: subjectCert.issuerName,
notAfter: new Date(subjectCert.notAfter).getTime(),
digestAlgorithm: subjectCert.signatureDigestAlgorithm,
notBefore: new Date(subjectCert.notBefore).getTime(),
signingTime: info.signingTime ? new Date(info.signingTime).getTime() : undefined,
subjectFriendlyName: info.subject,
subjectName: subjectCert.subjectName,
issuerName: subjectCert.issuerName,

});
});

Expand All @@ -139,7 +141,7 @@ export function packageSign(
signers: JSON.stringify(normalyzeSignatureInfo),
},
url: remoteFiles.uploader,
}, (err) => {
}, (err: Error) => {
if (err) {
if (connection && connection.connected && connection.socket) {
connection.socket.emit(ERROR, { id: file.remoteId, error: err });
Expand Down Expand Up @@ -186,7 +188,7 @@ export function packageSign(
}

export function filePackageSelect(files: IFilePath[]) {
return (dispatch, getState) => {
return (dispatch: (action: {}) => void) => {
dispatch({
type: PACKAGE_SELECT_FILE + START,
});
Expand Down Expand Up @@ -250,7 +252,7 @@ export function selectTempContentOfSignedFiles(tempContentOfSignedFiles: string)
}

export function loadAllCertificates() {
return (dispatch) => {
return (dispatch: (action: {}) => void) => {
dispatch({
type: LOAD_ALL_CERTIFICATES + START,
});
Expand All @@ -260,17 +262,29 @@ export function loadAllCertificates() {

window.PKISTORE = certificateStore;
window.TRUSTEDCERTIFICATECOLLECTION = certificateStore.trustedCerts;
window.PKIITEMS = certificateStore.items;

const certs = certificateStore.items.filter(function (item: trusted.pkistore.PkiItem) {
if (!item.id) {
item.id = item.provider + "_" + item.category + "_" + item.hash;
const crls = [];
const certs = [];

for (const item of certificateStore.items) {
if (item.type === "CERTIFICATE") {
if (!item.id) {
item.id = item.provider + "_" + item.category + "_" + item.hash;
}

certs.push(item);
} else if (item.type === "CRL") {
if (!item.id) {
item.id = item.provider + "_" + item.category + "_" + item.hash;
}

crls.push(item);
}
return item.type === "CERTIFICATE";
});
}

dispatch({
certs,
crls,
type: LOAD_ALL_CERTIFICATES + SUCCESS,
});
}, 0);
Expand All @@ -283,8 +297,8 @@ export function removeAllCertificates() {
};
}

export function verifyCertificate(certificateId) {
return (dispatch, getState) => {
export function verifyCertificate(certificateId: string) {
return (dispatch: (action: {}) => void, getState: () => any) => {
const { certificates } = getState();

const certItem = certificates.getIn(["entities", certificateId]);
Expand All @@ -310,21 +324,21 @@ export function verifyCertificate(certificateId) {
};
}

export function selectSignerCertificate(selected) {
export function selectSignerCertificate(selected: string) {
return {
payload: { selected },
type: SELECT_SIGNER_CERTIFICATE,
};
}

export function loadAllContainers() {
return (dispatch) => {
return (dispatch: (action: {}) => void) => {
dispatch({
type: LOAD_ALL_CONTAINERS + START,
});

setTimeout(() => {
let enumedContainers;
let enumedContainers: any[] = [];

try {
enumedContainers = trusted.utils.Csp.enumContainers(75);
Expand Down Expand Up @@ -360,7 +374,7 @@ export function removeAllContainers() {
}

export function getCertificateFromContainer(container: number) {
return (dispatch, getState) => {
return (dispatch: (action: {}) => void, getState: () => any) => {
dispatch({
payload: { container },
type: GET_CERTIFICATE_FROM_CONTAINER + START,
Expand Down Expand Up @@ -417,9 +431,9 @@ export function selectFile(fullpath: string, name?: string, lastModifiedDate?: D
extension,
filename: name ? name : path.basename(fullpath),
fullpath,
lastModifiedDate: lastModifiedDate ? lastModifiedDate : stat.birthtime,
lastModifiedDate: lastModifiedDate ? lastModifiedDate : (stat ? stat.birthtime : undefined),
remoteId,
size: size ? size : stat.size,
size: size ? size : (stat ? stat.size : undefined),
socket,
};

Expand All @@ -445,7 +459,7 @@ export function deleteFile(fileId: number) {
}

export function verifySignature(fileId: string) {
return (dispatch, getState) => {
return (dispatch: (action: {}) => void, getState: () => any) => {
const state = getState();
const { connections, documents, files } = state;
let signaruteStatus = false;
Expand All @@ -461,6 +475,7 @@ export function verifySignature(fileId: string) {
cms = signs.loadSign(file.fullpath);

if (cms.isDetached()) {
// tslint:disable-next-line:no-conditional-assignment
if (!(cms = signs.setDetachedContent(cms, file.fullpath))) {
throw new Error(("err"));
}
Expand All @@ -483,7 +498,7 @@ export function verifySignature(fileId: string) {
}
}

signatureInfo = signatureInfo.map((info) => {
signatureInfo = signatureInfo.map((info: any) => {
return {
fileId,
...info,
Expand All @@ -508,7 +523,7 @@ export function verifySignature(fileId: string) {
};
}

export function changeSignatureEncoding(encoding) {
export function changeSignatureEncoding(encoding: string) {
return {
payload: { encoding },
type: CHANGE_SIGNATURE_ENCODING,
Expand Down
4 changes: 4 additions & 0 deletions app/app.global.css
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,10 @@ i.material-icons.choosefolder {
line-height: 30px;
}

.collapsible {
margin: 0;
}

.collapsible-header.color{
background-color: ghostwhite;
}
Expand Down
97 changes: 97 additions & 0 deletions app/components/CRL/CRLInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import PropTypes from "prop-types";
import React from "react";
import { localizeAlgorithm } from "../../i18n/localize";

export interface ICRL {
active: boolean;
category: string;
format: string;
hash: string;
id: string;
issuerFriendlyName: string;
issuerName: string;
lastUpdate: Date;
nextUpdate: Date;
provider: string;
signatureAlgorithm: string;
signatureDigestAlgorithm: string;
type: string;
uri: string;
}

interface ICRLInfoProps {
crl: ICRL;
}

export default class CRLInfo extends React.Component<ICRLInfoProps, {}> {
static contextTypes = {
locale: PropTypes.string,
localize: PropTypes.func,
};

render() {
const { localize, locale } = this.context;
const { crl } = this.props;

return (
<div className="add-cert-collection collection cert-info-list">
<div className="collection-item certs-collection certificate-info">
<div className="collection-info cert-info-blue">
{localize("Certificate.issuer_name", locale)}
</div>
<div className="collection-title ">
{crl.issuerFriendlyName}
</div>
</div>
<div className="collection-item certs-collection certificate-info">
<div className="collection-info cert-info-blue">
{localize("CRL.lastUpdate", locale)}
</div>
<div className="collection-title ">{(new Date(crl.lastUpdate)).toLocaleDateString(locale, {
day: "numeric",
hour: "numeric",
minute: "numeric",
month: "long",
year: "numeric",
})}</div>
</div>
<div className="collection-item certs-collection certificate-info">
<div className="collection-info cert-info-blue">
{localize("CRL.nextUpdate", locale)}
</div>
<div className="collection-title ">{(new Date(crl.nextUpdate)).toLocaleDateString(locale, {
day: "numeric",
hour: "numeric",
minute: "numeric",
month: "long",
year: "numeric",
})}</div>
</div>
<div className="collection-item certs-collection certificate-info">
<div className="collection-info cert-info-blue">
{localize("Sign.alg", locale)}
</div>
<div className={"collection-title "}>
{localizeAlgorithm(crl.signatureAlgorithm, locale)}
</div>
</div>
<div className="collection-item certs-collection certificate-info">
<div className="collection-info cert-info-blue">
{localize("Certificate.signature_digest_algorithm", locale)}
</div>
<div className="collection-title ">
{localizeAlgorithm(crl.signatureDigestAlgorithm, locale)}
</div>
</div>
<div className="collection-item certs-collection certificate-info">
<div className="collection-info cert-info-blue">
{localize("Certificate.thumbprint", locale)}
</div>
<div className="collection-title ">
{crl.hash}
</div>
</div>
</div>
);
}
}
Loading

0 comments on commit bf26583

Please sign in to comment.