Search in sources :

Example 1 with Check

use of org.projectnessie.services.authz.Check in project nessie by projectnessie.

the class TreeApiImplWithAuthorization method getAllReferences.

@Override
public ReferencesResponse getAllReferences(ReferencesParams params) {
    ImmutableReferencesResponse.Builder resp = ReferencesResponse.builder();
    BatchAccessChecker check = startAccessCheck();
    List<Reference> refs = super.getAllReferences(params).getReferences().stream().peek(ref -> check.canViewReference(RefUtil.toNamedRef(ref))).collect(Collectors.toList());
    Set<NamedRef> notAllowed = check.check().keySet().stream().map(Check::ref).filter(Objects::nonNull).collect(Collectors.toSet());
    refs.stream().filter(ref -> !notAllowed.contains(RefUtil.toNamedRef(ref))).forEach(resp::addReferences);
    return resp.build();
}
Also used : LogResponse(org.projectnessie.model.LogResponse) Put(org.projectnessie.model.Operation.Put) ServerConfig(org.projectnessie.services.config.ServerConfig) Authorizer(org.projectnessie.services.authz.Authorizer) BatchAccessChecker(org.projectnessie.services.authz.BatchAccessChecker) Reference(org.projectnessie.model.Reference) NessieConflictException(org.projectnessie.error.NessieConflictException) VersionStore(org.projectnessie.versioned.VersionStore) GetReferenceParams(org.projectnessie.api.params.GetReferenceParams) ReferencesParams(org.projectnessie.api.params.ReferencesParams) Merge(org.projectnessie.model.Merge) Type(org.projectnessie.model.Content.Type) Content(org.projectnessie.model.Content) CommitMeta(org.projectnessie.model.CommitMeta) Check(org.projectnessie.services.authz.Check) Nullable(javax.annotation.Nullable) NamedRef(org.projectnessie.versioned.NamedRef) CommitLogParams(org.projectnessie.api.params.CommitLogParams) ReferencesResponse(org.projectnessie.model.ReferencesResponse) Branch(org.projectnessie.model.Branch) Set(java.util.Set) EntriesResponse(org.projectnessie.model.EntriesResponse) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) BranchName(org.projectnessie.versioned.BranchName) List(java.util.List) EntriesParams(org.projectnessie.api.params.EntriesParams) Principal(java.security.Principal) Delete(org.projectnessie.model.Operation.Delete) Operations(org.projectnessie.model.Operations) Transplant(org.projectnessie.model.Transplant) ImmutableReferencesResponse(org.projectnessie.model.ImmutableReferencesResponse) NessieNotFoundException(org.projectnessie.error.NessieNotFoundException) BatchAccessChecker(org.projectnessie.services.authz.BatchAccessChecker) Reference(org.projectnessie.model.Reference) Check(org.projectnessie.services.authz.Check) ImmutableReferencesResponse(org.projectnessie.model.ImmutableReferencesResponse) NamedRef(org.projectnessie.versioned.NamedRef)

Aggregations

Principal (java.security.Principal)1 List (java.util.List)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 CommitLogParams (org.projectnessie.api.params.CommitLogParams)1 EntriesParams (org.projectnessie.api.params.EntriesParams)1 GetReferenceParams (org.projectnessie.api.params.GetReferenceParams)1 ReferencesParams (org.projectnessie.api.params.ReferencesParams)1 NessieConflictException (org.projectnessie.error.NessieConflictException)1 NessieNotFoundException (org.projectnessie.error.NessieNotFoundException)1 Branch (org.projectnessie.model.Branch)1 CommitMeta (org.projectnessie.model.CommitMeta)1 Content (org.projectnessie.model.Content)1 Type (org.projectnessie.model.Content.Type)1 EntriesResponse (org.projectnessie.model.EntriesResponse)1 ImmutableReferencesResponse (org.projectnessie.model.ImmutableReferencesResponse)1 LogResponse (org.projectnessie.model.LogResponse)1 Merge (org.projectnessie.model.Merge)1