AuthHttpContext.java
3.36 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.servlet.http.HttpServletRequest
* javax.servlet.http.HttpServletResponse
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Deactivate
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.auth.core.AuthenticationSupport
* org.apache.sling.commons.mime.MimeTypeService
* org.osgi.service.http.HttpContext
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.crx.packmgr.impl;
import java.io.IOException;
import java.net.URL;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.auth.core.AuthenticationSupport;
import org.apache.sling.commons.mime.MimeTypeService;
import org.osgi.service.http.HttpContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(immediate=1)
@Service(value={HttpContext.class})
@Property(name="contextId", value={"com.day.crx.packmgr.impl.AuthHttpContext"})
public class AuthHttpContext
implements HttpContext {
private static final Logger log = LoggerFactory.getLogger(AuthHttpContext.class);
public static final String CONTEXT_ID = "com.day.crx.packmgr.impl.AuthHttpContext";
@Reference
private AuthenticationSupport authenticator = null;
@Reference
private MimeTypeService mimeTypeService = null;
@Activate
protected void activate() {
if (this.authenticator == null) {
log.error("Referenced Authentication Support is NULL");
}
}
@Deactivate
protected void deactivate() {
}
public String getMimeType(String name) {
if (this.mimeTypeService == null) {
log.error("MimeTypeService is NULL");
return null;
}
return this.mimeTypeService.getMimeType(name);
}
public URL getResource(String name) {
return null;
}
public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException {
AuthenticationSupport localAuthenticator = this.authenticator;
if (localAuthenticator != null) {
return localAuthenticator.handleSecurity(request, response);
}
response.sendError(503);
response.flushBuffer();
return false;
}
protected void bindAuthenticator(AuthenticationSupport authenticationSupport) {
this.authenticator = authenticationSupport;
}
protected void unbindAuthenticator(AuthenticationSupport authenticationSupport) {
if (this.authenticator == authenticationSupport) {
this.authenticator = null;
}
}
protected void bindMimeTypeService(MimeTypeService mimeTypeService) {
this.mimeTypeService = mimeTypeService;
}
protected void unbindMimeTypeService(MimeTypeService mimeTypeService) {
if (this.mimeTypeService == mimeTypeService) {
this.mimeTypeService = null;
}
}
}