use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.
the class SamlRegisteredServiceCachedMetadataEndpoint method invalidate.
/**
* Invalidate.
*
* @param serviceId the service id
*/
@DeleteOperation
@Operation(summary = "Invalidate SAML2 metadata cache using an entity id.", parameters = { @Parameter(name = "serviceId") })
public void invalidate(@Nullable final String serviceId) {
if (StringUtils.isBlank(serviceId)) {
cachingMetadataResolver.invalidate();
} else {
val registeredService = findRegisteredService(serviceId);
val criteriaSet = new CriteriaSet();
criteriaSet.add(new EntityIdCriterion(serviceId));
criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
cachingMetadataResolver.invalidate(registeredService, criteriaSet);
}
}
use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.
the class CasReleaseAttributesReportEndpoint method releasePrincipalAttributes.
/**
* Release principal attributes map.
*
* @param username the username
* @param password the password
* @param service the service
* @return the map
*/
@ReadOperation
@Operation(summary = "Get collection of released attributes for the user and application", parameters = { @Parameter(name = "username", required = true), @Parameter(name = "password", required = true), @Parameter(name = "service", required = true) })
public Map<String, Object> releasePrincipalAttributes(final String username, final String password, final String service) {
val selectedService = this.serviceFactory.createService(service);
val registeredService = this.servicesManager.findServiceBy(selectedService);
val credential = new UsernamePasswordCredential(username, password);
val result = this.authenticationSystemSupport.finalizeAuthenticationTransaction(selectedService, credential);
val authentication = result.getAuthentication();
val principal = authentication.getPrincipal();
val context = RegisteredServiceAttributeReleasePolicyContext.builder().registeredService(registeredService).service(selectedService).principal(principal).build();
val attributesToRelease = registeredService.getAttributeReleasePolicy().getAttributes(context);
val builder = DefaultAuthenticationBuilder.of(principal, this.principalFactory, attributesToRelease, selectedService, registeredService, authentication);
val finalAuthentication = builder.build();
val assertion = new DefaultAssertionBuilder(finalAuthentication).with(selectedService).with(CollectionUtils.wrap(finalAuthentication)).build();
val resValidation = new LinkedHashMap<String, Object>();
resValidation.put(CasViewConstants.MODEL_ATTRIBUTE_NAME_ASSERTION, assertion);
resValidation.put(CasViewConstants.MODEL_ATTRIBUTE_NAME_SERVICE, selectedService);
resValidation.put("registeredService", registeredService);
return resValidation;
}
use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.
the class SSOSamlIdPPostProfileHandlerEndpoint method producePost.
/**
* Produce response entity.
*
* @param request the request
* @param response the response
* @param map the RequestBody
* @return the response entity
*/
@PostMapping(produces = MediaType.APPLICATION_XML_VALUE)
@ResponseBody
@Operation(summary = "Produce SAML2 response entity", parameters = { @Parameter(name = "username", required = true), @Parameter(name = "password", required = true), @Parameter(name = SamlProtocolConstants.PARAMETER_ENTITY_ID, required = true), @Parameter(name = "encrypt") })
public ResponseEntity<Object> producePost(final HttpServletRequest request, final HttpServletResponse response, @RequestBody final Map<String, String> map) {
val username = map.get("username");
val password = map.get("password");
val entityId = map.get(SamlProtocolConstants.PARAMETER_ENTITY_ID);
val encrypt = Boolean.parseBoolean(map.get("encrypt"));
return produce(request, response, username, password, entityId, encrypt);
}
use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.
the class JwtTokenCipherSigningPublicKeyEndpoint method fetchPublicKey.
/**
* Fetch public key.
*
* @param service the service
* @return the string
* @throws Exception the exception
*/
@ReadOperation(produces = MediaType.TEXT_PLAIN_VALUE)
@Operation(summary = "Get public key for signing operations", parameters = { @Parameter(name = "service") })
public String fetchPublicKey(@Nullable final String service) throws Exception {
var signingKey = tokenCipherExecutor.getSigningKey();
if (StringUtils.isNotBlank(service)) {
val registeredService = servicesManager.findServiceBy(webApplicationServiceFactory.createService(service));
RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(registeredService);
val serviceCipher = new RegisteredServiceJwtTicketCipherExecutor();
if (serviceCipher.supports(registeredService)) {
val cipher = serviceCipher.getTokenTicketCipherExecutorForService(registeredService);
if (cipher.isEnabled()) {
signingKey = cipher.getSigningKey();
}
}
}
if (signingKey instanceof RSAPrivateCrtKey) {
val rsaSigningKey = (RSAPrivateCrtKey) signingKey;
val factory = KeyFactory.getInstance("RSA");
val publicKey = factory.generatePublic(new RSAPublicKeySpec(rsaSigningKey.getModulus(), rsaSigningKey.getPublicExponent()));
return EncodingUtils.encodeBase64(publicKey.getEncoded());
}
return null;
}
use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.
the class TicketExpirationPoliciesEndpoint method handle.
/**
* Produce expiration policies.
*
* @param serviceId the service
* @return the map
* @throws Exception the exception
*/
@ReadOperation
@Operation(summary = "Produce expiration policies given an optional service id", parameters = { @Parameter(name = "serviceId") })
public Map<String, String> handle(@Nullable final String serviceId) throws Exception {
val model = new HashMap<String, String>();
expirationPolicyBuilders.forEach(Unchecked.consumer(builder -> {
val policy = builder.buildTicketExpirationPolicy();
val details = getTicketExpirationPolicyDetails(policy);
model.put(builder.getTicketType().getName(), details);
}));
val registeredService = StringUtils.isNotBlank(serviceId) ? NumberUtils.isCreatable(serviceId) ? servicesManager.findServiceBy(Long.parseLong(serviceId)) : servicesManager.findServiceBy(webApplicationServiceFactory.createService(serviceId)) : null;
Optional.ofNullable(registeredService).map(RegisteredService::getTicketGrantingTicketExpirationPolicy).map(RegisteredServiceTicketGrantingTicketExpirationPolicy::toExpirationPolicy).filter(Optional::isPresent).map(Optional::get).ifPresent(Unchecked.consumer(policy -> {
val details = getTicketExpirationPolicyDetails(policy);
model.put(TicketGrantingTicket.class.getName().concat(registeredService.getName()), details);
}));
Optional.ofNullable(registeredService).map(RegisteredService::getServiceTicketExpirationPolicy).ifPresent(Unchecked.consumer(policy -> {
val details = getTicketExpirationPolicyDetails(policy);
model.put(ServiceTicket.class.getName().concat(registeredService.getName()), details);
}));
Optional.ofNullable(registeredService).map(RegisteredService::getProxyGrantingTicketExpirationPolicy).ifPresent(Unchecked.consumer(policy -> {
val details = getTicketExpirationPolicyDetails(policy);
model.put(ProxyGrantingTicket.class.getName().concat(registeredService.getName()), details);
}));
Optional.ofNullable(registeredService).map(RegisteredService::getProxyTicketExpirationPolicy).ifPresent(Unchecked.consumer(policy -> {
val details = getTicketExpirationPolicyDetails(policy);
model.put(ProxyTicket.class.getName().concat(registeredService.getName()), details);
}));
return model;
}
Aggregations