Skip to content

Commit

Permalink
fix(config-api): asset upload config and saml document store changes
Browse files Browse the repository at this point in the history
Signed-off-by: pujavs <[email protected]>
  • Loading branch information
pujavs committed Jan 24, 2025
1 parent b9ab35b commit 6135564
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Listing of custom asset types that each Janssen Server module accepts:

| Path | Asset Type |
|----------------|-------------|
| /opt/jans/jetty/jans-lock/custom-libs | *.jar
| /opt/jans/jetty/jans-lock/custom/libs | *.jar


### KeyCloak-link
Expand All @@ -96,7 +96,7 @@ Listing of custom asset types that each Janssen Server module accepts:

| Path | Asset Type |
|----------------|-------------|
| /opt/jans/jetty/jans-link/custom-libs | *.jar
| /opt/jans/jetty/jans-link/custom/libs | *.jar
| /var/jans/link-snapshots/ | *.txt


Expand Down
16 changes: 8 additions & 8 deletions jans-config-api/docs/jans-config-api-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9339,16 +9339,16 @@ components:
type: boolean
adminCanView:
type: boolean
userCanView:
adminCanEdit:
type: boolean
userCanEdit:
type: boolean
adminCanEdit:
type: boolean
adminCanAccess:
userCanView:
type: boolean
userCanAccess:
type: boolean
adminCanAccess:
type: boolean
whitePagesCanView:
type: boolean
baseDn:
Expand Down Expand Up @@ -11331,14 +11331,14 @@ components:
type: boolean
internal:
type: boolean
locationPath:
type: string
locationType:
type: string
enum:
- ldap
- db
- file
locationPath:
type: string
baseDn:
type: string
ScriptError:
Expand Down Expand Up @@ -11767,10 +11767,10 @@ components:
ttl:
type: integer
format: int32
opbrowserState:
type: string
persisted:
type: boolean
opbrowserState:
type: string
SessionIdAccessMap:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

package io.jans.configapi.plugin.saml.service;

