source: trunk/seguranca/ExpressoCertMail/src/br/gov/serpro/js/Javascript2AppletPassingData.java @ 1035

Revision 1035, 1.4 KB checked in by rafaelraymundo, 15 years ago (diff)

Ticket #558 - Adicionada funcionalidade de assinatura e criptografia de e-mails.

Line 
1package br.gov.serpro.js;
2
3import java.util.HashMap;
4import java.util.Map;
5
6public class Javascript2AppletPassingData {
7
8        private boolean locked = true;
9        private String data = null;
10    private Map<String, String> mapData = null;
11
12        public synchronized String getData() throws InterruptedException{
13                if (isLocked()){
14                        data = null;
15            wait();
16                }
17                lock();
18                //notifyAll();
19                return this.data;
20        }
21
22        public synchronized Map<String, String> getMap() throws InterruptedException{
23                if (isLocked()){
24                        mapData = null;
25            wait();
26                }
27                lock();
28                //notifyAll();
29                return this.mapData;
30        }
31
32        public synchronized void setData(String data){
33                //flag = true;
34                this.data = data;
35                unlock();
36        }
37
38    public synchronized void setData(String operation, String id, String body){
39                //flag = true;
40        if (this.mapData == null) {
41            this.mapData = new HashMap<String, String>();
42        }
43                this.mapData.put("operation", operation);
44        this.mapData.put("ID", id);
45        this.mapData.put("body", body);
46                unlock();
47        }
48
49    public synchronized void setData(String operation, String id, String body, String folder){
50        this.mapData = new HashMap<String, String>();
51        this.mapData.put("folder", folder);
52        this.setData(operation, id, body);
53    }
54
55        public synchronized void unlock(){
56                locked = false;
57                notifyAll();
58        }
59
60        private synchronized void lock(){
61                locked = true;
62        }
63
64        public synchronized boolean isLocked(){
65                return locked;
66        }
67}
Note: See TracBrowser for help on using the repository browser.