Search in sources :

Example 1 with ResourceResolverContext

use of org.apache.xml.security.utils.resolver.ResourceResolverContext in project santuario-java by apache.

the class ResolverDirectHTTPTest method testServerAuth.

@Test
@Ignore
public void testServerAuth() throws Exception {
    Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
    Attr uri = doc.createAttribute("URI");
    uri.setNodeValue(url);
    ResolverDirectHTTP resolverDirectHTTP = new ResolverDirectHTTP();
    resolverDirectHTTP.engineSetProperty("http.basic.username", serverUsername);
    resolverDirectHTTP.engineSetProperty("http.basic.password", serverPassword);
    ResourceResolverContext context = new ResourceResolverContext(uri, url, true);
    resolverDirectHTTP.engineResolveURI(context);
}
Also used : ResolverDirectHTTP(org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP) ResourceResolverContext(org.apache.xml.security.utils.resolver.ResourceResolverContext) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with ResourceResolverContext

use of org.apache.xml.security.utils.resolver.ResourceResolverContext in project santuario-java by apache.

the class ResolverDirectHTTPTest method testProxyAuth.

@Test
@Ignore
public void testProxyAuth() throws Exception {
    Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
    Attr uri = doc.createAttribute("URI");
    uri.setNodeValue(url);
    ResolverDirectHTTP resolverDirectHTTP = new ResolverDirectHTTP();
    resolverDirectHTTP.engineSetProperty("http.proxy.host", proxyHost);
    resolverDirectHTTP.engineSetProperty("http.proxy.port", proxyPort);
    resolverDirectHTTP.engineSetProperty("http.proxy.username", proxyUsername);
    resolverDirectHTTP.engineSetProperty("http.proxy.password", proxyPassword);
    ResourceResolverContext context = new ResourceResolverContext(uri, url, true);
    resolverDirectHTTP.engineResolveURI(context);
}
Also used : ResolverDirectHTTP(org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP) ResourceResolverContext(org.apache.xml.security.utils.resolver.ResourceResolverContext) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with ResourceResolverContext

use of org.apache.xml.security.utils.resolver.ResourceResolverContext in project santuario-java by apache.

the class ResolverDirectHTTPTest method testProxyAndServerAuth.

@Test
@Ignore
public void testProxyAndServerAuth() throws Exception {
    Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
    Attr uri = doc.createAttribute("URI");
    uri.setNodeValue(url);
    ResolverDirectHTTP resolverDirectHTTP = new ResolverDirectHTTP();
    resolverDirectHTTP.engineSetProperty("http.proxy.host", proxyHost);
    resolverDirectHTTP.engineSetProperty("http.proxy.port", proxyPort);
    resolverDirectHTTP.engineSetProperty("http.proxy.username", proxyUsername);
    resolverDirectHTTP.engineSetProperty("http.proxy.password", proxyPassword);
    resolverDirectHTTP.engineSetProperty("http.basic.username", serverUsername);
    resolverDirectHTTP.engineSetProperty("http.basic.password", serverPassword);
    ResourceResolverContext context = new ResourceResolverContext(uri, url, true);
    resolverDirectHTTP.engineResolveURI(context);
}
Also used : ResolverDirectHTTP(org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP) ResourceResolverContext(org.apache.xml.security.utils.resolver.ResourceResolverContext) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with ResourceResolverContext

use of org.apache.xml.security.utils.resolver.ResourceResolverContext in project santuario-java by apache.

the class ResolverDirectHTTPTest method testProxyAuthWithWrongPassword.

@Test
@Ignore
public void testProxyAuthWithWrongPassword() throws Exception {
    Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
    Attr uri = doc.createAttribute("URI");
    uri.setNodeValue(url);
    ResolverDirectHTTP resolverDirectHTTP = new ResolverDirectHTTP();
    resolverDirectHTTP.engineSetProperty("http.proxy.host", proxyHost);
    resolverDirectHTTP.engineSetProperty("http.proxy.port", proxyPort);
    resolverDirectHTTP.engineSetProperty("http.proxy.username", proxyUsername);
    resolverDirectHTTP.engineSetProperty("http.proxy.password", "wrongPassword");
    ResourceResolverContext context = new ResourceResolverContext(uri, url, true);
    try {
        resolverDirectHTTP.engineResolveURI(context);
        Assert.fail("Expected ResourceResolverException");
    } catch (ResourceResolverException e) {
        Assert.assertEquals("Server returned HTTP response code: 407 for URL: " + url, e.getMessage());
    }
}
Also used : ResolverDirectHTTP(org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP) ResourceResolverContext(org.apache.xml.security.utils.resolver.ResourceResolverContext) ResourceResolverException(org.apache.xml.security.utils.resolver.ResourceResolverException) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with ResourceResolverContext

use of org.apache.xml.security.utils.resolver.ResourceResolverContext in project santuario-java by apache.

the class ResolverDirectHTTPTest method testServerAuthWithWrongPassword.

@Test
@Ignore
public void testServerAuthWithWrongPassword() throws Exception {
    Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
    Attr uri = doc.createAttribute("URI");
    uri.setNodeValue(url);
    ResolverDirectHTTP resolverDirectHTTP = new ResolverDirectHTTP();
    resolverDirectHTTP.engineSetProperty("http.basic.username", serverUsername);
    resolverDirectHTTP.engineSetProperty("http.basic.password", "wrongPassword");
    ResourceResolverContext context = new ResourceResolverContext(uri, url, true);
    try {
        resolverDirectHTTP.engineResolveURI(context);
        Assert.fail("Expected ResourceResolverException");
    } catch (ResourceResolverException e) {
        Assert.assertEquals("Server returned HTTP response code: 401 for URL: " + url, e.getMessage());
    }
}
Also used : ResolverDirectHTTP(org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP) ResourceResolverContext(org.apache.xml.security.utils.resolver.ResourceResolverContext) ResourceResolverException(org.apache.xml.security.utils.resolver.ResourceResolverException) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ResourceResolverContext (org.apache.xml.security.utils.resolver.ResourceResolverContext)5 ResolverDirectHTTP (org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP)5 Ignore (org.junit.Ignore)5 Test (org.junit.Test)5 Attr (org.w3c.dom.Attr)5 Document (org.w3c.dom.Document)5 ResourceResolverException (org.apache.xml.security.utils.resolver.ResourceResolverException)2