Search in sources :

Example 71 with AuthorizationPolicy

use of org.apache.cxf.configuration.security.AuthorizationPolicy in project testcases by coheigea.

the class WSS4JBasicAuthFilter method filter.

public void filter(ContainerRequestContext requestContext) throws IOException {
    Message message = JAXRSUtils.getCurrentMessage();
    AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
    if (policy == null || policy.getUserName() == null || policy.getPassword() == null) {
        requestContext.abortWith(Response.status(401).header("WWW-Authenticate", "Basic realm=\"STS\"").build());
        return;
    }
    try {
        super.validate(message);
    } catch (Exception ex) {
        throw ExceptionUtils.toInternalServerErrorException(ex, null);
    }
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Message(org.apache.cxf.message.Message) IOException(java.io.IOException)

Example 72 with AuthorizationPolicy

use of org.apache.cxf.configuration.security.AuthorizationPolicy in project testcases by coheigea.

the class WSS4JBasicAuthFilter method filter.

public void filter(ContainerRequestContext requestContext) throws IOException {
    Message message = JAXRSUtils.getCurrentMessage();
    AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
    if (policy == null || policy.getUserName() == null || policy.getPassword() == null) {
        requestContext.abortWith(Response.status(401).header("WWW-Authenticate", "Basic realm=\"IdP\"").build());
        return;
    }
    try {
        super.validate(message);
    } catch (Exception ex) {
        throw ExceptionUtils.toInternalServerErrorException(ex, null);
    }
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Message(org.apache.cxf.message.Message) IOException(java.io.IOException)

Example 73 with AuthorizationPolicy

use of org.apache.cxf.configuration.security.AuthorizationPolicy in project testcases by coheigea.

the class WSS4JBasicAuthFilter method filter.

public void filter(ContainerRequestContext requestContext) throws IOException {
    Message message = JAXRSUtils.getCurrentMessage();
    AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
    if (policy == null || policy.getUserName() == null || policy.getPassword() == null) {
        requestContext.abortWith(Response.status(401).header("WWW-Authenticate", "Basic realm=\"STS\"").build());
        return;
    }
    try {
        super.validate(message);
    } catch (Exception ex) {
        throw ExceptionUtils.toInternalServerErrorException(ex, null);
    }
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Message(org.apache.cxf.message.Message) IOException(java.io.IOException)

Example 74 with AuthorizationPolicy

use of org.apache.cxf.configuration.security.AuthorizationPolicy in project testcases by coheigea.

the class WSS4JBasicAuthFilter method filter.

public void filter(ContainerRequestContext requestContext) throws IOException {
    Message message = JAXRSUtils.getCurrentMessage();
    AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
    if (policy == null || policy.getUserName() == null || policy.getPassword() == null) {
        requestContext.abortWith(Response.status(401).header("WWW-Authenticate", "Basic realm=\"STS\"").build());
        return;
    }
    try {
        super.validate(message);
    } catch (Exception ex) {
        throw ExceptionUtils.toInternalServerErrorException(ex, null);
    }
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Message(org.apache.cxf.message.Message) IOException(java.io.IOException)

Example 75 with AuthorizationPolicy

use of org.apache.cxf.configuration.security.AuthorizationPolicy in project testcases by coheigea.

the class WSS4JBasicAuthFilter method filter.

public void filter(ContainerRequestContext requestContext) throws IOException {
    Message message = JAXRSUtils.getCurrentMessage();
    AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
    if (policy == null || policy.getUserName() == null || policy.getPassword() == null) {
        requestContext.abortWith(Response.status(401).header("WWW-Authenticate", "Basic realm=\"IdP\"").build());
        return;
    }
    try {
        super.validate(message);
    } catch (Exception ex) {
        throw ExceptionUtils.toInternalServerErrorException(ex, null);
    }
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Message(org.apache.cxf.message.Message) IOException(java.io.IOException)

Aggregations

AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)85 Message (org.apache.cxf.message.Message)25 Test (org.junit.Test)22 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)16 IOException (java.io.IOException)15 ArrayList (java.util.ArrayList)11 Client (org.apache.cxf.endpoint.Client)11 List (java.util.List)9 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)9 URL (java.net.URL)7 HashMap (java.util.HashMap)7 ProxyAuthorizationPolicy (org.apache.cxf.configuration.security.ProxyAuthorizationPolicy)7 Map (java.util.Map)6 SecurityContext (org.apache.cxf.security.SecurityContext)6 Bus (org.apache.cxf.Bus)5 WebClient (org.apache.cxf.jaxrs.client.WebClient)5 MessageImpl (org.apache.cxf.message.MessageImpl)5 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)5 Principal (java.security.Principal)4 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)4