use of org.apereo.cas.services.util.RegisteredServiceJsonSerializer in project cas by apereo.
the class OidcCustomScopeAttributeReleasePolicyTests method verifySerialization.
@Test
public void verifySerialization() {
val policy = new OidcCustomScopeAttributeReleasePolicy("groups", CollectionUtils.wrap("groups"));
val chain = new ChainingAttributeReleasePolicy();
chain.addPolicy(policy);
val service = getOidcRegisteredService();
service.setAttributeReleasePolicy(chain);
val serializer = new RegisteredServiceJsonSerializer();
var json = serializer.toString(service);
assertNotNull(json);
assertNotNull(serializer.from(json));
}
use of org.apereo.cas.services.util.RegisteredServiceJsonSerializer in project cas by apereo.
the class OidcOpenIdScopeAttributeReleasePolicyTests method verifySerialization.
@Test
public void verifySerialization() {
val policy = new OidcOpenIdScopeAttributeReleasePolicy();
val chain = new ChainingAttributeReleasePolicy();
chain.addPolicy(policy);
val service = getOidcRegisteredService();
service.setAttributeReleasePolicy(chain);
val serializer = new RegisteredServiceJsonSerializer();
val json = serializer.toString(service);
assertNotNull(json);
assertNotNull(serializer.from(json));
}
use of org.apereo.cas.services.util.RegisteredServiceJsonSerializer in project cas by apereo.
the class OidcAddressScopeAttributeReleasePolicyTests method verifySerialization.
@Test
public void verifySerialization() {
val policy = new OidcAddressScopeAttributeReleasePolicy();
val chain = new ChainingAttributeReleasePolicy();
chain.addPolicy(policy);
val service = getOidcRegisteredService();
service.setAttributeReleasePolicy(chain);
val serializer = new RegisteredServiceJsonSerializer();
val json = serializer.toString(service);
assertNotNull(json);
assertNotNull(serializer.from(json));
}
use of org.apereo.cas.services.util.RegisteredServiceJsonSerializer in project cas by apereo.
the class GenerateYamlRegisteredServiceCommand method generate.
private static void generate(final File filePath, final File result) {
try {
val validator = new RegisteredServiceJsonSerializer();
if (filePath.isFile() && filePath.exists() && filePath.canRead() && filePath.length() > 0) {
val svc = validator.from(filePath);
LOGGER.info("Service [{}] is valid at [{}].", svc.getName(), filePath.getCanonicalPath());
val yaml = new RegisteredServiceYamlSerializer();
try (val writer = new StringWriter()) {
yaml.to(writer, svc);
LOGGER.info(writer.toString());
if (result != null) {
yaml.to(result, svc);
LOGGER.info("YAML service definition is saved at [{}].", result.getCanonicalPath());
}
}
} else {
LOGGER.warn("File [{}] is does not exist, is not readable or is empty", filePath.getCanonicalPath());
}
} catch (final Exception e) {
LOGGER.error("Could not understand and validate [{}]: [{}]", filePath.getPath(), e.getMessage());
} finally {
LOGGER.info("-".repeat(SEP_LINE_LENGTH));
}
}
use of org.apereo.cas.services.util.RegisteredServiceJsonSerializer in project cas by apereo.
the class ValidateRegisteredServiceCommand method validate.
private static void validate(final File filePath) {
try {
var validator = (RegisteredServiceJsonSerializer) null;
if (filePath.isFile() && filePath.exists() && filePath.canRead() && filePath.length() > 0) {
switch(FilenameUtils.getExtension(filePath.getPath()).toLowerCase()) {
case "json":
validator = new RegisteredServiceJsonSerializer();
break;
case "yml":
case "yaml":
validator = new RegisteredServiceYamlSerializer();
break;
default:
LOGGER.debug("Unknown file [{}]", filePath.getCanonicalPath());
break;
}
if (validator != null) {
val svc = Objects.requireNonNull(validator).from(filePath);
LOGGER.info("Service [{}] is valid at [{}].", svc.getName(), filePath.getCanonicalPath());
}
} else {
LOGGER.warn("File [{}] is does not exist, is not readable or is empty", filePath.getCanonicalPath());
}
} catch (final Exception e) {
LOGGER.error("Could not understand and validate [{}]: [{}]", filePath.getPath(), e.getMessage());
} finally {
LOGGER.info("-".repeat(SEP_LINE_LENGTH));
}
}
Aggregations