use of org.springframework.security.saml.context.SAMLMessageContext in project pentaho-engineering-samples by pentaho.
the class PentahoSamlLogoutFilter method idpContainsGlobalLogoutEndpoint.
private boolean idpContainsGlobalLogoutEndpoint(HttpServletRequest request, HttpServletResponse response) {
try {
SAMLMessageContext ctx = contextProvider.getLocalAndPeerEntity(request, response);
String binding = SAMLUtil.getLogoutBinding((IDPSSODescriptor) ctx.getPeerEntityRoleMetadata(), (SPSSODescriptor) ctx.getLocalEntityRoleMetadata());
return (binding != null && !binding.isEmpty());
} catch (MetadataProviderException e) {
logger.error(e.getMessage(), e);
}
return false;
}
use of org.springframework.security.saml.context.SAMLMessageContext in project hub-alert by blackducksoftware.
the class AuthenticationEventManager method sendAuthenticationEvent.
public void sendAuthenticationEvent(Authentication authentication, AuthenticationType authenticationType) {
String username;
String emailAddress = null;
try {
Object authPrincipal = authentication.getPrincipal();
if (authentication instanceof SAMLAuthenticationToken) {
SAMLAuthenticationToken samlAuthenticationToken = (SAMLAuthenticationToken) authentication;
SAMLMessageContext credentials = samlAuthenticationToken.getCredentials();
NameIDImpl subjectNameIdentifier = (NameIDImpl) credentials.getSubjectNameIdentifier();
username = subjectNameIdentifier.getValue();
emailAddress = username;
} else if (authPrincipal instanceof InetOrgPerson) {
username = authentication.getName();
emailAddress = ((InetOrgPerson) authPrincipal).getMail();
} else {
username = authentication.getName();
}
sendAuthenticationEvent(username, emailAddress, authenticationType, authentication.getAuthorities());
} catch (Exception e) {
logger.warn("Unable to send authentication event");
logger.debug("Authentication event failure", e);
}
}
Aggregations