joesoc / plexi

Automatically exported from code.google.com/p/plexi
Apache License 2.0
0 stars 0 forks source link

Error 403: Forbidden #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Copy the FileSystemAdaptor
2. Add the jar with libraries
3. Run

What is the expected output? What do you see instead?
I am expecting to see my file however the browser returns 403: unauthorized.

The line resulting in this error: DocumentHandler.class 

Line 220:
if (!authzed(ex, docId)) {
        return;
}

Line 269: 
else if (authzAuthority == null) {
      HttpExchanges.cannedRespond(ex, HttpURLConnection.HTTP_FORBIDDEN,
          Translation.HTTP_FORBIDDEN);
      return false;
}

authzAuthority is indeed null, however how do I set this? 

What version of the product are you using? On what operating system?
4.0.3

Original issue reported on code.google.com by robbert....@gmail.com on 29 Aug 2014 at 10:17

GoogleCodeExporter commented 9 years ago
EDIT: Found the answer: 

The adaptor can implement the interface AuthzAuthority

In the init you need to bind the adaptor (or AuthzAuthority class) to the 
context.
    @Override
    public void init(AdaptorContext context) throws Exception {
        // Process configuration.
        ...
        AuthzAuthority authzAuthority = this;
        context.setAuthzAuthority(authzAuthority);

        s....
    }

isUserAuthorised adds the logic for authentication:

    @Override
    public Map<DocId, AuthzStatus> isUserAuthorized(AuthnIdentity identity, Collection<DocId> ids) {
        Map<DocId, AuthzStatus> result = new HashMap<DocId, AuthzStatus>(ids.size() * 2);
        for (DocId id : ids) {
            result.put(id, AuthzStatus.PERMIT);
        }
        return Collections.unmodifiableMap(result);
    }

Original comment by robbert....@gmail.com on 29 Aug 2014 at 10:38