Search in sources :

Example 1 with HttpsToken

use of org.apache.wss4j.policy.model.HttpsToken in project cxf by apache.

the class AbstractCommonBindingHandler method assertToken.

protected void assertToken(AbstractToken token) {
    if (token == null) {
        return;
    }
    assertPolicy(token.getName());
    String namespace = token.getName().getNamespaceURI();
    if (token.getDerivedKeys() != null) {
        assertPolicy(new QName(namespace, token.getDerivedKeys().name()));
    }
    if (token instanceof X509Token) {
        X509Token x509Token = (X509Token) token;
        assertX509Token(x509Token);
    } else if (token instanceof HttpsToken) {
        HttpsToken httpsToken = (HttpsToken) token;
        if (httpsToken.getAuthenticationType() != null) {
            assertPolicy(new QName(namespace, httpsToken.getAuthenticationType().name()));
        }
    } else if (token instanceof KeyValueToken) {
        KeyValueToken keyValueToken = (KeyValueToken) token;
        if (keyValueToken.isRsaKeyValue()) {
            assertPolicy(new QName(namespace, SPConstants.RSA_KEY_VALUE));
        }
    } else if (token instanceof UsernameToken) {
        UsernameToken usernameToken = (UsernameToken) token;
        assertUsernameToken(usernameToken);
    } else if (token instanceof SecureConversationToken) {
        SecureConversationToken scToken = (SecureConversationToken) token;
        assertSecureConversationToken(scToken);
    } else if (token instanceof SecurityContextToken) {
        SecurityContextToken scToken = (SecurityContextToken) token;
        assertSecurityContextToken(scToken);
    } else if (token instanceof SpnegoContextToken) {
        SpnegoContextToken scToken = (SpnegoContextToken) token;
        assertSpnegoContextToken(scToken);
    } else if (token instanceof IssuedToken) {
        IssuedToken issuedToken = (IssuedToken) token;
        assertIssuedToken(issuedToken);
    } else if (token instanceof KerberosToken) {
        KerberosToken kerberosToken = (KerberosToken) token;
        assertKerberosToken(kerberosToken);
    } else if (token instanceof SamlToken) {
        SamlToken samlToken = (SamlToken) token;
        assertSamlToken(samlToken);
    }
}
Also used : HttpsToken(org.apache.wss4j.policy.model.HttpsToken) X509Token(org.apache.wss4j.policy.model.X509Token) SamlToken(org.apache.wss4j.policy.model.SamlToken) SecurityContextToken(org.apache.wss4j.policy.model.SecurityContextToken) QName(javax.xml.namespace.QName) KerberosToken(org.apache.wss4j.policy.model.KerberosToken) KeyValueToken(org.apache.wss4j.policy.model.KeyValueToken) IssuedToken(org.apache.wss4j.policy.model.IssuedToken) UsernameToken(org.apache.wss4j.policy.model.UsernameToken) SecureConversationToken(org.apache.wss4j.policy.model.SecureConversationToken) SpnegoContextToken(org.apache.wss4j.policy.model.SpnegoContextToken)

Example 2 with HttpsToken

use of org.apache.wss4j.policy.model.HttpsToken in project tesb-rt-se by Talend.

the class SingleBusLocatorRegistrar method isSecuredByPolicy.

/**
 * Is the transport secured by a policy
 */
private boolean isSecuredByPolicy(Server server) {
    boolean isSecured = false;
    EndpointInfo ei = server.getEndpoint().getEndpointInfo();
    PolicyEngine pe = bus.getExtension(PolicyEngine.class);
    if (null == pe) {
        LOG.finest("No Policy engine found");
        return isSecured;
    }
    Destination destination = server.getDestination();
    EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination, null);
    Collection<Assertion> assertions = ep.getChosenAlternative();
    for (Assertion a : assertions) {
        if (a instanceof TransportBinding) {
            TransportBinding tb = (TransportBinding) a;
            TransportToken tt = tb.getTransportToken();
            AbstractToken t = tt.getToken();
            if (t instanceof HttpsToken) {
                isSecured = true;
                break;
            }
        }
    }
    Policy policy = ep.getPolicy();
    List<PolicyComponent> pcList = policy.getPolicyComponents();
    for (PolicyComponent a : pcList) {
        if (a instanceof TransportBinding) {
            TransportBinding tb = (TransportBinding) a;
            TransportToken tt = tb.getTransportToken();
            AbstractToken t = tt.getToken();
            if (t instanceof HttpsToken) {
                isSecured = true;
                break;
            }
        }
    }
    return isSecured;
}
Also used : TransportToken(org.apache.wss4j.policy.model.TransportToken) EndpointPolicy(org.apache.cxf.ws.policy.EndpointPolicy) Policy(org.apache.neethi.Policy) Destination(org.apache.cxf.transport.Destination) PolicyComponent(org.apache.neethi.PolicyComponent) Assertion(org.apache.neethi.Assertion) PolicyEngine(org.apache.cxf.ws.policy.PolicyEngine) EndpointPolicy(org.apache.cxf.ws.policy.EndpointPolicy) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) HttpsToken(org.apache.wss4j.policy.model.HttpsToken) AbstractToken(org.apache.wss4j.policy.model.AbstractToken) TransportBinding(org.apache.wss4j.policy.model.TransportBinding)

Aggregations

HttpsToken (org.apache.wss4j.policy.model.HttpsToken)2 QName (javax.xml.namespace.QName)1 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)1 Destination (org.apache.cxf.transport.Destination)1 EndpointPolicy (org.apache.cxf.ws.policy.EndpointPolicy)1 PolicyEngine (org.apache.cxf.ws.policy.PolicyEngine)1 Assertion (org.apache.neethi.Assertion)1 Policy (org.apache.neethi.Policy)1 PolicyComponent (org.apache.neethi.PolicyComponent)1 AbstractToken (org.apache.wss4j.policy.model.AbstractToken)1 IssuedToken (org.apache.wss4j.policy.model.IssuedToken)1 KerberosToken (org.apache.wss4j.policy.model.KerberosToken)1 KeyValueToken (org.apache.wss4j.policy.model.KeyValueToken)1 SamlToken (org.apache.wss4j.policy.model.SamlToken)1 SecureConversationToken (org.apache.wss4j.policy.model.SecureConversationToken)1 SecurityContextToken (org.apache.wss4j.policy.model.SecurityContextToken)1 SpnegoContextToken (org.apache.wss4j.policy.model.SpnegoContextToken)1 TransportBinding (org.apache.wss4j.policy.model.TransportBinding)1 TransportToken (org.apache.wss4j.policy.model.TransportToken)1 UsernameToken (org.apache.wss4j.policy.model.UsernameToken)1