use of io.milton.http.Auth in project lobcder by skoulouzis.
the class MiltonFtpFile method isRemovable.
@Override
public boolean isRemovable() {
log.debug("isRemovable: " + getAbsolutePath());
if (r == null)
return false;
if (path.isRoot())
return false;
Auth auth = new Auth(user.getName(), user.getUser());
FtpRequest request = new FtpRequest(Method.DELETE, auth, path.toString());
boolean b = r.authorise(request, Method.DELETE, auth);
log.debug(".. = " + b);
return b;
}
use of io.milton.http.Auth in project lobcder by skoulouzis.
the class RequestAdapter method getAuthorization.
@Override
public Auth getAuthorization() {
if (auth != null) {
return auth;
}
String enc = getRequestHeader(Header.AUTHORIZATION);
if (enc == null) {
return null;
}
if (enc.length() == 0) {
return null;
}
auth = new Auth(enc);
return auth;
}
use of io.milton.http.Auth in project lobcder by skoulouzis.
the class WebDataFileResource method canRedirect.
private boolean canRedirect(Request request) throws SQLException, UnsupportedEncodingException, URISyntaxException, IOException {
if (isInCache()) {
return false;
}
Auth auth = request.getAuthorization();
if (auth == null) {
return false;
}
final String autheader = request.getHeaders().get("authorization");
if (autheader != null) {
final int index = autheader.indexOf(' ');
if (index > 0) {
final String credentials = new String(Base64.decodeBase64(autheader.substring(index).getBytes()), "UTF8");
final String uname = credentials.substring(0, credentials.indexOf(":"));
final String token = credentials.substring(credentials.indexOf(":") + 1);
if (authenticate(uname, token) == null) {
return false;
}
if (!authorise(request, Request.Method.GET, auth)) {
return false;
}
}
}
String userAgent = request.getHeaders().get("user-agent");
if (userAgent == null || userAgent.length() <= 1) {
return false;
}
WebDataFileResource.log.log(Level.FINE, "userAgent: {0}", userAgent);
List<String> nonRedirectableUserAgents = PropertiesHelper.getNonRedirectableUserAgents();
for (String s : nonRedirectableUserAgents) {
if (userAgent.contains(s)) {
return false;
}
}
return true;
}
use of io.milton.http.Auth in project lobcder by skoulouzis.
the class SecurityManagerBasicAuthHandler method authenticate.
@Override
public Object authenticate(Resource resource, Request request) {
log.debug("authenticate");
Auth auth = request.getAuthorization();
Object o = securityManager.authenticate(auth.getUser(), auth.getPassword());
log.debug("result: " + o);
return o;
}
use of io.milton.http.Auth in project lobcder by skoulouzis.
the class SecurityManagerDigestAuthenticationHandler method authenticate.
@Override
public Object authenticate(Resource r, Request request) {
Auth auth = request.getAuthorization();
DigestResponse resp = digestHelper.calculateResponse(auth, securityManager.getRealm(request.getHostHeader()), request.getMethod());
if (resp == null) {
log.debug("requested digest authentication is invalid or incorrectly formatted");
return null;
} else {
Object o = securityManager.authenticate(resp);
return o;
}
}
Aggregations