mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
public gpg key download on management screen
This commit is contained in:
@@ -61,6 +61,7 @@ public abstract class PublicKeyMapper {
|
||||
if (UserPermissions.changePublicKeys(rawGpgKey.getOwner()).isPermitted() && !rawGpgKey.isReadonly()) {
|
||||
linksBuilder.single(Link.link("delete", createDeleteLink(rawGpgKey)));
|
||||
}
|
||||
linksBuilder.single(Link.link("raw", createDownloadLink(rawGpgKey)));
|
||||
return new RawGpgKeyDto(linksBuilder.build());
|
||||
}
|
||||
|
||||
@@ -77,4 +78,11 @@ public abstract class PublicKeyMapper {
|
||||
.parameters(rawGpgKey.getOwner(), rawGpgKey.getId())
|
||||
.href();
|
||||
}
|
||||
|
||||
private String createDownloadLink(RawGpgKey rawGpgKey) {
|
||||
return new LinkBuilder(scmPathInfoStore.get().get(), PublicKeyResource.class)
|
||||
.method("findByIdGpg")
|
||||
.parameters(rawGpgKey.getId())
|
||||
.href();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,9 @@ public class PublicKeyResource {
|
||||
public Response findByIdGpg(@PathParam("id") String id) {
|
||||
Optional<RawGpgKey> byId = store.findById(id);
|
||||
if (byId.isPresent()) {
|
||||
return Response.ok(byId.get().getRaw()).build();
|
||||
return Response.ok(byId.get().getRaw())
|
||||
.header("Content-Disposition", "attachment; filename=\"" + byId.get().getDisplayName() + ".asc\"")
|
||||
.build();
|
||||
}
|
||||
return Response.status(Response.Status.NOT_FOUND).build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user