XSSProtectionServiceImpl.java
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
*/
package com.day.cq.xss.impl;
import com.adobe.granite.xss.XSSFilter;
import com.day.cq.xss.ProtectionContext;
import com.day.cq.xss.XSSProtectionException;
import com.day.cq.xss.XSSProtectionService;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
@Deprecated
@Component
@Service(value={XSSProtectionService.class})
public class XSSProtectionServiceImpl
implements XSSProtectionService {
@Reference
private XSSFilter filter;
@Override
public void invalidatePolicy(String policyPath) {
}
@Override
public String protectFromXSS(String src) throws XSSProtectionException {
return this.filter.filter(src);
}
@Override
public String protectFromXSS(String src, String policyPath) throws XSSProtectionException {
return this.filter.filter(XSSFilter.DEFAULT_CONTEXT, src, policyPath);
}
private com.adobe.granite.xss.ProtectionContext getContext(ProtectionContext context) {
if (context == ProtectionContext.HTML_HTML_CONTENT) {
return com.adobe.granite.xss.ProtectionContext.HTML_HTML_CONTENT;
}
if (context == ProtectionContext.PLAIN_HTML_CONTENT) {
return com.adobe.granite.xss.ProtectionContext.PLAIN_HTML_CONTENT;
}
return null;
}
@Override
public String protectForContext(ProtectionContext context, String src, String policyPath) throws XSSProtectionException {
return this.filter.filter(this.getContext(context), src, policyPath);
}
@Override
public String protectForContext(ProtectionContext context, String src) throws XSSProtectionException {
return this.filter.filter(this.getContext(context), src, null);
}
protected void bindFilter(XSSFilter xSSFilter) {
this.filter = xSSFilter;
}
protected void unbindFilter(XSSFilter xSSFilter) {
if (this.filter == xSSFilter) {
this.filter = null;
}
}
}