use of org.apereo.cas.services.RegisteredService in project cas by apereo.
the class WSFederationClaimsReleasePolicy method getAttributesInternal.
@Override
public Map<String, Object> getAttributesInternal(final Principal principal, final Map<String, Object> attrs, final RegisteredService service) {
final Map<String, Object> resolvedAttributes = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
resolvedAttributes.putAll(attrs);
final Map<String, Object> attributesToRelease = new HashMap<>(resolvedAttributes.size());
getAllowedAttributes().entrySet().stream().filter(entry -> WSFederationClaims.contains(entry.getKey().toUpperCase())).forEach(entry -> {
final String claimName = entry.getKey();
final String attributeName = entry.getValue();
final WSFederationClaims claim = WSFederationClaims.valueOf(claimName.toUpperCase());
LOGGER.debug("Evaluating claimName [{}] mapped to attribute name [{}]", claim.getUri(), attributeName);
final Object value = resolvedAttributes.get(attributeName);
if (value != null) {
LOGGER.debug("Adding claimName [{}] to the collection of released attributes", claim.getUri());
attributesToRelease.put(claim.getUri(), value);
}
});
return attributesToRelease;
}
use of org.apereo.cas.services.RegisteredService in project cas by apereo.
the class WSFederationMetadataUIAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
Service service = WebUtils.getService(requestContext);
if (service != null) {
service = serviceSelectionStrategy.resolveServiceFrom(service);
final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(service, registeredService);
if (registeredService instanceof WSFederationRegisteredService) {
final WSFederationRegisteredService wsfed = WSFederationRegisteredService.class.cast(registeredService);
WebUtils.putServiceUserInterfaceMetadata(requestContext, new DefaultRegisteredServiceUserInterfaceInfo(wsfed));
}
}
return success();
}
use of org.apereo.cas.services.RegisteredService in project cas by apereo.
the class OidcProfileScopeToAttributesFilter method filterAttributesByScope.
private void filterAttributesByScope(final Collection<String> stream, final Map<String, Object> attributes, final Principal principal, final RegisteredService registeredService) {
stream.stream().distinct().filter(s -> this.filters.containsKey(s)).forEach(s -> {
final BaseOidcScopeAttributeReleasePolicy policy = filters.get(s);
attributes.putAll(policy.getAttributes(principal, registeredService));
});
}
use of org.apereo.cas.services.RegisteredService in project cas by apereo.
the class OAuth20AccessTokenControllerTests method addRefreshToken.
private RefreshToken addRefreshToken(final Principal principal, final RegisteredService registeredService) {
final Authentication authentication = getAuthentication(principal);
final WebApplicationServiceFactory factory = new WebApplicationServiceFactory();
final Service service = factory.createService(registeredService.getServiceId());
final RefreshToken refreshToken = oAuthRefreshTokenFactory.create(service, authentication);
oAuth20AccessTokenController.getTicketRegistry().addTicket(refreshToken);
return refreshToken;
}
use of org.apereo.cas.services.RegisteredService in project cas by apereo.
the class WsFederationAction method getRelyingPartyIdentifier.
/**
* Get the relying party id for a service.
*
* @param service the service to get an id for
* @return relying party id
*/
private String getRelyingPartyIdentifier(final Service service) {
String relyingPartyIdentifier = this.configuration.getRelyingPartyIdentifier();
if (service != null) {
final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(service, registeredService);
if (registeredService.getProperties().containsKey("wsfed.relyingPartyIdentifier")) {
relyingPartyIdentifier = registeredService.getProperties().get("wsfed.relyingPartyIdentifier").getValue();
}
}
LOGGER.debug("Determined relying party identifier for [{}] to be [{}]", service, relyingPartyIdentifier);
return relyingPartyIdentifier;
}
Aggregations