Search in sources :

Example 11 with SAMLSecurityContext

use of org.apache.cxf.rt.security.saml.claims.SAMLSecurityContext in project cxf by apache.

the class Saml2BearerGrantHandler method getGrantSubject.

protected UserSubject getGrantSubject(Message message, SamlAssertionWrapper wrapper) {
    SecurityContext sc = scProvider.getSecurityContext(message, wrapper);
    if (sc instanceof SAMLSecurityContext) {
        SAMLSecurityContext jaxrsSc = (SAMLSecurityContext) sc;
        Set<Principal> rolesP = jaxrsSc.getUserRoles();
        List<String> roles = new ArrayList<>();
        if (roles != null) {
            for (Principal p : rolesP) {
                roles.add(p.getName());
            }
        }
        return new SamlUserSubject(jaxrsSc.getUserPrincipal().getName(), roles, jaxrsSc.getClaims());
    }
    return new UserSubject(sc.getUserPrincipal().getName());
}
Also used : UserSubject(org.apache.cxf.rs.security.oauth2.common.UserSubject) SAMLSecurityContext(org.apache.cxf.rt.security.saml.claims.SAMLSecurityContext) SAMLSecurityContext(org.apache.cxf.rt.security.saml.claims.SAMLSecurityContext) SecurityContext(org.apache.cxf.security.SecurityContext) ArrayList(java.util.ArrayList) Principal(java.security.Principal)

Aggregations

SAMLSecurityContext (org.apache.cxf.rt.security.saml.claims.SAMLSecurityContext)11 Principal (java.security.Principal)9 ClaimCollection (org.apache.cxf.rt.security.claims.ClaimCollection)9 SecurityContext (org.apache.cxf.security.SecurityContext)6 SamlAssertionWrapper (org.apache.wss4j.common.saml.SamlAssertionWrapper)4 ArrayList (java.util.ArrayList)2 Set (java.util.Set)2 Subject (javax.security.auth.Subject)2 SimplePrincipal (org.apache.cxf.common.security.SimplePrincipal)2 DefaultSecurityContext (org.apache.cxf.interceptor.security.DefaultSecurityContext)2 RolePrefixSecurityContextImpl (org.apache.cxf.interceptor.security.RolePrefixSecurityContextImpl)2 Subject (org.apache.cxf.rs.security.saml.assertion.Subject)2 Method (java.lang.reflect.Method)1 PublicKey (java.security.PublicKey)1 X509Certificate (java.security.cert.X509Certificate)1 List (java.util.List)1 KerberosPrincipal (javax.security.auth.kerberos.KerberosPrincipal)1 AccessDeniedException (org.apache.cxf.interceptor.security.AccessDeniedException)1 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)1 Message (org.apache.cxf.message.Message)1