1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.wss4j.dom.common;
21
22 import org.apache.wss4j.common.ext.WSSecurityException;
23 import org.apache.wss4j.dom.engine.WSSecurityEngineResult;
24 import org.apache.wss4j.dom.handler.HandlerAction;
25 import org.apache.wss4j.dom.handler.WSHandler;
26 import org.apache.wss4j.dom.handler.RequestData;
27 import org.apache.wss4j.dom.handler.WSHandlerResult;
28 import org.w3c.dom.Document;
29
30 import java.util.HashMap;
31 import java.util.List;
32 import java.util.Map;
33
34
35
36
37
38 public class CustomHandler extends WSHandler {
39
40 private Map<String, Object> optionsMap = new HashMap<>();
41
42 public Object
43 getOption(String key) {
44 return optionsMap.get(key);
45 }
46
47 public void
48 setOption(String key, Object option) {
49 optionsMap.put(key, option);
50 }
51
52 @SuppressWarnings("unchecked")
53 public void
54 setProperty(
55 Object ctx,
56 String key,
57 Object value
58 ) {
59 ((Map<String, Object>)ctx).put(key, value);
60 }
61
62 public Object
63 getProperty(Object ctx, String key) {
64 if (ctx instanceof Map<?,?>) {
65 return ((Map<?,?>)ctx).get(key);
66 }
67 return null;
68 }
69
70 public void
71 setPassword(Object msgContext, String password) {
72 }
73
74 public String
75 getPassword(Object msgContext) {
76 if (msgContext instanceof Map<?,?>) {
77 return (String)((Map<?,?>)msgContext).get("password");
78 }
79 return null;
80 }
81
82 public void send(
83 Document doc,
84 RequestData reqData,
85 List<HandlerAction> actions,
86 boolean request
87 ) throws WSSecurityException {
88 doSenderAction(
89 doc,
90 reqData,
91 actions,
92 request
93 );
94 }
95
96 public void receive(
97 List<Integer> actions,
98 RequestData reqData
99 ) throws WSSecurityException {
100 doReceiverAction(
101 actions,
102 reqData
103 );
104 }
105
106 public void signatureConfirmation(
107 RequestData requestData,
108 WSHandlerResult handlerResults
109 ) throws WSSecurityException {
110 checkSignatureConfirmation(requestData, handlerResults);
111 }
112
113 public boolean checkResults(
114 List<WSSecurityEngineResult> results,
115 List<Integer> actions
116 ) throws WSSecurityException {
117 return checkReceiverResults(results, actions);
118 }
119
120 public boolean checkResultsAnyOrder(
121 List<WSSecurityEngineResult> results,
122 List<Integer> actions
123 ) throws WSSecurityException {
124 return checkReceiverResultsAnyOrder(results, actions);
125 }
126
127
128 }