import io.jans.service.document.store.service.DocumentStoreService;
import io.jans.service.document.store.conf.DocumentStoreType;
import io.jans.service.document.store.service.LocalDocumentStoreService;
import io.jans.util.exception.InvalidConfigurationException;
Expand Down Expand Up @@ -38,8 +37,6 @@ public class SamlIdpService {

@Inject
Logger logger;
@Inject
private DocumentStoreService documentStoreService;

@Inject
private LocalDocumentStoreService localDocumentStoreService;
Expand All @@ -58,7 +55,7 @@ public void create() {
}

public boolean isLocalDocumentStoreType() {
return documentStoreService.getProviderType() == DocumentStoreType.LOCAL;
return localDocumentStoreService.getProviderType() == DocumentStoreType.LOCAL;
}

public String saveMetadataFile(String metadataDir, String metadataFileName, String documentStoreModuleName,
Expand All @@ -83,14 +80,13 @@ public String saveMetadataFile(String metadataDir, String metadataFileName, Stri
}

String metadataFile = metadataDir + File.separator + metadataFileName;
logger.info("documentStoreService:{}, metadataFile:{}, localDocumentStoreService:{} ", documentStoreService,
metadataFile, localDocumentStoreService);
logger.info("metadataFile:{}, localDocumentStoreService:{} ", metadataFile, localDocumentStoreService);
try {
String result = documentStoreService.saveDocumentStream(metadataFile, null,
stream, documentStoreModuleName);
String result = localDocumentStoreService.saveDocumentStream(metadataFile, null, stream,
documentStoreModuleName);
logger.info("SAML file saving result:{}", result);

InputStream newFile = documentStoreService.readDocumentAsStream(metadataFile);
InputStream newFile = localDocumentStoreService.readDocumentAsStream(metadataFile);
logger.info("SAML file read newFile:{}", newFile);

if (result != null) {
Expand All @@ -114,16 +110,16 @@ public GluuErrorHandler validateMetadata(String metadataPath)
return new GluuErrorHandler(false, true, validationLog);
}

try (InputStream stream = documentStoreService.readDocumentAsStream(metadataPath)) {
try (InputStream stream = localDocumentStoreService.readDocumentAsStream(metadataPath)) {
return XMLValidator.validateMetadata(stream, samlSchema);
}
}

public boolean renameMetadata(String metadataPath, String destinationMetadataPath) {
logger.debug("Rename metadata file documentStoreService:{},metadataPath:{}, destinationMetadataPath:{}",
documentStoreService, metadataPath, destinationMetadataPath);
localDocumentStoreService, metadataPath, destinationMetadataPath);
try {
return documentStoreService.renameDocument(metadataPath, destinationMetadataPath) != null;
return localDocumentStoreService.renameDocument(metadataPath, destinationMetadataPath) != null;
} catch (Exception ex) {
logger.error("Failed to rename metadata '{}' to '{}'", metadataPath, destinationMetadataPath, ex);
}
Expand All @@ -133,24 +129,24 @@ public boolean renameMetadata(String metadataPath, String destinationMetadataPat

public InputStream getFileFromDocumentStore(String path) {

logger.debug("Get file from DocumentStore. Path: {}",path);
logger.debug("Get file from DocumentStore. Path: {}", path);
try {
return documentStoreService.readDocumentAsStream(path);
}catch(Exception e) {
logger.error("Failed to get file '{}' from DocumentStore",path);
return localDocumentStoreService.readDocumentAsStream(path);
} catch (Exception e) {
logger.error("Failed to get file '{}' from DocumentStore", path);
return null;
}
}

private String getTempMetadataFilename(String metadataFolder, String fileName) {
logger.info("documentStoreService:{}, localDocumentStoreService:{}, metadataFolder:{}, fileName:{}",
documentStoreService, localDocumentStoreService, metadataFolder, fileName);
public String getTempMetadataFilename(String metadataFolder, String fileName) {
logger.info("localDocumentStoreService:{}, metadataFolder:{}, fileName:{}", localDocumentStoreService,
metadataFolder, fileName);
synchronized (SamlIdpService.class) {
String possibleTemp;
do {
possibleTemp = fileName + INumGenerator.generate(2);
logger.debug("possibleTemp:{}", possibleTemp);
} while (documentStoreService.hasDocument(metadataFolder + possibleTemp));
} while (localDocumentStoreService.hasDocument(metadataFolder + possibleTemp));
return possibleTemp;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.jans.orm.search.filter.Filter;
import io.jans.orm.PersistenceEntryManager;
import io.jans.service.document.store.model.Document;
import io.jans.service.document.store.provider.DBDocumentStoreProvider;
import io.jans.service.document.store.service.DBDocumentService;

import io.jans.util.exception.InvalidAttributeException;
Expand All @@ -33,11 +32,9 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.*;

import jakarta.enterprise.context.ApplicationScoped;
Expand Down Expand Up @@ -66,9 +63,6 @@ public class AssetService {
@Inject
AuthUtil authUtil;

@Inject
DBDocumentStoreProvider dBDocumentStoreProvider;

@Inject
DocumentStoreService documentStoreService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@
"jans-auth",
"jans-config-api",
"jans-keycloak-link",
"jans-scim"
"jans-scim",
"jans-lock",
"jans-link"
],
"description": "java archive library."
},
Expand Down Expand Up @@ -261,17 +263,6 @@
],
"description": " FIDO Server Metadata."
},
{
"directory": "/opt/jans/jetty/%s/custom-libs",
"type": [
"jar"
],
"jansServiceModule": [
"jans-lock",
"jans-link"
],
"description": "java archive library."
},
{
"directory": "/var/jans/keycloak-link-snapshots",
"type": [
Expand Down

0 comments on commit 6135564

Please sign in to comment.