question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create a Permissions class

See original GitHub issue

To make #1156 less of a mess, create a Permissions class to allow for

  • Type safety - can be parsed from a String instead of an int to avoid octal vs. decimal confusion
  • Compactness - internal representation can still be an int
  • Ease of use - relevant methods on this class instead of using a helper and doing multiple back-and-forth conversions
  • Extendability - should be easy to add operations if/as we need them

Right now we only really need two methods:

/* Parse/validate an octal String (e.g. "755"). */
static Permissions fromString(String octalString);

/* Set the permissions on a TarArchiveEntry. */
void setOnTarArchiveEntry(TarArchiveEntry entry);

but we can decide to add stuff depending on how people want to use the library.

static Permissions fromSet(Set<PosixFilePermission> octalString);

Permissions addPermission(PosixFilePermission permission);

Set<PosixFilePermission> getPermissionSet();

int getPermissionBits();

// etc.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
coollogcommented, Oct 19, 2018

Yea, this class will be user-facing, so getPermissionBits sounds good instead of requiring TarArchiveEntry.

0reactions
TadCordlecommented, Oct 19, 2018

One thing I’m not so thrilled about is that it has a dependency on some particular external library (Apache Commons Compress). May not matter much if this is exclusively for internal usage.

That’s true. I don’t think this class is going to be exclusively for internal usage. It might be worth it to just leave out applyToTarArchiveEntryMode and use getPermissionBits.

Alternatively, we could make it applyToFileMode which would take an int and return an int with the lowest 9 bits set.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Permission Classes in Django REST Framework
This article looks at how to build custom permission classes in Django REST Framework (DRF).
Read more >
Permissions - Django REST framework
The DRY Rest Permissions package provides the ability to define different permissions for individual default and custom actions. This package is made for...
Read more >
Custom Permissions in Django Rest - DEV Community ‍ ‍
When building a web API using DRF, you are directly provided some permissions classes such as AllowAny or IsAuthenticated for example.
Read more >
Create custom permission classes - django - Stack Overflow
Create a custom permission class that subclasses rest_framework.permissions.BasePermission; override has_object_permission() method; Inside the ...
Read more >
Custom Permission Classes in Django Rest Framework
Custom Permission Classes in Django Rest Framework · IsAuthenticated : This class mainly checks if the user has been authenticated or not and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found