use of org.apereo.cas.configuration.model.support.sms.SmsProperties in project cas by apereo.
the class ElectronicFenceConfiguration method configureContingencyPlan.
private void configureContingencyPlan(final BaseAuthenticationRiskContingencyPlan b) {
final EmailProperties mail = casProperties.getAuthn().getAdaptive().getRisk().getResponse().getMail();
if (StringUtils.isNotBlank(mail.getText()) && StringUtils.isNotBlank(mail.getFrom()) && StringUtils.isNotBlank(mail.getSubject())) {
b.getNotifiers().add(authenticationRiskEmailNotifier());
}
final SmsProperties sms = casProperties.getAuthn().getAdaptive().getRisk().getResponse().getSms();
if (StringUtils.isNotBlank(sms.getText()) && StringUtils.isNotBlank(sms.getFrom())) {
b.getNotifiers().add(authenticationRiskSmsNotifier());
}
}
use of org.apereo.cas.configuration.model.support.sms.SmsProperties in project cas by apereo.
the class RegisteredServicesEventListener method handleRegisteredServiceExpiredEvent.
/**
* Handle registered service expired event.
*
* @param event the event
*/
@EventListener
public void handleRegisteredServiceExpiredEvent(final CasRegisteredServiceExpiredEvent event) {
final RegisteredService registeredService = event.getRegisteredService();
final List<RegisteredServiceContact> contacts = registeredService.getContacts();
final EmailProperties mail = casProperties.getServiceRegistry().getMail();
final SmsProperties sms = casProperties.getServiceRegistry().getSms();
final String serviceName = StringUtils.defaultIfBlank(registeredService.getName(), registeredService.getServiceId());
if (communicationsManager.isMailSenderDefined()) {
final String message = String.format(mail.getText(), serviceName);
contacts.stream().filter(c -> StringUtils.isNotBlank(c.getEmail())).forEach(c -> communicationsManager.email(message, mail.getFrom(), mail.getSubject(), c.getEmail(), mail.getCc(), mail.getBcc()));
}
if (communicationsManager.isSmsSenderDefined()) {
final String message = String.format(sms.getText(), serviceName);
contacts.stream().filter(c -> StringUtils.isNotBlank(c.getPhone())).forEach(c -> communicationsManager.sms(sms.getFrom(), c.getPhone(), message));
}
servicesManager.load();
}
use of org.apereo.cas.configuration.model.support.sms.SmsProperties in project cas by apereo.
the class SurrogateAuthenticationEventListener method notify.
private void notify(final Principal principal, final AbstractCasEvent event) {
final String eventDetails = event.toString();
if (communicationsManager.isSmsSenderDefined()) {
final SmsProperties sms = casProperties.getAuthn().getSurrogate().getSms();
final String text = sms.getText().concat("\n").concat(eventDetails);
communicationsManager.sms(sms.getFrom(), principal.getAttributes().get(sms.getAttributeName()).toString(), text);
} else {
LOGGER.trace("CAS is unable to send surrogate-authentication SMS messages given no settings are defined to account for servers, etc");
}
if (communicationsManager.isMailSenderDefined()) {
final EmailProperties mail = casProperties.getAuthn().getSurrogate().getMail();
final String emailAttribute = mail.getAttributeName();
final Object to = principal.getAttributes().get(emailAttribute);
if (to != null) {
final String text = mail.getText().concat("\n").concat(eventDetails);
this.communicationsManager.email(text, mail.getFrom(), mail.getSubject(), to.toString(), mail.getCc(), mail.getBcc());
} else {
LOGGER.trace("The principal has no {} attribute, cannot send email notification", emailAttribute);
}
} else {
LOGGER.trace("CAS is unable to send surrogate-authentication email messages given no settings are defined to account for servers, etc");
}
}
use of org.apereo.cas.configuration.model.support.sms.SmsProperties in project cas by apereo.
the class AuthenticationRiskTwilioSmsNotifier method publish.
@Override
public void publish() {
final SmsProperties sms = casProperties.getAuthn().getAdaptive().getRisk().getResponse().getSms();
final Principal principal = authentication.getPrincipal();
if (StringUtils.isBlank(sms.getText()) || StringUtils.isBlank(sms.getFrom()) || !principal.getAttributes().containsKey(sms.getAttributeName())) {
LOGGER.debug("Could not send sms [{}] because either no phones could be found or sms settings are not configured.", principal.getId());
return;
}
communicationsManager.sms(sms.getFrom(), principal.getAttributes().get(sms.getAttributeName()).toString(), sms.getText());
}
Aggregations