1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.miloss.fgsms.presentation;
23
24 import java.security.Principal;
25 import java.util.HashSet;
26 import java.util.Set;
27 import javax.xml.namespace.QName;
28 import javax.xml.ws.handler.MessageContext;
29 import javax.xml.ws.handler.soap.SOAPHandler;
30 import javax.xml.ws.handler.soap.SOAPMessageContext;
31 import org.miloss.fgsms.common.Constants;
32
33
34
35
36
37
38 public class PKIHandler implements SOAPHandler<SOAPMessageContext> {
39
40 public PKIHandler() {
41 }
42
43 public PKIHandler(Principal user) {
44 this.user = user;
45 }
46 private Principal user = null;
47
48 public Set<QName> getHeaders() {
49 return new HashSet<QName>();
50 }
51
52 public boolean handleMessage(SOAPMessageContext messageContext) {
53 Boolean isOutbound = (Boolean) messageContext.get(messageContext.MESSAGE_OUTBOUND_PROPERTY);
54
55 if (isOutbound) {
56
57 try {
58 ProcessOutboundMessage(messageContext);
59 } catch (Exception ex) {
60
61 return true;
62 }
63 } else {
64 }
65
66 return true;
67 }
68
69 public boolean handleFault(SOAPMessageContext context) {
70 return true;
71 }
72
73 public void close(MessageContext context) {
74 }
75
76 private void ProcessOutboundMessage(SOAPMessageContext messageContext) {
77 if (user == null) {
78 return;
79 }
80 messageContext.getMessage().getMimeHeaders().addHeader(org.miloss.fgsms.common.Constants.CAC_DELEGATE_Authorization_Header, user.getName());
81 }
82 }