Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config-api): agama download endpoint #10463

Merged
merged 34 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d032f6c
fix(config-api): missing scope in spec
pujavs Nov 15, 2024
cb5c3c3
fix(config-api): missing scope in spec
pujavs Nov 15, 2024
de1a91b
feat(Config-api): sync with main
pujavs Nov 18, 2024
b9a9e0f
feat(Config-api): sync with main
pujavs Nov 18, 2024
e4f641a
feat(config-api): server app status
pujavs Nov 20, 2024
cd9e9bf
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Nov 20, 2024
ca630c8
feat(config-api): server app status
pujavs Nov 20, 2024
8ab7baf
feat(config-api): sync with main
pujavs Nov 25, 2024
4d2f38e
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Nov 28, 2024
522ad7b
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Nov 28, 2024
efd19f4
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Dec 2, 2024
bb7c3ad
feat(config-api): agama repo endpoin -wip
pujavs Dec 2, 2024
4a6551f
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Dec 3, 2024
025d794
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Dec 4, 2024
c89db59
feat(config-api): sync with main
pujavs Dec 5, 2024
44238c6
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Dec 5, 2024
eefd842
feat(config-api): agama rep endpoint
pujavs Dec 5, 2024
eea7049
feat(config-api): agama endpoint wip
pujavs Dec 9, 2024
b676b07
:wq!
pujavs Dec 9, 2024
a0c35d4
feat(config-api): implemenetd agama repo endpoint and fixed user pwd …
pujavs Dec 9, 2024
138a0b3
feat(config-api): implemenetd agama repo endpoint and fixed user pwd …
pujavs Dec 9, 2024
e51c234
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Dec 11, 2024
390fcd4
fix(Config-api): user password patch fix
pujavs Dec 11, 2024
f6c232b
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Dec 16, 2024
df6cd30
fix(config-api): user credentials in plain text
pujavs Dec 17, 2024
642c120
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Dec 17, 2024
3b34408
fix(config-api): user password being displayed as clear text
pujavs Dec 17, 2024
7efeed6
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Dec 17, 2024
0b8c85e
fix(config-api): user password being displayed as clear text
pujavs Dec 17, 2024
5b78bd6
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Dec 18, 2024
89f6c52
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Dec 18, 2024
0e94c4d
feat(config-api): agama download
pujavs Dec 19, 2024
5d87875
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Dec 19, 2024
32e0a25
feat(config-api): agama download
pujavs Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 42 additions & 8 deletions jans-config-api/docs/jans-config-api-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,40 @@ paths:
security:
- oauth2:
- https://jans.io/oauth/config/agama.readonly
/api/v1/agama-repo/download:
get:
tags:
- Agama
summary: Download agama project.
description: Download agama project.
operationId: get-agama-project
parameters:
- name: downloadLink
in: query
description: Agama project download Link
schema:
type: string
responses:
"200":
description: Agama project
content:
application/json:
schema:
type: string
format: binary
"204":
description: No Content
"401":
description: Unauthorized
"404":
description: Not Found
"500":
description: InternalServerError
security:
- oauth2:
- https://jans.io/oauth/config/agama-repo.readonly
- https://jans.io/oauth/config/agama-repo.write
- https://jans.io/oauth/config/read-all
/api/v1/agama-repo:
get:
tags:
Expand Down Expand Up @@ -9305,6 +9339,10 @@ components:
type: boolean
whitePagesCanView:
type: boolean
adminCanAccess:
type: boolean
userCanAccess:
type: boolean
adminCanView:
type: boolean
userCanView:
Expand All @@ -9313,10 +9351,6 @@ components:
type: boolean
adminCanEdit:
type: boolean
adminCanAccess:
type: boolean
userCanAccess:
type: boolean
baseDn:
type: string
PatchRequest:
Expand Down Expand Up @@ -10954,10 +10988,10 @@ components:
type: array
items:
type: object
value:
type: object
displayValue:
type: string
value:
type: object
LocalizedString:
type: object
properties:
Expand Down Expand Up @@ -11733,10 +11767,10 @@ components:
ttl:
type: integer
format: int32
opbrowserState:
type: string
persisted:
type: boolean
opbrowserState:
type: string
SessionIdAccessMap:
type: object
properties:
Expand Down
4 changes: 2 additions & 2 deletions jans-config-api/plugins/docs/user-mgt-plugin-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -863,10 +863,10 @@ components:
type: array
items:
type: object
value:
type: object
displayValue:
type: string
value:
type: object
CustomUser:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
import io.jans.configapi.util.ApiConstants;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.*;

import jakarta.inject.Inject;
import static io.jans.as.model.util.Util.escapeLog;

import java.io.IOException;
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
Expand Down Expand Up @@ -68,5 +71,29 @@ public class AgamaRepoResource extends ConfigBaseResource {
public Response getAllAgamaRepositories() {
return Response.ok(agamaRepoService.getAllAgamaRepositories()).build();
}


@Operation(summary = "Download agama project.", description = "Download agama project.", operationId = "get-agama-project", tags = {
"Agama" }, security = @SecurityRequirement(name = "oauth2", scopes = {
ApiAccessConstants.AGAMA_REPO_READ_ACCESS, ApiAccessConstants.AGAMA_REPO_WRITE_ACCESS,
ApiAccessConstants.SUPER_ADMIN_READ_ACCESS }))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Agama project", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = String.class, format = "binary"))),
@ApiResponse(responseCode = "204", description = "No Content"),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "404", description = "Not Found"),
@ApiResponse(responseCode = "500", description = "InternalServerError") })
@GET
@ProtectedApi(scopes = { ApiAccessConstants.AGAMA_REPO_READ_ACCESS }, groupScopes = {
ApiAccessConstants.AGAMA_REPO_WRITE_ACCESS }, superScopes = { ApiAccessConstants.SUPER_ADMIN_READ_ACCESS })
@Produces(MediaType.APPLICATION_JSON)
@Path("/download")
public Response getAgamaProject(
@Parameter(description = "Agama project download Link") @QueryParam(value = "downloadLink") String downloadLink)
throws IOException {
if (logger.isInfoEnabled()) {
logger.info(" Agama Project File downloadLink :{}", escapeLog(downloadLink));
}
return Response.ok(agamaRepoService.getAgamaProject(downloadLink)).build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@

import com.fasterxml.jackson.databind.JsonNode;

import io.jans.as.model.util.Util;
import io.jans.configapi.service.status.StatusCheckerTimer;
import io.jans.util.exception.InvalidAttributeException;

import static io.jans.as.model.util.Util.escapeLog;

import java.io.IOException;
import java.net.URLDecoder;
import java.net.URL;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;

@ApplicationScoped
Expand All @@ -20,5 +31,17 @@ public class AgamaRepoService {
public JsonNode getAllAgamaRepositories() {
return statusCheckerTimer.getAllAgamaRepositories();
}


public byte[] getAgamaProject(String downloadLink) throws IOException {
if (logger.isInfoEnabled()) {
logger.info("Fetch Agama Project File from :{}", escapeLog(downloadLink));
}
if (StringUtils.isBlank(downloadLink)) {
throw new InvalidAttributeException("Agama Project url is null!!!");
}
String url = URLDecoder.decode(downloadLink, Util.UTF8_STRING_ENCODING);
logger.info("Decoded Agama Project url :{}", url);
return Base64.encodeBase64(IOUtils.toByteArray((new URL(url)).openStream()), true);
}

}