Author: janb Date: Thu Aug 28 02:23:49 2008 New Revision: 689765 URL: http://svn.apache.org/viewvc?rev=689765&view=rev Log: Add license headers where forgotten; implement test of the proxy authentication.
Added: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyDeployerTest.java (with props) maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyRetrieverTest.java (with props) Modified: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/SecureSender.java maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/AuthenticatingJettyDeployerTest.java maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/AuthenticatingJettyRetrieverTest.java maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/JettyRetrieverTest.java maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/server/AuthenticatingPutServer.java maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/server/AuthenticatingTestServer.java Modified: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/SecureSender.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/SecureSender.java?rev=689765&r1=689764&r2=689765&view=diff ============================================================================== --- maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/SecureSender.java (original) +++ maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/SecureSender.java Thu Aug 28 02:23:49 2008 @@ -61,17 +61,23 @@ } InetSocketAddress proxyAddress = new InetSocketAddress(host,port); HttpDestination destination = httpClient.getDestination(exchange.getAddress(), ssl); + + System.err.println("Matched destination "+destination); destination.setProxy(proxyAddress); + System.err.println("Set proxy "+host+":"+port+" on destination"); //set up authentication for the proxy Credentials proxyCredentials = server.getProxyCredentials(); - + if (proxyCredentials != null) { if (proxyCredentials.isCertificate()) throw new UnsupportedOperationException ("Proxy credential not supported"); else - destination.setProxyAuthentication(new ProxyAuthorization (proxyCredentials.getUser(), proxyCredentials.getPass())); + { + destination.setProxyAuthentication(new ProxyAuthorization (proxyCredentials.getUser(), proxyCredentials.getPass())); + System.err.println("Set proxy authentication: "+proxyCredentials.getUser()+":"+proxyCredentials.getPass()); + } } destination.send(exchange); } Modified: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/AuthenticatingJettyDeployerTest.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/AuthenticatingJettyDeployerTest.java?rev=689765&r1=689764&r2=689765&view=diff ============================================================================== --- maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/AuthenticatingJettyDeployerTest.java (original) +++ maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/AuthenticatingJettyDeployerTest.java Thu Aug 28 02:23:49 2008 @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.maven.mercury.spi.http.client; import java.net.URL; Modified: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/AuthenticatingJettyRetrieverTest.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/AuthenticatingJettyRetrieverTest.java?rev=689765&r1=689764&r2=689765&view=diff ============================================================================== --- maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/AuthenticatingJettyRetrieverTest.java (original) +++ maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/AuthenticatingJettyRetrieverTest.java Thu Aug 28 02:23:49 2008 @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.maven.mercury.spi.http.client; import java.net.URL; @@ -19,7 +37,8 @@ _port=String.valueOf(server.getPort()); HashSet<Server> remoteServerTypes = new HashSet<Server>(); - remoteServerType = new Server( "test", new URL(__HOST_FRAGMENT+_port), false, false, new Credentials("foo", "bar")); + remoteServerType = new Server( "test", new URL(__HOST_FRAGMENT+_port), false, false, + new Credentials(((AuthenticatingTestServer)server).getUsername(), ((AuthenticatingTestServer)server).getPassword())); factories = new HashSet<StreamVerifierFactory>(); remoteServerTypes.add(remoteServerType); Modified: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/JettyRetrieverTest.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/JettyRetrieverTest.java?rev=689765&r1=689764&r2=689765&view=diff ============================================================================== --- maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/JettyRetrieverTest.java (original) +++ maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/JettyRetrieverTest.java Thu Aug 28 02:23:49 2008 @@ -159,7 +159,7 @@ assert dir.canWrite(); return dir; } - + public void testSyncRetrievalAllGood() throws Exception { @@ -566,5 +566,5 @@ is.close(); os.close(); } - + } Added: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyDeployerTest.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyDeployerTest.java?rev=689765&view=auto ============================================================================== --- maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyDeployerTest.java (added) +++ maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyDeployerTest.java Thu Aug 28 02:23:49 2008 @@ -0,0 +1,84 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.maven.mercury.spi.http.client; + +import java.net.URL; +import java.util.HashSet; + +import org.apache.maven.mercury.crypto.api.StreamVerifierFactory; +import org.apache.maven.mercury.spi.http.client.deploy.DefaultDeployer; +import org.apache.maven.mercury.spi.http.server.AuthenticatingProxyServer; +import org.apache.maven.mercury.spi.http.server.AuthenticatingPutServer; +import org.apache.maven.mercury.transport.api.Credentials; + +public class ProxyJettyDeployerTest extends JettyDeployerTest +{ + + + AuthenticatingProxyServer _proxyServer; + String _proxyPort; + + + public ProxyJettyDeployerTest() throws Exception + { + super(); + } + protected void setUp() throws Exception + { + setUpFiles(); + //Set up a proxy server (which requires authentication) + _proxyServer = new AuthenticatingProxyServer(); + _proxyServer.start(); + _proxyPort = String.valueOf(_proxyServer.getPort()); + + _deployer = new DefaultDeployer(); + + //set up a target server (which requires authentication) + _putServer = new AuthenticatingPutServer(); + _putServer.start(); + _port = String.valueOf(_putServer.getPort()); + setUpServerType(); + } + + + + protected void setUpServerType () throws Exception + { + HashSet<org.apache.maven.mercury.transport.api.Server> remoteServerTypes = new HashSet<org.apache.maven.mercury.transport.api.Server>(); + remoteServerType = new org.apache.maven.mercury.transport.api.Server( "test", + new URL(_HOST_FRAGMENT+_port), + false, + false, + new Credentials(((AuthenticatingPutServer)_putServer).getUsername(), ((AuthenticatingPutServer)_putServer).getPassword()), + new URL(_HOST_FRAGMENT+_proxyPort), + new Credentials(_proxyServer.getUsername(), _proxyServer.getPassword())); + factories = new HashSet<StreamVerifierFactory>(); + remoteServerTypes.add(remoteServerType); + _deployer.setServers(remoteServerTypes); + } + + + + protected void tearDown() throws Exception + { + _proxyServer.stop(); + super.tearDown(); + } +} Propchange: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyDeployerTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyDeployerTest.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyDeployerTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyRetrieverTest.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyRetrieverTest.java?rev=689765&view=auto ============================================================================== --- maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyRetrieverTest.java (added) +++ maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyRetrieverTest.java Thu Aug 28 02:23:49 2008 @@ -0,0 +1,70 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.mercury.spi.http.client; + +import java.net.URL; +import java.util.HashSet; + +import org.apache.maven.mercury.crypto.api.StreamVerifierFactory; +import org.apache.maven.mercury.spi.http.client.retrieve.DefaultRetriever; +import org.apache.maven.mercury.spi.http.server.AuthenticatingProxyServer; +import org.apache.maven.mercury.spi.http.server.AuthenticatingTestServer; +import org.apache.maven.mercury.transport.api.Credentials; +import org.apache.maven.mercury.transport.api.Server; + +public class ProxyJettyRetrieverTest extends JettyRetrieverTest +{ + AuthenticatingProxyServer _proxyServer; + String _proxyPort; + + public void setUp () + throws Exception + { + //Set up a proxy server (which requires authentication) + _proxyServer = new AuthenticatingProxyServer(); + _proxyServer.start(); + _proxyPort = String.valueOf(_proxyServer.getPort()); + + //Set up the real target server (which requires authentication) + server = new AuthenticatingTestServer(); + server.start(); + _port=String.valueOf(server.getPort()); + + HashSet<Server> remoteServerTypes = new HashSet<Server>(); + remoteServerType = new Server( "test", new URL(__HOST_FRAGMENT+_port), + false, + false, + new Credentials(((AuthenticatingTestServer)server).getUsername(), ((AuthenticatingTestServer)server).getPassword()), + new URL(__HOST_FRAGMENT+_proxyPort), + new Credentials(_proxyServer.getUsername(), _proxyServer.getPassword())); + factories = new HashSet<StreamVerifierFactory>(); + + remoteServerTypes.add(remoteServerType); + + retriever = new DefaultRetriever(); + retriever.setServers(remoteServerTypes); + } + + + protected void tearDown() throws Exception + { + _proxyServer.stop(); + super.tearDown(); + } +} Propchange: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyRetrieverTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyRetrieverTest.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/client/ProxyJettyRetrieverTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/server/AuthenticatingPutServer.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/server/AuthenticatingPutServer.java?rev=689765&r1=689764&r2=689765&view=diff ============================================================================== --- maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/server/AuthenticatingPutServer.java (original) +++ maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/server/AuthenticatingPutServer.java Thu Aug 28 02:23:49 2008 @@ -8,14 +8,18 @@ public class AuthenticatingPutServer extends SimplePutServer { + private String _username = "foo"; + private String _password = "bar"; + private String _role = "foomeister"; + public AuthenticatingPutServer() throws Exception { super(); HashUserRealm realm = new HashUserRealm(); - realm.put ("foo", "bar"); - realm.addUserToRole("foo", "foomeister"); + realm.put (_username, _password); + realm.addUserToRole(_username, _role); realm.setName("foorealm"); SecurityHandler securityHandler = new SecurityHandler(); @@ -23,7 +27,7 @@ securityHandler.setUserRealm(realm); Constraint constraint = new Constraint(); constraint.setAuthenticate(true); - constraint.setRoles(new String[]{"foomeister"}); + constraint.setRoles(new String[]{_role}); ConstraintMapping cm = new ConstraintMapping(); cm.setConstraint(constraint); cm.setPathSpec("/*"); @@ -38,4 +42,14 @@ server.start(); server.join(); } + + public String getUsername() + { + return _username; + } + + public String getPassword () + { + return _password; + } } Modified: maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/server/AuthenticatingTestServer.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/server/AuthenticatingTestServer.java?rev=689765&r1=689764&r2=689765&view=diff ============================================================================== --- maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/server/AuthenticatingTestServer.java (original) +++ maven/sandbox/trunk/mercury/mercury-transport/mercury-transport-http/src/test/java/org/apache/maven/mercury/spi/http/server/AuthenticatingTestServer.java Thu Aug 28 02:23:49 2008 @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.maven.mercury.spi.http.server; import org.mortbay.jetty.security.BasicAuthenticator; @@ -8,14 +26,18 @@ public class AuthenticatingTestServer extends SimpleTestServer { + private static final String __username = "foo"; + private static final String __password = "bar"; + private static final String __role = "foomeister"; + public AuthenticatingTestServer() throws Exception { super(); HashUserRealm realm = new HashUserRealm(); - realm.put ("foo", "bar"); - realm.addUserToRole("foo", "foomeister"); + realm.put (__username, __password); + realm.addUserToRole(__username, __role); realm.setName("foorealm"); SecurityHandler securityHandler = new SecurityHandler(); @@ -23,7 +45,7 @@ securityHandler.setUserRealm(realm); Constraint constraint = new Constraint(); constraint.setAuthenticate(true); - constraint.setRoles(new String[]{"foomeister"}); + constraint.setRoles(new String[]{__role}); ConstraintMapping cm = new ConstraintMapping(); cm.setConstraint(constraint); cm.setPathSpec("/*"); @@ -31,4 +53,13 @@ context.addHandler(securityHandler); } + public String getUsername() + { + return __username; + } + + public String getPassword() + { + return __password; + } }