Search in sources :

Example 6 with Auth

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;
}
Also used : Auth(io.milton.http.Auth)

Example 7 with Auth

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;
}
Also used : Auth(io.milton.http.Auth)

Example 8 with 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;
}
Also used : Auth(io.milton.http.Auth)

Example 9 with Auth

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;
}
Also used : Auth(io.milton.http.Auth)

Example 10 with Auth

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;
    }
}
Also used : Auth(io.milton.http.Auth)

Aggregations

Auth (io.milton.http.Auth)13 DigestResource (io.milton.resource.DigestResource)2 Request (io.milton.http.Request)1 Response (io.milton.http.Response)1 BadRequestException (io.milton.http.exceptions.BadRequestException)1 NotAuthorizedException (io.milton.http.exceptions.NotAuthorizedException)1 ReplaceableResource (io.milton.resource.ReplaceableResource)1 ServletRequest (javax.servlet.ServletRequest)1 ServletResponse (javax.servlet.ServletResponse)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Timer (org.polymap.core.runtime.Timer)1 DefaultSessionContextProvider (org.polymap.core.runtime.session.DefaultSessionContextProvider)1