├── .classpath
├── .project
├── .settings
├── org.eclipse.core.resources.prefs
└── org.eclipse.jdt.core.prefs
├── README.md
├── a.properties
├── bin
├── SEFunction
│ ├── AttributesGenerate.class
│ ├── CloudServer.class
│ ├── DataOwner.class
│ ├── DeleteFolder.class
│ ├── KeywordIndex.class
│ ├── ProxyServer.class
│ ├── SearchMasterKey.class
│ ├── TrustAuthority.class
│ ├── User.class
│ └── UserTuple.class
├── bswabe
│ ├── Bswabe.class
│ ├── BswabeCph.class
│ ├── BswabeMsk.class
│ ├── BswabePrv.class
│ ├── BswabePub.class
│ ├── PolynDiv.class
│ ├── PolynomialOperate.class
│ └── SerializeUtils.class
├── cscpabe
│ ├── AESCoder.class
│ ├── Common.class
│ └── csCpabe.class
├── gui
│ ├── GUI$1.class
│ ├── GUI$10.class
│ ├── GUI$11.class
│ ├── GUI$12.class
│ ├── GUI$13.class
│ ├── GUI$14.class
│ ├── GUI$15.class
│ ├── GUI$16.class
│ ├── GUI$17.class
│ ├── GUI$18.class
│ ├── GUI$19.class
│ ├── GUI$2.class
│ ├── GUI$20.class
│ ├── GUI$21.class
│ ├── GUI$22.class
│ ├── GUI$23.class
│ ├── GUI$24.class
│ ├── GUI$25.class
│ ├── GUI$26.class
│ ├── GUI$27.class
│ ├── GUI$28.class
│ ├── GUI$3.class
│ ├── GUI$4.class
│ ├── GUI$5.class
│ ├── GUI$6.class
│ ├── GUI$7.class
│ ├── GUI$8.class
│ ├── GUI$9.class
│ └── GUI.class
└── test
│ └── Test.class
├── file
├── CloudServer
│ ├── Fid.txt
│ ├── KeywordTable.xls
│ ├── cph
│ │ ├── 1_file
│ │ ├── 2_file
│ │ ├── 3_file
│ │ └── 4_file
│ ├── file
│ │ ├── 1.cpabe
│ │ ├── 2.cpabe
│ │ ├── 3.cpabe
│ │ └── 4.cpabe
│ └── public_key
├── ProxyServer
│ └── ProxyTable.xls
├── TrustAuthority
│ ├── RegisterTable.xls
│ ├── kmk_key
│ └── master_key
└── User
│ └── 1
│ ├── A Survey of Provably Secure Searchable Encryption.pdf
│ ├── CP-ABE With Constant-Size Keys for.pdf
│ ├── SearchResultFilepath.txt
│ ├── SearchResultName.txt
│ ├── SearchResultNumber.txt
│ ├── private_key
│ └── user_file
├── image
├── DOimage.png
├── TAimage.png
├── USimage.png
├── decryptimage.png
├── newusergrantimage.png
├── searchimage.png
└── userrevocationimage.png
├── lib
├── jpbc-api-2.0.0.jar
├── jpbc-plaf-2.0.0.jar
└── jxl-2.6.12.jar
└── src
├── SEFunction
├── AttributesGenerate.java
├── CloudServer.java
├── DataOwner.java
├── DeleteFolder.java
├── KeywordIndex.java
├── ProxyServer.java
├── SearchMasterKey.java
├── TrustAuthority.java
├── User.java
└── UserTuple.java
├── bswabe
├── Bswabe.java
├── BswabeCph.java
├── BswabeMsk.java
├── BswabePrv.java
├── BswabePub.java
├── PolynDiv.java
├── PolynomialOperate.java
└── SerializeUtils.java
├── cscpabe
├── AESCoder.java
├── Common.java
└── csCpabe.java
├── gui
└── GUI.java
└── test
└── Test.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ConstantSizeCPABESE
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/gui/GUI.java=UTF-8
3 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.8
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.8
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ConstantSizeCPABESE
2 | constant size cp-abe searchable encryptyion scheme
3 |
4 | This is the prototype of my Master's thesis "Multi-User Searchable Encryption Scheme with Constant-Size Keys" which was published in 2017 IEEE 7th International Symposium on Cloud and Service Computing (SC2).
5 |
6 | It was programmed by Java.
7 |
--------------------------------------------------------------------------------
/a.properties:
--------------------------------------------------------------------------------
1 | type a
2 | q 8780710799663312522437781984754049815806883199414208211028653399266475630880222957078625179422662221423155858769582317459277713367317481324925129998224791
3 | h 12016012264891146079388821366740534204802954401251311822919615131047207289359704531102844802183906537786776
4 | r 730750818665451621361119245571504901405976559617
5 | exp2 159
6 | exp1 107
7 | sign1 1
8 | sign0 1
9 |
--------------------------------------------------------------------------------
/bin/SEFunction/AttributesGenerate.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/SEFunction/AttributesGenerate.class
--------------------------------------------------------------------------------
/bin/SEFunction/CloudServer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/SEFunction/CloudServer.class
--------------------------------------------------------------------------------
/bin/SEFunction/DataOwner.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/SEFunction/DataOwner.class
--------------------------------------------------------------------------------
/bin/SEFunction/DeleteFolder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/SEFunction/DeleteFolder.class
--------------------------------------------------------------------------------
/bin/SEFunction/KeywordIndex.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/SEFunction/KeywordIndex.class
--------------------------------------------------------------------------------
/bin/SEFunction/ProxyServer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/SEFunction/ProxyServer.class
--------------------------------------------------------------------------------
/bin/SEFunction/SearchMasterKey.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/SEFunction/SearchMasterKey.class
--------------------------------------------------------------------------------
/bin/SEFunction/TrustAuthority.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/SEFunction/TrustAuthority.class
--------------------------------------------------------------------------------
/bin/SEFunction/User.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/SEFunction/User.class
--------------------------------------------------------------------------------
/bin/SEFunction/UserTuple.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/SEFunction/UserTuple.class
--------------------------------------------------------------------------------
/bin/bswabe/Bswabe.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/bswabe/Bswabe.class
--------------------------------------------------------------------------------
/bin/bswabe/BswabeCph.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/bswabe/BswabeCph.class
--------------------------------------------------------------------------------
/bin/bswabe/BswabeMsk.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/bswabe/BswabeMsk.class
--------------------------------------------------------------------------------
/bin/bswabe/BswabePrv.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/bswabe/BswabePrv.class
--------------------------------------------------------------------------------
/bin/bswabe/BswabePub.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/bswabe/BswabePub.class
--------------------------------------------------------------------------------
/bin/bswabe/PolynDiv.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/bswabe/PolynDiv.class
--------------------------------------------------------------------------------
/bin/bswabe/PolynomialOperate.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/bswabe/PolynomialOperate.class
--------------------------------------------------------------------------------
/bin/bswabe/SerializeUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/bswabe/SerializeUtils.class
--------------------------------------------------------------------------------
/bin/cscpabe/AESCoder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/cscpabe/AESCoder.class
--------------------------------------------------------------------------------
/bin/cscpabe/Common.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/cscpabe/Common.class
--------------------------------------------------------------------------------
/bin/cscpabe/csCpabe.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/cscpabe/csCpabe.class
--------------------------------------------------------------------------------
/bin/gui/GUI$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$1.class
--------------------------------------------------------------------------------
/bin/gui/GUI$10.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$10.class
--------------------------------------------------------------------------------
/bin/gui/GUI$11.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$11.class
--------------------------------------------------------------------------------
/bin/gui/GUI$12.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$12.class
--------------------------------------------------------------------------------
/bin/gui/GUI$13.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$13.class
--------------------------------------------------------------------------------
/bin/gui/GUI$14.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$14.class
--------------------------------------------------------------------------------
/bin/gui/GUI$15.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$15.class
--------------------------------------------------------------------------------
/bin/gui/GUI$16.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$16.class
--------------------------------------------------------------------------------
/bin/gui/GUI$17.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$17.class
--------------------------------------------------------------------------------
/bin/gui/GUI$18.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$18.class
--------------------------------------------------------------------------------
/bin/gui/GUI$19.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$19.class
--------------------------------------------------------------------------------
/bin/gui/GUI$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$2.class
--------------------------------------------------------------------------------
/bin/gui/GUI$20.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$20.class
--------------------------------------------------------------------------------
/bin/gui/GUI$21.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$21.class
--------------------------------------------------------------------------------
/bin/gui/GUI$22.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$22.class
--------------------------------------------------------------------------------
/bin/gui/GUI$23.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$23.class
--------------------------------------------------------------------------------
/bin/gui/GUI$24.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$24.class
--------------------------------------------------------------------------------
/bin/gui/GUI$25.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$25.class
--------------------------------------------------------------------------------
/bin/gui/GUI$26.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$26.class
--------------------------------------------------------------------------------
/bin/gui/GUI$27.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$27.class
--------------------------------------------------------------------------------
/bin/gui/GUI$28.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$28.class
--------------------------------------------------------------------------------
/bin/gui/GUI$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$3.class
--------------------------------------------------------------------------------
/bin/gui/GUI$4.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$4.class
--------------------------------------------------------------------------------
/bin/gui/GUI$5.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$5.class
--------------------------------------------------------------------------------
/bin/gui/GUI$6.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$6.class
--------------------------------------------------------------------------------
/bin/gui/GUI$7.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$7.class
--------------------------------------------------------------------------------
/bin/gui/GUI$8.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$8.class
--------------------------------------------------------------------------------
/bin/gui/GUI$9.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI$9.class
--------------------------------------------------------------------------------
/bin/gui/GUI.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/gui/GUI.class
--------------------------------------------------------------------------------
/bin/test/Test.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/bin/test/Test.class
--------------------------------------------------------------------------------
/file/CloudServer/Fid.txt:
--------------------------------------------------------------------------------
1 | 4
--------------------------------------------------------------------------------
/file/CloudServer/KeywordTable.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/CloudServer/KeywordTable.xls
--------------------------------------------------------------------------------
/file/CloudServer/cph/1_file:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/CloudServer/cph/1_file
--------------------------------------------------------------------------------
/file/CloudServer/cph/2_file:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/CloudServer/cph/2_file
--------------------------------------------------------------------------------
/file/CloudServer/cph/3_file:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/CloudServer/cph/3_file
--------------------------------------------------------------------------------
/file/CloudServer/cph/4_file:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/CloudServer/cph/4_file
--------------------------------------------------------------------------------
/file/CloudServer/file/1.cpabe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/CloudServer/file/1.cpabe
--------------------------------------------------------------------------------
/file/CloudServer/file/2.cpabe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/CloudServer/file/2.cpabe
--------------------------------------------------------------------------------
/file/CloudServer/file/3.cpabe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/CloudServer/file/3.cpabe
--------------------------------------------------------------------------------
/file/CloudServer/file/4.cpabe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/CloudServer/file/4.cpabe
--------------------------------------------------------------------------------
/file/CloudServer/public_key:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/CloudServer/public_key
--------------------------------------------------------------------------------
/file/ProxyServer/ProxyTable.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/ProxyServer/ProxyTable.xls
--------------------------------------------------------------------------------
/file/TrustAuthority/RegisterTable.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/TrustAuthority/RegisterTable.xls
--------------------------------------------------------------------------------
/file/TrustAuthority/kmk_key:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/TrustAuthority/kmk_key
--------------------------------------------------------------------------------
/file/TrustAuthority/master_key:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/TrustAuthority/master_key
--------------------------------------------------------------------------------
/file/User/1/A Survey of Provably Secure Searchable Encryption.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/User/1/A Survey of Provably Secure Searchable Encryption.pdf
--------------------------------------------------------------------------------
/file/User/1/CP-ABE With Constant-Size Keys for.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/User/1/CP-ABE With Constant-Size Keys for.pdf
--------------------------------------------------------------------------------
/file/User/1/SearchResultFilepath.txt:
--------------------------------------------------------------------------------
1 | file/CloudServer/file/2.cpabe
2 | file/CloudServer/file/3.cpabe
3 |
--------------------------------------------------------------------------------
/file/User/1/SearchResultName.txt:
--------------------------------------------------------------------------------
1 | CP-ABE With Constant-Size Keys for.pdf
2 | A Survey of Provably Secure Searchable Encryption.pdf
3 |
--------------------------------------------------------------------------------
/file/User/1/SearchResultNumber.txt:
--------------------------------------------------------------------------------
1 | 2
2 |
--------------------------------------------------------------------------------
/file/User/1/private_key:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/User/1/private_key
--------------------------------------------------------------------------------
/file/User/1/user_file:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/file/User/1/user_file
--------------------------------------------------------------------------------
/image/DOimage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/image/DOimage.png
--------------------------------------------------------------------------------
/image/TAimage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/image/TAimage.png
--------------------------------------------------------------------------------
/image/USimage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/image/USimage.png
--------------------------------------------------------------------------------
/image/decryptimage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/image/decryptimage.png
--------------------------------------------------------------------------------
/image/newusergrantimage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/image/newusergrantimage.png
--------------------------------------------------------------------------------
/image/searchimage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/image/searchimage.png
--------------------------------------------------------------------------------
/image/userrevocationimage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/image/userrevocationimage.png
--------------------------------------------------------------------------------
/lib/jpbc-api-2.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/lib/jpbc-api-2.0.0.jar
--------------------------------------------------------------------------------
/lib/jpbc-plaf-2.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/lib/jpbc-plaf-2.0.0.jar
--------------------------------------------------------------------------------
/lib/jxl-2.6.12.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/lib/jxl-2.6.12.jar
--------------------------------------------------------------------------------
/src/SEFunction/AttributesGenerate.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/SEFunction/AttributesGenerate.java
--------------------------------------------------------------------------------
/src/SEFunction/CloudServer.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/SEFunction/CloudServer.java
--------------------------------------------------------------------------------
/src/SEFunction/DataOwner.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/SEFunction/DataOwner.java
--------------------------------------------------------------------------------
/src/SEFunction/DeleteFolder.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/SEFunction/DeleteFolder.java
--------------------------------------------------------------------------------
/src/SEFunction/KeywordIndex.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/SEFunction/KeywordIndex.java
--------------------------------------------------------------------------------
/src/SEFunction/ProxyServer.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/SEFunction/ProxyServer.java
--------------------------------------------------------------------------------
/src/SEFunction/SearchMasterKey.java:
--------------------------------------------------------------------------------
1 | package SEFunction;
2 |
3 | import it.unisa.dia.gas.jpbc.Element;
4 |
5 | public class SearchMasterKey {
6 | /*
7 | * The search master key
8 | */
9 | public Element K_mk; /*Z_r */
10 | }
11 |
--------------------------------------------------------------------------------
/src/SEFunction/TrustAuthority.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/SEFunction/TrustAuthority.java
--------------------------------------------------------------------------------
/src/SEFunction/User.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/SEFunction/User.java
--------------------------------------------------------------------------------
/src/SEFunction/UserTuple.java:
--------------------------------------------------------------------------------
1 | package SEFunction;
2 |
3 | import it.unisa.dia.gas.jpbc.Element;
4 |
5 | public class UserTuple {
6 | /*
7 | * ( Uid, A_Uid, SK )
8 | */
9 | public int Uid;
10 | public Element A_Uid; /* Z_r */
11 | // private key
12 | public Element g_s_faA; /* G_1 */
13 | public Element h_s1_a; /* G_2 */
14 | public int fxALength;
15 | public Element[] fxA; /* Z_r */
16 | }
17 |
--------------------------------------------------------------------------------
/src/bswabe/Bswabe.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/bswabe/Bswabe.java
--------------------------------------------------------------------------------
/src/bswabe/BswabeCph.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/bswabe/BswabeCph.java
--------------------------------------------------------------------------------
/src/bswabe/BswabeMsk.java:
--------------------------------------------------------------------------------
1 | package bswabe;
2 |
3 | import it.unisa.dia.gas.jpbc.Element;
4 |
5 | public class BswabeMsk {
6 | /*
7 | * A master secret key
8 | */
9 | public Element alpha; /* Z_r */
10 | public Element g; /* G_1 */
11 | }
12 |
--------------------------------------------------------------------------------
/src/bswabe/BswabePrv.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/bswabe/BswabePrv.java
--------------------------------------------------------------------------------
/src/bswabe/BswabePub.java:
--------------------------------------------------------------------------------
1 | package bswabe;
2 |
3 | import it.unisa.dia.gas.jpbc.Element;
4 | import it.unisa.dia.gas.jpbc.Pairing;
5 |
6 | public class BswabePub {
7 | /*
8 | * A public key
9 | */
10 | public Pairing pairing;
11 | public int n;
12 | public Element[] vi; /* G_1 */
13 | public Element h; /* G_2 */
14 | public Element[] hi; /* G_2 */
15 | public Element e_gh; /* G_T */
16 | public Element H1; /* Z_r */
17 | public Element H2; /* Z_r */
18 | public Element H3; /* Z_r */
19 | public Element H4; /* Z_r */
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/bswabe/PolynDiv.java:
--------------------------------------------------------------------------------
1 | package bswabe;
2 |
3 | import it.unisa.dia.gas.jpbc.Element;
4 |
5 | public class PolynDiv {
6 | /*
7 | * Polynomial divide structure
8 | */
9 | public Element[] result;
10 | public Element[] remainder;
11 | }
12 |
--------------------------------------------------------------------------------
/src/bswabe/PolynomialOperate.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/bswabe/PolynomialOperate.java
--------------------------------------------------------------------------------
/src/bswabe/SerializeUtils.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RayHaha/ConstantSizeCPABESE/5a35a0a17b11665a5e174d2903219a9cc54b3b27/src/bswabe/SerializeUtils.java
--------------------------------------------------------------------------------
/src/cscpabe/AESCoder.java:
--------------------------------------------------------------------------------
1 | package cscpabe;
2 | import java.security.SecureRandom;
3 |
4 | import javax.crypto.Cipher;
5 | import javax.crypto.KeyGenerator;
6 | import javax.crypto.SecretKey;
7 | import javax.crypto.spec.SecretKeySpec;
8 |
9 | public class AESCoder {
10 |
11 | private static byte[] getRawKey(byte[] seed) throws Exception {
12 | KeyGenerator kgen = KeyGenerator.getInstance("AES");
13 | SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
14 | sr.setSeed(seed);
15 | kgen.init(128, sr); // 192 and 256 bits may not be available
16 | SecretKey skey = kgen.generateKey();
17 | byte[] raw = skey.getEncoded();
18 | return raw;
19 | }
20 |
21 | public static byte[] encrypt(byte[] seed, byte[] plaintext)
22 | throws Exception {
23 | byte[] raw = getRawKey(seed);
24 | SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
25 | Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
26 | cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
27 | byte[] encrypted = cipher.doFinal(plaintext);
28 | return encrypted;
29 | }
30 |
31 | public static byte[] decrypt(byte[] seed, byte[] ciphertext)
32 | throws Exception {
33 | byte[] raw = getRawKey(seed);
34 | SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
35 | Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
36 | cipher.init(Cipher.DECRYPT_MODE, skeySpec);
37 | byte[] decrypted = cipher.doFinal(ciphertext);
38 |
39 | return decrypted;
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/src/cscpabe/Common.java:
--------------------------------------------------------------------------------
1 | package cscpabe;
2 | import java.io.ByteArrayOutputStream;
3 | import java.io.FileInputStream;
4 | import java.io.FileOutputStream;
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.io.OutputStream;
8 |
9 | public class Common {
10 |
11 | /* read byte[] from inputfile */
12 | public static byte[] suckFile(String inputfile) throws IOException {
13 | InputStream is = new FileInputStream(inputfile);
14 | int size = is.available();
15 | byte[] content = new byte[size];
16 |
17 | is.read(content);
18 |
19 | is.close();
20 | return content;
21 | }
22 |
23 | /* write byte[] into outputfile */
24 | public static void spitFile(String outputfile, byte[] b) throws IOException {
25 | OutputStream os = new FileOutputStream(outputfile);
26 | os.write(b);
27 | os.close();
28 | }
29 |
30 |
31 | public static void writeCpabeFile(String encfile,
32 | byte[] cphBuf, byte[] aesBuf) throws IOException {
33 | int i;
34 | OutputStream os = new FileOutputStream(encfile);
35 |
36 | /* write aes_buf */
37 | for (i = 3; i >= 0; i--)
38 | os.write(((aesBuf.length & (0xff << 8 * i)) >> 8 * i));
39 | os.write(aesBuf);
40 |
41 | /* write cph_buf */
42 | for (i = 3; i >= 0; i--)
43 | os.write(((cphBuf.length & (0xff << 8 * i)) >> 8 * i));
44 | os.write(cphBuf);
45 |
46 | os.close();
47 |
48 | }
49 |
50 | public static byte[][] readCpabeFile(String encfile) throws IOException {
51 | int i, len;
52 | InputStream is = new FileInputStream(encfile);
53 | byte[][] res = new byte[2][];
54 | byte[] aesBuf, cphBuf;
55 |
56 | /* read aes buf */
57 | len = 0;
58 | for (i = 3; i >= 0; i--)
59 | len |= is.read() << (i * 8);
60 | aesBuf = new byte[len];
61 |
62 | is.read(aesBuf);
63 |
64 | /* read cph buf */
65 | len = 0;
66 | for (i = 3; i >= 0; i--)
67 | len |= is.read() << (i * 8);
68 | cphBuf = new byte[len];
69 |
70 | is.read(cphBuf);
71 |
72 | is.close();
73 |
74 | res[0] = aesBuf;
75 | res[1] = cphBuf;
76 | return res;
77 | }
78 | /**
79 | * Return a ByteArrayOutputStream instead of writing to a file
80 | */
81 | public static ByteArrayOutputStream writeCpabeData(byte[] mBuf,
82 | byte[] cphBuf, byte[] aesBuf) throws IOException {
83 | int i;
84 | ByteArrayOutputStream os = new ByteArrayOutputStream();
85 | /* write m_buf */
86 | for (i = 3; i >= 0; i--)
87 | os.write(((mBuf.length & (0xff << 8 * i)) >> 8 * i));
88 | os.write(mBuf);
89 |
90 | /* write aes_buf */
91 | for (i = 3; i >= 0; i--)
92 | os.write(((aesBuf.length & (0xff << 8 * i)) >> 8 * i));
93 | os.write(aesBuf);
94 |
95 | /* write cph_buf */
96 | for (i = 3; i >= 0; i--)
97 | os.write(((cphBuf.length & (0xff << 8 * i)) >> 8 * i));
98 | os.write(cphBuf);
99 |
100 | os.close();
101 | return os;
102 | }
103 | /**
104 | * Read data from an InputStream instead of taking it from a file.
105 | */
106 | public static byte[][] readCpabeData(InputStream is) throws IOException {
107 | int i, len;
108 |
109 | byte[][] res = new byte[3][];
110 | byte[] mBuf, aesBuf, cphBuf;
111 |
112 | /* read m buf */
113 | len = 0;
114 | for (i = 3; i >= 0; i--)
115 | len |= is.read() << (i * 8);
116 | mBuf = new byte[len];
117 | is.read(mBuf);
118 | /* read aes buf */
119 | len = 0;
120 | for (i = 3; i >= 0; i--)
121 | len |= is.read() << (i * 8);
122 | aesBuf = new byte[len];
123 | is.read(aesBuf);
124 |
125 | /* read cph buf */
126 | len = 0;
127 | for (i = 3; i >= 0; i--)
128 | len |= is.read() << (i * 8);
129 | cphBuf = new byte[len];
130 | is.read(cphBuf);
131 |
132 | is.close();
133 | res[0] = aesBuf;
134 | res[1] = cphBuf;
135 | res[2] = mBuf;
136 | return res;
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/src/cscpabe/csCpabe.java:
--------------------------------------------------------------------------------
1 | package cscpabe;
2 |
3 | import java.io.IOException;
4 |
5 | import bswabe.Bswabe;
6 | import bswabe.BswabeCph;
7 | import bswabe.BswabeMsk;
8 | import bswabe.BswabePrv;
9 | import bswabe.BswabePub;
10 | import bswabe.SerializeUtils;
11 | import cscpabe.AESCoder;
12 | import cscpabe.Common;
13 | import it.unisa.dia.gas.jpbc.Element;
14 |
15 | public class csCpabe {
16 |
17 | public void setup(String pubfile, String mskfile, int n) throws IOException,
18 | ClassNotFoundException{
19 | byte[] pub_byte, msk_byte;
20 | BswabePub pub = new BswabePub();
21 | BswabeMsk msk = new BswabeMsk();
22 | Bswabe.Setup(pub, msk, n);
23 |
24 | /* store BswabePub into pubfile */
25 | pub_byte = SerializeUtils.serializeBswabePub(pub);
26 | Common.spitFile(pubfile, pub_byte);
27 |
28 | /* store BswabeMsk into mskfile */
29 | msk_byte = SerializeUtils.serializeBswabeMsk(msk);
30 | Common.spitFile(mskfile, msk_byte);
31 |
32 | }
33 |
34 | public void keyGen(String pubfile, String mskfile, String prvfile, int[] userAttributes) throws IOException{
35 | byte[] pub_byte, msk_byte, prv_byte;
36 | BswabePub pub = new BswabePub();
37 | BswabeMsk msk = new BswabeMsk();
38 |
39 | /* get BswabePub from pubfile */
40 | pub_byte = Common.suckFile(pubfile);
41 | pub = SerializeUtils.unserializeBswabePub(pub_byte);
42 |
43 | /* get BswabeMsk from mskfile */
44 | msk_byte = Common.suckFile(mskfile);
45 | msk = SerializeUtils.unserializeBswabeMsk(pub, msk_byte);
46 |
47 | /* store BswabePrv into prvfile */
48 | BswabePrv prv = Bswabe.KeyGen(pub, msk, userAttributes);
49 | prv_byte = SerializeUtils.serializeBswabePrv(prv);
50 | Common.spitFile(prvfile, prv_byte);
51 | }
52 |
53 | public void encrypt(String pubfile, String inputfile, String encfile, String cphfile,
54 | int[] accessStructure) throws Exception{
55 | byte[] pub_byte, aesBuf, cphBuf, plt;
56 | BswabePub pub = new BswabePub();
57 |
58 | /* get BswabePub from pubfile */
59 | pub_byte = Common.suckFile(pubfile);
60 | pub = SerializeUtils.unserializeBswabePub(pub_byte);
61 |
62 | Element m = pub.pairing.getZr().newRandomElement();
63 | BswabeCph cph = Bswabe.Encrypt(pub, m.toBytes(), accessStructure);
64 |
65 | if (cph == null) {
66 | System.out.println("Error happed in enc");
67 | System.exit(0);
68 | }
69 |
70 | cphBuf = SerializeUtils.bswabeCphSerialize(pub, cph);
71 | Common.spitFile(cphfile, cphBuf);
72 |
73 | /* read file to encrypted */
74 | plt = Common.suckFile(inputfile);
75 | aesBuf = AESCoder.encrypt(m.toBytes(), plt);
76 |
77 | Common.writeCpabeFile(encfile, cphBuf, aesBuf);
78 | }
79 | public void decrypt(String pubfile, String prvfile, String encfile,
80 | String decfile) throws Exception{
81 | byte[] aesBuf, cphBuf;
82 | byte[] plt;
83 | byte[] prv_byte;
84 | byte[] pub_byte;
85 | byte[][] tmp;
86 | BswabeCph cph;
87 | BswabePrv prv;
88 | BswabePub pub;
89 |
90 | /* get BswabePub from pubfile */
91 | pub_byte = Common.suckFile(pubfile);
92 | pub = SerializeUtils.unserializeBswabePub(pub_byte);
93 |
94 | /* read ciphertext */
95 | tmp = Common.readCpabeFile(encfile);
96 | aesBuf = tmp[0];
97 | cphBuf = tmp[1];
98 | cph = SerializeUtils.bswabeCphUnserialize(pub, cphBuf);
99 |
100 | /* get BswabePrv form prvfile */
101 | prv_byte = Common.suckFile(prvfile);
102 | prv = SerializeUtils.unserializeBswabePrv(pub, prv_byte);
103 |
104 | /* decrypt */
105 | byte[] decryptbyte = Bswabe.Decrypt(pub, cph, prv);
106 | plt = AESCoder.decrypt(decryptbyte, aesBuf);
107 | Common.spitFile(decfile, plt);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/gui/GUI.java:
--------------------------------------------------------------------------------
1 | package gui;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.CardLayout;
5 | import java.awt.Color;
6 | import java.awt.Container;
7 | import java.awt.Graphics;
8 | import java.awt.event.ActionEvent;
9 | import java.awt.event.ActionListener;
10 | import java.io.BufferedReader;
11 | import java.io.File;
12 | import java.io.FileReader;
13 | import java.io.IOException;
14 | import java.util.ArrayList;
15 | import java.util.Vector;
16 |
17 | import javax.swing.ImageIcon;
18 | import javax.swing.JButton;
19 | import javax.swing.JFileChooser;
20 | import javax.swing.JFrame;
21 | import javax.swing.JLabel;
22 | import javax.swing.JList;
23 | import javax.swing.JOptionPane;
24 | import javax.swing.JPanel;
25 | import javax.swing.JScrollPane;
26 | import javax.swing.JTextArea;
27 | import javax.swing.JTextField;
28 |
29 | import SEFunction.AttributesGenerate;
30 | import SEFunction.DataOwner;
31 | import SEFunction.DeleteFolder;
32 | import SEFunction.TrustAuthority;
33 | import SEFunction.User;
34 | import jxl.Cell;
35 | import jxl.Sheet;
36 | import jxl.Workbook;
37 | import jxl.read.biff.BiffException;
38 | import jxl.write.WriteException;
39 |
40 | public class GUI{
41 | public static void GraphicUI() throws BiffException, IOException{
42 | //file_dir
43 | String file_dir = "file/";
44 |
45 | String sCloudServer = "CloudServer/";
46 | String sDataOwner = "DataOwner/";
47 | String sUser = "User/";
48 | String sTrustAuthority = "TrustAuthority/";
49 |
50 | String pubkey = "public_key";
51 | String mskkey = "master_key";
52 | String prvkey = "private_key";
53 | String kmkkey = "kmk_key";
54 | String usertuple = "user_file";
55 | String keywordindex = "keyword_file";
56 |
57 | String pubfile = file_dir+sCloudServer+pubkey;
58 | String mskfile = file_dir+sTrustAuthority+mskkey;
59 | String kmkfile = file_dir+sTrustAuthority+kmkkey;
60 |
61 | String RegisterTable = "file/TrustAuthority/RegisterTable.xls";
62 | File RegisterFile = new File(RegisterTable);
63 |
64 | JFrame frame = new JFrame("csCPABE");
65 |
66 | // background picture
67 | String TAimagepath = "image/TAimage.png";
68 | ImageIcon TAbackground = new ImageIcon(TAimagepath);
69 | JLabel TAbackgroundlabel = new JLabel(TAbackground);
70 | TAbackgroundlabel.setBounds(0, 0, TAbackground.getIconWidth(),
71 | TAbackground.getIconHeight());
72 |
73 | frame.getLayeredPane().add(TAbackgroundlabel, new Integer(Integer.MIN_VALUE));
74 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
75 | frame.setSize(960, 560);
76 | frame.setResizable(false);
77 | frame.setVisible(true);
78 |
79 | CardLayout card = new CardLayout();
80 |
81 |
82 |
83 | // 不需要有cloud server, proxy server
84 | // 這兩個只會被動執行
85 | JPanel MainPanel = new JPanel();
86 | JPanel ButtonPanel = new JPanel();
87 | JPanel AccountPanel = new JPanel();
88 |
89 |
90 | //JButton TAButton = new JButton("Trust Authority");
91 | JButton USButton = new JButton("User");
92 | JButton DOButton = new JButton("Data Owner");
93 |
94 |
95 | JButton DestroyButton = new JButton("BOOM!!!");
96 |
97 | MainPanel.setLayout(card);
98 |
99 | // AccountPanel
100 | JLabel AccountLabel = new JLabel("Account");
101 | JLabel UidLabel = new JLabel("-1");
102 | AccountLabel.setVisible(false);
103 | UidLabel.setVisible(false);
104 | AccountPanel.add(AccountLabel);
105 | AccountPanel.add(UidLabel);
106 | AccountPanel.setVisible(false);
107 |
108 | // NewUserGrantPanel
109 | // background picture
110 | String NUGimagepath = "image/newusergrantimage.png";
111 | ImageIcon NUGbackground = new ImageIcon(NUGimagepath);
112 |
113 | JPanel NewUserGrantPanel = new JPanel(){
114 | /**
115 | *
116 | */
117 | private static final long serialVersionUID = 1L;
118 |
119 | public void paintComponent(Graphics g) {
120 | g.drawImage(NUGbackground.getImage(), 0, 0, this);
121 | }
122 | };
123 | NewUserGrantPanel.setLayout(null);
124 | JTextArea acArea = new JTextArea();
125 | acArea.setFont(new java.awt.Font("Dialog", 1, 40));
126 | acArea.setForeground(Color.WHITE);
127 | acArea.setOpaque(false);
128 | acArea.setSize(600, 50);
129 | acArea.setBounds(300, 60, 600, 50);
130 | JTextArea paArea = new JTextArea();
131 | paArea.setFont(new java.awt.Font("Dialog", 1, 40));
132 | paArea.setForeground(Color.WHITE);
133 | paArea.setOpaque(false);
134 | paArea.setSize(585, 50);
135 | paArea.setBounds(315, 150, 585, 50);
136 | JTextArea idArea = new JTextArea();
137 | idArea.setFont(new java.awt.Font("Dialog", 1, 40));
138 | idArea.setForeground(Color.WHITE);
139 | idArea.setOpaque(false);
140 | idArea.setSize(640, 50);
141 | idArea.setBounds(260, 230, 640, 50);
142 | JTextArea atArea = new JTextArea();
143 | atArea.setFont(new java.awt.Font("Dialog", 1, 40));
144 | atArea.setForeground(Color.WHITE);
145 | atArea.setOpaque(false);
146 | atArea.setSize(570, 50);
147 | atArea.setBounds(330, 320, 570, 50);
148 | NewUserGrantPanel.add(acArea);
149 | NewUserGrantPanel.add(paArea);
150 | NewUserGrantPanel.add(idArea);
151 | NewUserGrantPanel.add(atArea);
152 |
153 | // home button
154 | JButton NUGHomeButton = new JButton();
155 | NUGHomeButton.setSize(165,85);
156 | NUGHomeButton.setBounds(760, 445, 165, 85);
157 | NUGHomeButton.setContentAreaFilled(false);
158 | NUGHomeButton.setBorderPainted(false);
159 | NUGHomeButton.addActionListener(new ActionListener(){
160 |
161 | @Override
162 | public void actionPerformed(ActionEvent e) {
163 | card.show(MainPanel, "TA");
164 | acArea.setText("");
165 | paArea.setText("");
166 | idArea.setText("");
167 | atArea.setText("");
168 | }
169 |
170 | });
171 | NewUserGrantPanel.add(NUGHomeButton);
172 |
173 | JButton NewUserConfirmButton = new JButton();
174 | NewUserConfirmButton.setSize(165, 85);
175 | NewUserConfirmButton.setBounds(500, 445, 165, 85);
176 | NewUserConfirmButton.setContentAreaFilled(false);
177 | NewUserConfirmButton.setBorderPainted(false);
178 | NewUserGrantPanel.add(NewUserConfirmButton);
179 |
180 | NewUserConfirmButton.addActionListener(new ActionListener(){
181 |
182 | @Override
183 | public void actionPerformed(ActionEvent e) {
184 | String sUid = idArea.getText();
185 | String attri = atArea.getText();
186 | String[] attr = attri.split(",");
187 | if(sUid.length()==0){
188 | JOptionPane.showMessageDialog(null, "Please input Uid", "Error", JOptionPane.INFORMATION_MESSAGE );
189 | }else{
190 | int Uid = Integer.parseInt(sUid);
191 | try {
192 | int[] userA = AttributesGenerate.AttributesGen(attr);
193 | TrustAuthority.NewUserGrant(pubfile, mskfile, kmkfile, file_dir+sUser , userA, Uid);
194 | TrustAuthority.UserRegister(acArea.getText(), paArea.getText(), idArea.getText());
195 | JOptionPane.showMessageDialog(null, "Done!", "Done!", JOptionPane.INFORMATION_MESSAGE );
196 | } catch (WriteException | BiffException | IOException e1) {
197 | e1.printStackTrace();
198 | }
199 | }
200 |
201 | }
202 |
203 | });
204 |
205 | // User Revocation Panel
206 | String URimagepath = "image/userrevocationimage.png";
207 | ImageIcon URbackground = new ImageIcon(URimagepath);
208 |
209 | JPanel UserRevocationPanel = new JPanel(){
210 | /**
211 | *
212 | */
213 | private static final long serialVersionUID = 1L;
214 |
215 | public void paintComponent(Graphics g) {
216 | g.drawImage(URbackground.getImage(), 0, 0, this);
217 | }
218 | };
219 | UserRevocationPanel.setLayout(null);
220 | JTextArea acArea2 = new JTextArea();
221 | JTextArea idArea2 = new JTextArea();
222 | UserRevocationPanel.add(acArea2);
223 | acArea2.setFont(new java.awt.Font("Dialog", 1, 40));
224 | acArea2.setForeground(Color.WHITE);
225 | acArea2.setOpaque(false);
226 | acArea2.setSize(600, 50);
227 | acArea2.setBounds(300, 60, 600, 50);
228 | UserRevocationPanel.add(idArea2);
229 | idArea2.setFont(new java.awt.Font("Dialog", 1, 40));
230 | idArea2.setForeground(Color.WHITE);
231 | idArea2.setOpaque(false);
232 | idArea2.setSize(640, 50);
233 | idArea2.setBounds(260, 230, 640, 50);
234 |
235 | // home button
236 | JButton URHomeButton = new JButton();
237 | URHomeButton.setSize(165,85);
238 | URHomeButton.setBounds(760, 445, 165, 85);
239 | URHomeButton.setContentAreaFilled(false);
240 | URHomeButton.setBorderPainted(false);
241 | URHomeButton.addActionListener(new ActionListener(){
242 |
243 | @Override
244 | public void actionPerformed(ActionEvent e) {
245 | card.show(MainPanel, "TA");
246 | acArea2.setText("");
247 | idArea2.setText("");
248 | }
249 |
250 | });
251 | UserRevocationPanel.add(URHomeButton);
252 |
253 | JButton UserRevocationConfirm = new JButton();
254 | UserRevocationConfirm.setSize(165, 85);
255 | UserRevocationConfirm.setBounds(500, 445, 165, 85);
256 | UserRevocationConfirm.setContentAreaFilled(false);
257 | UserRevocationConfirm.setBorderPainted(false);
258 | UserRevocationPanel.add(UserRevocationConfirm);
259 |
260 | UserRevocationConfirm.addActionListener(new ActionListener(){
261 |
262 | @Override
263 | public void actionPerformed(ActionEvent e) {
264 | String sUid = idArea2.getText();
265 | String account = acArea2.getText();
266 | if(sUid.length()==0){
267 | JOptionPane.showMessageDialog(null, "Please input Uid", "Error", JOptionPane.INFORMATION_MESSAGE );
268 | }else{
269 | int Uid = Integer.parseInt(sUid);
270 | try {
271 | TrustAuthority.UserRevocation(Uid);
272 | TrustAuthority.UserRevocationRegister(account);
273 | JOptionPane.showMessageDialog(null, "Done!", "Done!", JOptionPane.INFORMATION_MESSAGE );
274 | } catch (BiffException | WriteException | IOException e1) {
275 | e1.printStackTrace();
276 | }
277 | }
278 | }
279 |
280 | });
281 |
282 | // TA Panel
283 | JPanel TAPanel = new JPanel();
284 | JButton NewUserGrantButton = new JButton();
285 | NewUserGrantButton.setSize(775,125);
286 | NewUserGrantButton.setBounds(65, 100, 775, 125);
287 | NewUserGrantButton.setOpaque(false);
288 | JButton UserRevocationButton = new JButton();
289 | UserRevocationButton.setSize(775, 125);
290 | UserRevocationButton.setBounds(65, 300, 775, 125);
291 | UserRevocationButton.setOpaque(false);
292 | TAPanel.setLayout(null);
293 | TAPanel.add(TAbackgroundlabel, new Integer(Integer.MIN_VALUE));
294 |
295 | TAPanel.add(NewUserGrantButton);
296 | TAPanel.add(UserRevocationButton);
297 |
298 |
299 | // system setup button (for test don't use now)
300 | JButton SystemSetupButton = new JButton("System Setup");
301 | SystemSetupButton.addActionListener(new ActionListener(){
302 |
303 | @Override
304 | public void actionPerformed(ActionEvent e) {
305 | int Nsize = AttributesGenerate.NSize();
306 | try {
307 | TrustAuthority.SystemSetup(pubfile, mskfile, kmkfile, Nsize);
308 | } catch (ClassNotFoundException | WriteException | IOException e1) {
309 | e1.printStackTrace();
310 | }
311 | }
312 |
313 | });
314 |
315 | NewUserGrantButton.addActionListener(new ActionListener(){
316 |
317 | @Override
318 | public void actionPerformed(ActionEvent e) {
319 | card.show(MainPanel, "NewUserGrant");
320 | }
321 |
322 | });
323 |
324 | UserRevocationButton.addActionListener(new ActionListener(){
325 |
326 | @Override
327 | public void actionPerformed(ActionEvent e) {
328 | card.show(MainPanel, "UserRevocation");
329 | }
330 |
331 | });
332 |
333 | // DO Panel
334 | // background picture
335 | String DOimagepath = "image/DOimage.png";
336 | ImageIcon DObackground = new ImageIcon(DOimagepath);
337 |
338 | JPanel DOPanel = new JPanel(){
339 | /**
340 | *
341 | */
342 | private static final long serialVersionUID = 1L;
343 |
344 | public void paintComponent(Graphics g) {
345 | g.drawImage(DObackground.getImage(), 0, 0, this);
346 | //super.paintComponents(g);
347 | }
348 | };
349 | JButton SelectFileButton = new JButton();
350 | SelectFileButton.setSize(300, 80);
351 | SelectFileButton.setBounds(10, 60, 300, 80);
352 | SelectFileButton.setContentAreaFilled(false);
353 | SelectFileButton.setBorderPainted(false);
354 | JLabel FileName = new JLabel("");
355 | FileName.setSize(560, 50);
356 | FileName.setBounds(340, 80, 560, 50);
357 | FileName.setFont(new java.awt.Font("Dialog", 1, 40));
358 | FileName.setForeground(Color.WHITE);
359 | FileName.setOpaque(false);
360 | JTextArea KeywordArea = new JTextArea();
361 | KeywordArea.setSize(600, 50);
362 | KeywordArea.setBounds(300, 200, 600, 50);
363 | KeywordArea.setFont(new java.awt.Font("Dialog", 1, 40));
364 | KeywordArea.setForeground(Color.WHITE);
365 | KeywordArea.setOpaque(false);
366 | JTextArea AccessInputArea = new JTextArea();
367 | AccessInputArea.setSize(585, 50);
368 | AccessInputArea.setBounds(315, 335, 585, 50);
369 | AccessInputArea.setFont(new java.awt.Font("Dialog", 1, 40));
370 | AccessInputArea.setForeground(Color.WHITE);
371 | AccessInputArea.setOpaque(false);
372 | JButton DataUploadButton = new JButton();
373 | DataUploadButton.setSize(165, 85);
374 | DataUploadButton.setBounds(500, 445, 165, 85);
375 | DataUploadButton.setContentAreaFilled(false);
376 | DataUploadButton.setBorderPainted(false);
377 | DOPanel.setLayout(null);
378 | DOPanel.add(SelectFileButton);
379 | DOPanel.add(FileName);
380 | DOPanel.add(KeywordArea);
381 | DOPanel.add(AccessInputArea);
382 | DOPanel.add(DataUploadButton);
383 |
384 | // home button
385 | JButton DOHomeButton = new JButton();
386 | DOHomeButton.setSize(165,85);
387 | DOHomeButton.setBounds(760, 445, 165, 85);
388 | DOHomeButton.setContentAreaFilled(false);
389 | DOHomeButton.setBorderPainted(false);
390 | DOHomeButton.addActionListener(new ActionListener(){
391 |
392 | @Override
393 | public void actionPerformed(ActionEvent e) {
394 | card.show(MainPanel, "US");
395 | FileName.setText("");
396 | KeywordArea.setText("");
397 | AccessInputArea.setText("");
398 | }
399 |
400 | });
401 | DOPanel.add(DOHomeButton);
402 |
403 | JTextField FilePath = new JTextField();
404 |
405 | SelectFileButton.addActionListener(new ActionListener(){
406 |
407 | @Override
408 | public void actionPerformed(ActionEvent e) {
409 | JFileChooser fileChooser = new JFileChooser();//宣告filechooser
410 | int returnValue = fileChooser.showOpenDialog(null);//叫出filechooser
411 | if (returnValue == JFileChooser.APPROVE_OPTION){
412 | File selectedFile = fileChooser.getSelectedFile();//指派給File
413 | FileName.setText(selectedFile.getName());
414 | FilePath.setText(selectedFile.getAbsolutePath());
415 | }
416 | }
417 |
418 | });
419 |
420 | DataUploadButton.addActionListener(new ActionListener(){
421 |
422 | @Override
423 | public void actionPerformed(ActionEvent e) {
424 | // compute time
425 | long time1, time2;
426 | time1 = System.currentTimeMillis();
427 |
428 | String AreaString = KeywordArea.getText();
429 | String[] keywordarray = {};
430 | String accessStructure = AccessInputArea.getText();
431 | String[] aStructure = accessStructure.split(",");
432 | int[] accessP = AttributesGenerate.AttributesGen(aStructure);
433 | boolean run = true;
434 | if(AreaString.length()==0){
435 | // 沒輸入關鍵字
436 | run = false;
437 | JOptionPane.showMessageDialog(null, "Please input keyword", "Error", JOptionPane.INFORMATION_MESSAGE );
438 | }else{
439 | keywordarray = AreaString.split(",");
440 | }
441 |
442 | if(accessStructure.length()==0){
443 | run = false;
444 | JOptionPane.showMessageDialog(null, "Please input access structure", "Error", JOptionPane.INFORMATION_MESSAGE );
445 | }
446 |
447 | String sUid = UidLabel.getText();
448 | int Uid = Integer.parseInt(sUid);
449 | String inputname = FileName.getText();
450 |
451 | if(inputname.equals("")){
452 | run = false;
453 | JOptionPane.showMessageDialog(null, "Please choose the file", "Error", JOptionPane.INFORMATION_MESSAGE );
454 | }
455 | if(run){
456 | String cphname = inputname+"_file";
457 | String encname = inputname+".cpabe";
458 | String userfile = file_dir+sUser+Uid+"/"+usertuple;
459 | String inputpath = FilePath.getText();
460 | File checkuid = new File(userfile);
461 | if(checkuid.exists()){
462 | try {
463 | DataOwner.DataUpload(pubfile, userfile, file_dir+sCloudServer , file_dir+sDataOwner,
464 | inputpath, inputname, encname, cphname, keywordindex, accessP, keywordarray);
465 | JOptionPane.showMessageDialog(null, "Done!", "Done!", JOptionPane.INFORMATION_MESSAGE );
466 | } catch (Exception e1) {
467 | e1.printStackTrace();
468 | }
469 | }else{
470 | JOptionPane.showMessageDialog(null, "You are not user", "Error", JOptionPane.INFORMATION_MESSAGE );
471 | }
472 |
473 | }
474 | time2 = System.currentTimeMillis();
475 | System.out.println("Data Upload cost:" + (time2-time1) + "ms");
476 | }
477 |
478 | });
479 |
480 | // Decrypt Panel
481 | // background picture
482 | String Decryptimagepath = "image/decryptimage.png";
483 | ImageIcon Decryptbackground = new ImageIcon(Decryptimagepath);
484 | JPanel DecryptPanel = new JPanel(){
485 | /**
486 | *
487 | */
488 | private static final long serialVersionUID = 1L;
489 |
490 | public void paintComponent(Graphics g) {
491 | g.drawImage(Decryptbackground.getImage(), 0, 0, this);
492 | //super.paintComponents(g);
493 | }
494 | };
495 | DecryptPanel.setLayout(null);
496 | Vector SearchResultNameVector = new Vector();
497 | Vector SearchResultPathVector = new Vector();
498 | JList SearchResultList = new JList(SearchResultNameVector);
499 | SearchResultList.setSize(960, 400);
500 | SearchResultList.setBounds(0, 0, 960, 400);
501 | SearchResultList.setFont(new java.awt.Font("Dialog", 0, 20));
502 | SearchResultList.setForeground(Color.WHITE);
503 | SearchResultList.setOpaque(false);
504 | ((JLabel)SearchResultList.getCellRenderer()).setOpaque(false);
505 | SearchResultList.setSelectionForeground(Color.RED);
506 | JScrollPane SearchResultScroll = new JScrollPane(SearchResultList);
507 | SearchResultScroll.setSize(960, 400);
508 | SearchResultScroll.setBounds(0, 0, 960, 400);
509 | SearchResultScroll.setOpaque(false);
510 | SearchResultScroll.getViewport().setOpaque(false);
511 | DecryptPanel.add(SearchResultScroll);
512 | JButton DecryptConfirm = new JButton();
513 | DecryptConfirm.setSize(165, 85);
514 | DecryptConfirm.setBounds(500, 445, 165, 85);
515 | DecryptConfirm.setContentAreaFilled(false);
516 | DecryptConfirm.setBorderPainted(false);
517 | DecryptPanel.add(DecryptConfirm);
518 |
519 | // home button
520 | JButton DecryptHomeButton = new JButton();
521 | DecryptHomeButton.setSize(165,85);
522 | DecryptHomeButton.setBounds(760, 445, 165, 85);
523 | DecryptHomeButton.setContentAreaFilled(false);
524 | DecryptHomeButton.setBorderPainted(false);
525 | DecryptPanel.add(DecryptHomeButton);
526 | DecryptHomeButton.addActionListener(new ActionListener(){
527 |
528 | @Override
529 | public void actionPerformed(ActionEvent e) {
530 | card.show(MainPanel, "US");
531 | SearchResultPathVector.clear();
532 | SearchResultNameVector.clear();
533 | }
534 |
535 | });
536 |
537 | DecryptConfirm.addActionListener(new ActionListener(){
538 |
539 | @Override
540 | public void actionPerformed(ActionEvent e) {
541 |
542 | String sUid = UidLabel.getText();
543 | int Uid = Integer.parseInt(sUid);
544 | String prvfile = file_dir+sUser+Uid+"/"+prvkey;
545 | String decfiledir = file_dir+sUser+Uid+"/";
546 |
547 | // 找出所選擇的index
548 | int[] Idx = SearchResultList.getSelectedIndices();
549 | String[] SelectPath = new String[Idx.length];
550 | String[] SelectName = new String[Idx.length];
551 | for(int i=0; i KeywordList = new ArrayList();
620 | ArrayList AndOrList = new ArrayList();
621 | // 1 -> And 2 -> Or
622 |
623 | // home button
624 | JButton SearchHomeButton = new JButton();
625 | SearchHomeButton.setSize(165,85);
626 | SearchHomeButton.setBounds(760, 445, 165, 85);
627 | SearchHomeButton.setContentAreaFilled(false);
628 | SearchHomeButton.setBorderPainted(false);
629 | SearchPanel.add(SearchHomeButton);
630 | SearchHomeButton.addActionListener(new ActionListener(){
631 |
632 | @Override
633 | public void actionPerformed(ActionEvent e) {
634 | card.show(MainPanel, "US");
635 | KeywordList.clear();
636 | AndOrList.clear();
637 | KeywordToSearch.setText("");
638 | }
639 |
640 | });
641 |
642 | SearchConfirm.addActionListener(new ActionListener(){
643 |
644 | @Override
645 | public void actionPerformed(ActionEvent e) {
646 | // 計算時間
647 | long time1, time2;
648 | time1 = System.currentTimeMillis();
649 | // Search 結束跳decrypt頁面
650 | String AreaString = KeywordToSearch.getText();
651 | String sUid = UidLabel.getText();
652 | if(AreaString.length()==0){
653 | JOptionPane.showMessageDialog(null, "Please input keyword", "Error", JOptionPane.INFORMATION_MESSAGE );
654 | }else{
655 | int Uid = Integer.parseInt(sUid);
656 | String userfile = file_dir+sUser+Uid+"/"+usertuple;
657 | String prvfile = file_dir+sUser+Uid+"/"+prvkey;
658 | String decfiledir = file_dir+sUser+Uid+"/";
659 | File checkuid = new File(userfile);
660 | if(checkuid.exists()){
661 | try {
662 | if(AndOrList.size()==0){
663 | User.TrapdoorGenUser(pubfile, userfile, prvfile, decfiledir,AreaString);
664 | }else{
665 | KeywordList.add(AreaString);
666 | User.UserAndOrSearch(KeywordList, AndOrList, pubfile, userfile, prvfile, decfiledir);
667 | }
668 |
669 | time2 = System.currentTimeMillis();
670 | System.out.println("search cost:" + (time2-time1) + "ms");
671 |
672 | boolean SearchCheck = User.CheckSearch(decfiledir);
673 | if(SearchCheck){
674 | String SearchResultFilepath= decfiledir+"SearchResultFilepath.txt";
675 | FileReader fr = new FileReader(SearchResultFilepath);
676 | BufferedReader br = new BufferedReader(fr);
677 | String SearchResultName = decfiledir + "SearchResultName.txt";
678 | FileReader fr2 = new FileReader(SearchResultName);
679 | BufferedReader br2 = new BufferedReader(fr2);
680 | while(br.ready() && br2.ready()){
681 | String path = br.readLine();
682 | SearchResultPathVector.addElement(path);
683 | String name = br2.readLine();
684 | SearchResultNameVector.addElement(name);
685 | }
686 | br.close();
687 | br2.close();
688 | SearchResultList.setListData(SearchResultNameVector);
689 | card.show(MainPanel, "Decrypt");
690 | KeywordList.clear();
691 | AndOrList.clear();
692 | KeywordToSearch.setText("");
693 | //User.FileDecryption(pubfile, prvfile, decfiledir);
694 | }else{
695 | JOptionPane.showMessageDialog(null, "Can't find result", "Error", JOptionPane.INFORMATION_MESSAGE );
696 | }
697 | } catch (Exception e1) {
698 | e1.printStackTrace();
699 | }
700 | }else{
701 | JOptionPane.showMessageDialog(null, "You are not user", "Error", JOptionPane.INFORMATION_MESSAGE );
702 | }
703 |
704 | }
705 | }
706 |
707 | });
708 |
709 | AndButton.addActionListener(new ActionListener(){
710 |
711 | @Override
712 | public void actionPerformed(ActionEvent e) {
713 | String AreaString = KeywordToSearch.getText();
714 | if(AreaString.length()==0){
715 | JOptionPane.showMessageDialog(null, "Please input keyword", "Error", JOptionPane.INFORMATION_MESSAGE );
716 | }else{
717 | KeywordList.add(AreaString);
718 | AndOrList.add(1);
719 | KeywordToSearch.setText("");
720 | }
721 | }
722 |
723 | });
724 |
725 | OrButton.addActionListener(new ActionListener(){
726 |
727 | @Override
728 | public void actionPerformed(ActionEvent e) {
729 | String AreaString = KeywordToSearch.getText();
730 | if(AreaString.length()==0){
731 | JOptionPane.showMessageDialog(null, "Please input keyword", "Error", JOptionPane.INFORMATION_MESSAGE );
732 | }else{
733 | KeywordList.add(AreaString);
734 | AndOrList.add(2);
735 | KeywordToSearch.setText("");
736 | }
737 |
738 | }
739 |
740 | });
741 |
742 | BackButton.addActionListener(new ActionListener(){
743 |
744 | @Override
745 | public void actionPerformed(ActionEvent e) {
746 | int theSize = KeywordList.size();
747 | if(theSize==0){
748 | JOptionPane.showMessageDialog(null, "Nothing to delete", "Error", JOptionPane.INFORMATION_MESSAGE );
749 | }else{
750 | String keyword = KeywordList.get(theSize-1);
751 | KeywordToSearch.setText(keyword);
752 | KeywordList.remove(theSize-1);
753 | AndOrList.remove(theSize-1);
754 | }
755 |
756 |
757 | }
758 |
759 | });
760 |
761 | // US panel
762 | // background picture
763 | String USimagepath = "image/USimage.png";
764 | ImageIcon USbackground = new ImageIcon(USimagepath);
765 |
766 | JPanel USPanel = new JPanel(){
767 | /**
768 | *
769 | */
770 | private static final long serialVersionUID = 1L;
771 |
772 | public void paintComponent(Graphics g) {
773 | g.drawImage(USbackground.getImage(), 0, 0, this);
774 | }
775 | };
776 | JButton DataOwnerButton = new JButton();
777 | DataOwnerButton.setSize(775,125);
778 | DataOwnerButton.setBounds(45, 50, 775, 125);
779 | DataOwnerButton.setContentAreaFilled(false);
780 | DataOwnerButton.setBorderPainted(false);
781 | JButton SearchButton = new JButton();
782 | SearchButton.setSize(775, 125);
783 | SearchButton.setBounds(45, 240, 775, 125);
784 | SearchButton.setContentAreaFilled(false);
785 | SearchButton.setBorderPainted(false);
786 | USPanel.setLayout(null);
787 | USPanel.add(DataOwnerButton);
788 | USPanel.add(SearchButton);
789 |
790 | SearchButton.addActionListener(new ActionListener(){
791 |
792 | @Override
793 | public void actionPerformed(ActionEvent e) {
794 | card.show(MainPanel, "Search");
795 | }
796 |
797 | });
798 |
799 | DataOwnerButton.addActionListener(new ActionListener(){
800 |
801 | @Override
802 | public void actionPerformed(ActionEvent e) {
803 | card.show(MainPanel, "DO");
804 | }
805 |
806 | });
807 |
808 | JPanel LoginFail = new JPanel();
809 | JLabel LoginFailLabel = new JLabel("Login fail");
810 | LoginFail.add(LoginFailLabel);
811 |
812 | Container contentPane = frame.getContentPane();
813 |
814 | ButtonPanel.add(DestroyButton);
815 |
816 | MainPanel.add(TAPanel,"TA");
817 | MainPanel.add(USPanel,"US");
818 | MainPanel.add(DOPanel,"DO");
819 | MainPanel.add(NewUserGrantPanel,"NewUserGrant");
820 | MainPanel.add(UserRevocationPanel,"UserRevocation");
821 | MainPanel.add(SearchPanel,"Search");
822 | MainPanel.add(LoginFail,"LoginFail");
823 | MainPanel.add(DecryptPanel,"Decrypt");
824 |
825 | USButton.addActionListener(new ActionListener(){
826 |
827 | @Override
828 | public void actionPerformed(ActionEvent e) {
829 | card.show(MainPanel, "US");
830 | }
831 |
832 | });
833 | DOButton.addActionListener(new ActionListener(){
834 |
835 | @Override
836 | public void actionPerformed(ActionEvent e) {
837 | card.show(MainPanel, "DO");
838 | }
839 |
840 | });
841 | DestroyButton.addActionListener(new ActionListener(){
842 |
843 | @Override
844 | public void actionPerformed(ActionEvent e) {
845 | DeleteFolder.delFolder(file_dir);
846 | }
847 |
848 | });
849 |
850 | int mType = JOptionPane.INFORMATION_MESSAGE;
851 |
852 |
853 | // 讀帳號 判斷有沒有這個帳號以及是否是受信任的第三方
854 | int Uid = -1;
855 | String account = "";
856 | if(!RegisterFile.exists()){
857 | JOptionPane.showMessageDialog(null, "Setup First", "Warning", JOptionPane.INFORMATION_MESSAGE );
858 | int Nsize = AttributesGenerate.NSize();
859 | try {
860 | TrustAuthority.SystemSetup(pubfile, mskfile, kmkfile, Nsize);
861 | } catch (ClassNotFoundException | WriteException | IOException e1) {
862 | e1.printStackTrace();
863 | }
864 | }else{
865 | Workbook book=Workbook.getWorkbook(new File(RegisterTable));
866 | Sheet sheet=book.getSheet(0);
867 | int raw = sheet.getRows();
868 | int index = 0;
869 | boolean accountfound = false;
870 | account = JOptionPane.showInputDialog(frame,"Please input account","Account",mType);
871 | while(!accountfound && index