pax_global_header 0000666 0000000 0000000 00000000064 12411160572 0014511 g ustar 00root root 0000000 0000000 52 comment=e4fc74e6012f74aa31ac87c1a798f8858bba8498
JGlobus-JGlobus-Release-2.1.0/ 0000775 0000000 0000000 00000000000 12411160572 0015777 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/.gitignore 0000664 0000000 0000000 00000000224 12411160572 0017765 0 ustar 00root root 0000000 0000000 target
test-output
*.iml
*.rej
*.diff
*.orig
.idea
.project
.classpath
.settings
.idea~
.project~
.classpath~
.settings~
.gitignore~
*.java~
*.xml~
JGlobus-JGlobus-Release-2.1.0/LICENSE 0000664 0000000 0000000 00000026137 12411160572 0017015 0 ustar 00root root 0000000 0000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed 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.
JGlobus-JGlobus-Release-2.1.0/README.textile 0000664 0000000 0000000 00000004572 12411160572 0020344 0 ustar 00root root 0000000 0000000
***********
* JGlobus *
***********
https://github.com/jglobus/JGlobus/
The JGlobus project aims to provide the base portions of the Globus ecosystem
for the Java language.
The notable JARs part of the JGlobus project include:
- jsse / ssl-proxies: A GSI-enabled Java trustmanager.
- GSS: A secure sockets layer based on GSI from Globus.
- MyProxy: Support for the MyProxy server.
- GridFTP: Client-side GridFTP support.
- ssl-proxies-tomcat: Utility functions for integrating the GSI-enabled trustmanager into a Tomcat container.
- axis: Axis 1.4 support for the GSI-enabled trustmanager.
*****************
* Release Notes *
*****************
JGlobus 2.0.5 Release Notes
- This is the first release from github and distributed through Maven central, as opposed to globus.org
- This release addresses compatibility and performance issues with the IGTF CA bundle.
- Several forward-ports of bugs reported by dCache.org. In particular, a larger set of RDN are supported.
- CRLs are properly cached and reloaded, essential for running JGlobus as a trustmanager of a Java container.
jGlobus 2.0.4 Core Release Notes
- This release addresses internal security vulnerabilities that were identified in internal reviews in collaboration with the MyProxy team at NCSA.
- GSS Tomcat support was moved into its own Maven project.
jGlobus 2.0.3 Core Release Notes
- caGrid changes introduced in 2.0.2 were backed-out due to incompabilities discovered between those changes and the changes GSSContextImpl.
jGlobus 2.0.2 Core Release Notes
- Password fix to GSSContextImpl.java and additional contributions from caGrid.
jGlobus 2.0.1 Core Release Notes
- jGlobus 2.0.1 Core (download) is a bug-fix release that addresses an issue with signature verification.
- This issue was discovered and addresses by Jonathan Siwek at NCSA. Details of this fix can be found at https://github.com/jglobus/JGlobus/pull/10.
jGlobus 2.0.0 All Release Notes
- jGlobus 2.0.0 (download) replaces the use of pureTLS, as was used in jGlobus 1.x, with JSSE.
While this resulted in minor changes to the GSI API, the GRAM and GridFTP packages remain unchanged from jGlobus 1.X.
- A secondary goal was to drop or deprecated packages that are not strictly related to the use of Globus Toolkit.
This includes, for example, the removal of the MDS package, as MDS is no longer supported in Globus Toolkit 5.X.
- jGlobus now requires Java 1.5 or higher.
JGlobus-JGlobus-Release-2.1.0/axis/ 0000775 0000000 0000000 00000000000 12411160572 0016743 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/pom.xml 0000664 0000000 0000000 00000002560 12411160572 0020263 0 ustar 00root root 0000000 0000000
parent
org.jglobus
2.1.0
4.0.0
axisg
Apache AXIS support for JGlobus
axis
axis
axis
axis-jaxrpc
${project.groupId}
gss
${project.version}
commons-httpclient
commons-httpclient
javax.servlet
servlet-api
junit
junit
test
JGlobus-JGlobus-Release-2.1.0/axis/src/ 0000775 0000000 0000000 00000000000 12411160572 0017532 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/src/main/ 0000775 0000000 0000000 00000000000 12411160572 0020456 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/ 0000775 0000000 0000000 00000000000 12411160572 0021377 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/ 0000775 0000000 0000000 00000000000 12411160572 0022166 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/ 0000775 0000000 0000000 00000000000 12411160572 0023461 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/ 0000775 0000000 0000000 00000000000 12411160572 0024425 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/example/ 0000775 0000000 0000000 00000000000 12411160572 0026060 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/example/Client.java 0000664 0000000 0000000 00000006456 12411160572 0030154 0 ustar 00root root 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed 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.globus.axis.example;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.utils.Options;
import org.apache.axis.SimpleTargetedChain;
import org.apache.axis.transport.http.HTTPSender;
import org.globus.axis.transport.HTTPSSender;
import org.globus.axis.transport.GSIHTTPSender;
import org.globus.axis.gsi.GSIConstants;
import org.globus.axis.util.Util;
import org.globus.gsi.gssapi.auth.SelfAuthorization;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
public class Client {
public static void main(String [] args) {
Util.registerTransport();
try {
Options options = new Options(args);
String endpointURL = options.getURL();
String textToSend;
args = options.getRemainingArgs();
if ((args == null) || (args.length < 1)) {
textToSend = "";
} else {
textToSend = args[0];
}
// these transport handlers would normally
// be configured in client-config.wsdd file
SimpleProvider provider = new SimpleProvider();
SimpleTargetedChain c = null;
c = new SimpleTargetedChain(new GSIHTTPSender());
provider.deployTransport("httpg", c);
c = new SimpleTargetedChain(new HTTPSSender());
provider.deployTransport("https", c);
c = new SimpleTargetedChain(new HTTPSender());
provider.deployTransport("http", c);
// only necessary becuase of Options.getURL()
// re-initializes Call settings
Util.reregisterTransport();
Service service = new Service(provider);
Call call = (Call) service.createCall();
// set globus credentials
/*
call.setProperty(GSIConstants.GSI_CREDENTIALS,
cred);
*/
// sets authorization type
call.setProperty(GSIConstants.GSI_AUTHORIZATION,
SelfAuthorization.getInstance());
// sets gsi mode
call.setProperty(GSIConstants.GSI_MODE,
GSIConstants.GSI_MODE_LIMITED_DELEG);
call.setTargetEndpointAddress( new URL(endpointURL) );
call.setOperationName(new QName("MyService",
"serviceMethod"));
call.addParameter( "arg1",
XMLType.XSD_STRING,
ParameterMode.IN);
call.setReturnType( XMLType.XSD_STRING );
String ret = (String) call.invoke( new Object[] { textToSend } );
System.out.println("Service response : " + ret);
} catch (Exception e) {
e.printStackTrace();
}
}
}
JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/example/MyService.jws 0000664 0000000 0000000 00000004476 12411160572 0030526 0 ustar 00root root 0000000 0000000 /*
This file is licensed under the terms of the Globus Toolkit Public
License, found at http://www.globus.org/toolkit/download/license.html.
*/
import javax.servlet.http.HttpServletRequest;
import org.apache.axis.MessageContext;
import org.apache.axis.transport.http.HTTPConstants;
import org.globus.axis.util.Util;
import org.globus.axis.gsi.GSIConstants;
import org.globus.axis.handler.CredentialHandler;
import org.ietf.jgss.GSSCredential;
public class MyService {
public String serviceMethod(String arg) {
MessageContext ctx = MessageContext.getCurrentContext();
setUpEnv(ctx);
GSSCredential cred =
(GSSCredential)ctx.getProperty(GSIConstants.GSI_CREDENTIALS);
System.out.println("MyService called with arg : " + arg);
System.out.println("Delegated credentials : " + cred);
StringBuffer buf = new StringBuffer();
buf.append("User '").append(ctx.getProperty(GSIConstants.GSI_USER_DN));
buf.append("' authorized locally as '");
buf.append(ctx.getProperty(GSIConstants.GSI_AUTH_USERNAME));
buf.append("' sent the following message: ");
buf.append(arg);
return buf.toString();
}
/**
* This is just for testing purposes. These properties are set automatically
* if CredentialHandler is deployed in server-config.wsdd file.
*/
private void setUpEnv(MessageContext msgContext) {
Object tmp = msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
if ((tmp == null) || !(tmp instanceof HttpServletRequest)) {
return;
}
HttpServletRequest req = (HttpServletRequest)tmp;
// if httpg is access protocol in servlet engine, axis
// will not set the TRANS_URL property correctly.
// this is a workaround for that problem
String url = req.getRequestURL().toString();
tmp = msgContext.getProperty(MessageContext.TRANS_URL);
if (tmp == null && url != null) {
msgContext.setProperty(MessageContext.TRANS_URL, url);
}
tmp = req.getAttribute(GSIConstants.GSI_CREDENTIALS);
if (tmp != null) {
msgContext.setProperty(GSIConstants.GSI_CREDENTIALS, tmp);
}
tmp = req.getAttribute(GSIConstants.GSI_AUTH_USERNAME);
if (tmp != null) {
msgContext.setProperty(GSIConstants.GSI_AUTH_USERNAME, tmp);
}
tmp = req.getAttribute(GSIConstants.GSI_USER_DN);
if (tmp != null) {
msgContext.setProperty(GSIConstants.GSI_USER_DN, tmp);
}
}
}
JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/example/README.txt 0000664 0000000 0000000 00000002255 12411160572 0027562 0 ustar 00root root 0000000 0000000 I. Configure HTTPG Connector as described in TOMCAT_INSTALL.TXT
II. Deploy Axis on Tomcat
Please look at the Axis Installation Guide for details.
For normal use please install the CredentialHandler as described
below. For testing purposes of the MyService example this step
is not necessary.
Modify the server-config.wsdd and add CredentialHandler handler to
the section of the block, e.g.:
...
...
III. Deploy MyService to Axis
Copy MyService.jws file to Tomcat's webapps/axis/ directory.
IV. Connect to MyService
To run the client (assuming MyService is deployed on Tomcat server) type:
java org.globus.axis.example.Client -l httpg://127.0.0.1:8443/axis/MyService.jws "hello"
Note: you must specify the 'httpg' as the url protocol.
Add all jar files inside lib/ and build/ to the classpath. Also include
all jar files in Axis lib/ directory and xerces.jar (xerces.jar can be
found in Tomcat's common/lib directory.
JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/gsi/ 0000775 0000000 0000000 00000000000 12411160572 0025207 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/gsi/GSIConstants.java 0000664 0000000 0000000 00000003070 12411160572 0030371 0 ustar 00root root 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed 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.globus.axis.gsi;
public interface GSIConstants extends org.globus.gsi.GSIConstants {
public static final String
GSI_CREDENTIALS = "org.globus.gsi.credentials",
GSI_AUTHORIZATION = "org.globus.gsi.authorization",
GSI_MODE = "org.globus.gsi.mode",
GSI_AUTH_USERNAME = "org.globus.gsi.authorized.user.name",
GSI_USER_DN = "org.globus.gsi.authorized.user.dn",
GSI_ANONYMOUS = "org.globus.gsi.anonymous",
GSI_CONTEXT = "org.globus.gsi.context";
/* this is just a hack for now
* something more type safe will be
* much better */
public static final String
/* behaves just like a regular ssl socket */
GSI_MODE_SSL = "ssl",
/* send no delegation character */
GSI_MODE_NO_DELEG = "gsi",
/* performs full delegation */
GSI_MODE_FULL_DELEG = "gsifull",
/* performs limited delegation - default */
GSI_MODE_LIMITED_DELEG = "gsilimited";
}
JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/handler/ 0000775 0000000 0000000 00000000000 12411160572 0026042 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/handler/CredentialHandler.java 0000664 0000000 0000000 00000010346 12411160572 0032261 0 ustar 00root root 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed 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.globus.axis.handler;
import javax.servlet.http.HttpServletRequest;
import javax.security.auth.Subject;
import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.transport.http.HTTPConstants;
import org.globus.axis.gsi.GSIConstants;
import org.globus.gsi.gssapi.jaas.GlobusPrincipal;
import org.globus.gsi.gssapi.jaas.UserNamePrincipal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSException;
/**
* Axis server-side request handler. To be used only in when deployed in
* Tomcat.
*/
public class CredentialHandler extends BasicHandler {
private static Log log =
LogFactory.getLog(CredentialHandler.class.getName());
// must match the PEER_SUBJECT in security code
private static final String CALLER_SUBJECT =
"callerSubject";
public void invoke(MessageContext msgContext) throws AxisFault {
log.debug("Enter: invoke");
Object tmp = msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
if ((tmp == null) || !(tmp instanceof HttpServletRequest)) {
return;
}
HttpServletRequest req = (HttpServletRequest)tmp;
// if httpg is access protocol in servlet engine, axis
// will not set the TRANS_URL property correctly.
// this is a workaround for that problem
String url = req.getRequestURL().toString();
tmp = msgContext.getProperty(MessageContext.TRANS_URL);
if (tmp == null && url != null) {
msgContext.setProperty(MessageContext.TRANS_URL, url);
}
Subject subject = getSubject(msgContext);
// USER_DN is set by both HTTPS/HTTPG valves
tmp = req.getAttribute(GSIConstants.GSI_USER_DN);
if (tmp != null) {
msgContext.setProperty(GSIConstants.GSI_USER_DN, tmp);
subject.getPrincipals().add(new GlobusPrincipal((String)tmp));
}
// GSI_CONTEXT is set by HTTPS valve only
tmp = req.getAttribute(GSIConstants.GSI_CONTEXT);
if (tmp != null) {
msgContext.setProperty(GSIConstants.GSI_CONTEXT, tmp);
GSSContext ctx = (GSSContext)tmp;
try {
if (ctx.getDelegCred() != null) {
subject.getPrivateCredentials().add(ctx.getDelegCred());
}
} catch (GSSException e) {
log.warn("Unable to obtain delegated credentials", e);
}
}
// GSI_CREDENTIALS is set only by HTTPG valve
tmp = req.getAttribute(GSIConstants.GSI_CREDENTIALS);
if (tmp != null) {
log.debug("Delegation performed. Setting credentials property.");
msgContext.setProperty(GSIConstants.GSI_CREDENTIALS, tmp);
subject.getPrivateCredentials().add(tmp);
} else {
log.debug("Delegation not performed. Not setting credentials property.");
}
// GSI_AUTH_USERNAM is set only by HTTPG Valve
tmp = req.getAttribute(GSIConstants.GSI_AUTH_USERNAME);
if (tmp != null) {
msgContext.setProperty(GSIConstants.GSI_AUTH_USERNAME, tmp);
subject.getPrincipals().add(new UserNamePrincipal((String)tmp));
}
log.debug("Exit: invoke");
}
protected Subject getSubject(MessageContext msgCtx) {
Subject subject =
(Subject)msgCtx.getProperty(CALLER_SUBJECT);
if (subject == null) {
subject = new Subject();
msgCtx.setProperty(CALLER_SUBJECT, subject);
}
return subject;
}
}
JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/transport/ 0000775 0000000 0000000 00000000000 12411160572 0026461 5 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/transport/GSIHTTPSender.java 0000664 0000000 0000000 00000013137 12411160572 0031614 0 ustar 00root root 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed 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.globus.axis.transport;
import java.io.IOException;
import org.apache.axis.MessageContext;
import org.apache.axis.components.net.BooleanHolder;
import org.apache.axis.transport.http.SocketHolder;
import org.apache.axis.transport.http.HTTPSender;
import org.gridforum.jgss.ExtendedGSSContext;
import org.gridforum.jgss.ExtendedGSSManager;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSManager;
import org.ietf.jgss.GSSName;
import org.ietf.jgss.Oid;
import org.globus.axis.util.Util;
import org.globus.gsi.GSIConstants;
import org.globus.gsi.TrustedCertificates;
import org.globus.gsi.gssapi.GSSConstants;
import org.globus.gsi.gssapi.net.GssSocketFactory;
import org.globus.gsi.gssapi.net.GssSocket;
import org.globus.gsi.gssapi.auth.Authorization;
import org.globus.gsi.gssapi.auth.GSSAuthorization;
import org.globus.gsi.gssapi.auth.HostAuthorization;
/**
* This is meant to be used on a SOAP Client to call a SOAP server.
*
This code is based on Axis HTTPSender.java code.
*/
public class GSIHTTPSender extends HTTPSender {
protected void getSocket(SocketHolder sockHolder,
MessageContext msgContext,
String protocol,
String host, int port, int timeout,
StringBuffer otherHeaders,
BooleanHolder useFullURL)
throws Exception {
if (!protocol.equalsIgnoreCase("httpg")) {
throw new IOException("Invalid protocol");
}
GSSCredential cred = null;
Authorization auth = null;
String mode = null;
auth = (Authorization)Util.getProperty(msgContext,
GSIHTTPTransport.GSI_AUTHORIZATION);
mode = (String)Util.getProperty(msgContext,
GSIHTTPTransport.GSI_MODE);
if (auth == null) {
auth = HostAuthorization.getInstance();
}
if (mode == null) {
mode = GSIHTTPTransport.GSI_MODE_NO_DELEG;
}
GSSManager manager = ExtendedGSSManager.getInstance();
ExtendedGSSContext context = null;
Boolean anonymous = (Boolean) Util.getProperty(
msgContext, GSIHTTPTransport.GSI_ANONYMOUS);
if (anonymous != null && anonymous.equals(Boolean.TRUE)) {
GSSName name = manager.createName((String)null,
(Oid)null);
cred = manager.createCredential(
name,
GSSCredential.DEFAULT_LIFETIME,
(Oid)null,
GSSCredential.INITIATE_ONLY);
} else {
cred = (GSSCredential)Util.getProperty(
msgContext, GSIHTTPTransport.GSI_CREDENTIALS);
}
GSSName expectedName = null;
if (auth instanceof GSSAuthorization) {
GSSAuthorization gssAuth = (GSSAuthorization)auth;
expectedName = gssAuth.getExpectedName(cred, host);
}
context =
(ExtendedGSSContext)manager.createContext(expectedName,
GSSConstants.MECH_OID,
cred,
GSSContext.DEFAULT_LIFETIME);
if (mode.equalsIgnoreCase(GSIHTTPTransport.GSI_MODE_LIMITED_DELEG)) {
context.requestCredDeleg(true);
context.setOption(GSSConstants.DELEGATION_TYPE,
GSIConstants.DELEGATION_TYPE_LIMITED);
} else if (mode.equalsIgnoreCase(GSIHTTPTransport.GSI_MODE_FULL_DELEG)) {
context.requestCredDeleg(true);
context.setOption(GSSConstants.DELEGATION_TYPE,
GSIConstants.DELEGATION_TYPE_FULL);
} else if (mode.equalsIgnoreCase(GSIHTTPTransport.GSI_MODE_NO_DELEG)) {
context.requestCredDeleg(false);
} else if (mode.equalsIgnoreCase(GSIHTTPTransport.GSI_MODE_SSL)) {
context.setOption(GSSConstants.GSS_MODE,
GSIConstants.MODE_SSL);
} else {
throw new Exception("Invalid GSI MODE: " + mode);
}
TrustedCertificates trustedCerts =
(TrustedCertificates)Util.getProperty(msgContext,
GSIHTTPTransport
.TRUSTED_CERTIFICATES);
if (trustedCerts != null) {
context.setOption(GSSConstants.TRUSTED_CERTIFICATES,
trustedCerts);
}
Boolean authzRequiredWithDelegation =
(Boolean)Util.getProperty(msgContext,
GSIConstants
.AUTHZ_REQUIRED_WITH_DELEGATION);
if (authzRequiredWithDelegation != null) {
context.setOption(GSSConstants.AUTHZ_REQUIRED_WITH_DELEGATION,
authzRequiredWithDelegation);
}
GssSocketFactory factory = GssSocketFactory.getDefault();
int lport = (port == -1) ? 8443 : port;
super.getSocket(sockHolder, msgContext, "http", host,
lport, timeout, otherHeaders, useFullURL);
GssSocket gsiSocket =
(GssSocket)factory.createSocket(sockHolder.getSocket(),
host, lport, context);
gsiSocket.setAuthorization(auth);
sockHolder.setSocket(gsiSocket);
}
}
JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/transport/GSIHTTPTransport.java 0000664 0000000 0000000 00000006275 12411160572 0032375 0 ustar 00root root 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed 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.globus.axis.transport;
import org.apache.axis.AxisEngine;
import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.client.Call;
import org.apache.axis.client.Transport;
import org.apache.axis.transport.http.HTTPConstants;
import org.globus.axis.gsi.GSIConstants;
/**
* Extends Transport by implementing the setupMessageContext function to
* set HTTP-specific message context fields and transport chains.
* May not even be necessary if we arrange things differently somehow.
* Can hold state relating to URL properties.
*
This code is based on Axis HTTPTransport.java code.
*/
public class GSIHTTPTransport extends Transport implements GSIConstants
{
public static final String DEFAULT_TRANSPORT_NAME = "httpg";
/**
* HTTP properties
*/
public static final String URL = MessageContext.TRANS_URL;
private String cookie;
private String cookie2;
private String action;
public GSIHTTPTransport () {
transportName = DEFAULT_TRANSPORT_NAME;
}
/**
* helper constructor
*/
public GSIHTTPTransport (String url, String action)
{
transportName = DEFAULT_TRANSPORT_NAME;
this.url = url;
this.action = action;
}
/**
* Set up any transport-specific derived properties in the message context.
* @param mc the context to set up
* @param call the client service instance
* @param engine the engine containing the registries
* @throws AxisFault if service cannot be found
*/
public void setupMessageContextImpl(MessageContext mc,
Call call,
AxisEngine engine)
throws AxisFault
{
if (action != null) {
mc.setUseSOAPAction(true);
mc.setSOAPActionURI(action);
}
// Set up any cookies we know about
if (cookie != null)
mc.setProperty(HTTPConstants.HEADER_COOKIE, cookie);
if (cookie2 != null)
mc.setProperty(HTTPConstants.HEADER_COOKIE2, cookie2);
// Allow the SOAPAction to determine the service, if the service
// (a) has not already been determined, and (b) if a service matching
// the soap action has been deployed.
if (mc.getService() == null) {
mc.setTargetService( (String)mc.getSOAPActionURI() );
}
}
public void processReturnedMessageContext(MessageContext context) {
cookie = context.getStrProp(HTTPConstants.HEADER_COOKIE);
cookie2 = context.getStrProp(HTTPConstants.HEADER_COOKIE2);
}
}
JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/transport/HTTPSSender.java 0000664 0000000 0000000 00000004007 12411160572 0031370 0 ustar 00root root 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed 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.globus.axis.transport;
import java.io.IOException;
import org.apache.axis.MessageContext;
import org.apache.axis.components.net.BooleanHolder;
import org.apache.axis.transport.http.SocketHolder;
import org.apache.axis.transport.http.HTTPSender;
import org.globus.gsi.gssapi.net.GssSocket;
/**
* This is meant to be used on a SOAP Client to call a SOAP server.
*
This code is based on Axis HTTPSender.java code.
*/
public class HTTPSSender extends HTTPSender {
protected void getSocket(SocketHolder sockHolder,
MessageContext msgContext,
String protocol,
String host, int port, int timeout,
StringBuffer otherHeaders,
BooleanHolder useFullURL)
throws Exception {
if (!protocol.equalsIgnoreCase("https")) {
throw new IOException("Invalid protocol");
}
int lport = (port == -1) ? 8443 : port;
SSLContextHelper helper = new SSLContextHelper(msgContext,
host,
lport);
super.getSocket(sockHolder, msgContext, "http", host,
lport, timeout, otherHeaders, useFullURL);
GssSocket gsiSocket = helper.wrapSocket(sockHolder.getSocket());
sockHolder.setSocket(gsiSocket);
}
}
JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/transport/HTTPSTransport.java 0000664 0000000 0000000 00000002521 12411160572 0032143 0 ustar 00root root 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed 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.globus.axis.transport;
/**
* Extends Transport by implementing the setupMessageContext function to
* set HTTP-specific message context fields and transport chains.
* May not even be necessary if we arrange things differently somehow.
* Can hold state relating to URL properties.
*
This code is based on Axis HTTPTransport.java code.
*/
public class HTTPSTransport extends GSIHTTPTransport
{
public static final String DEFAULT_TRANSPORT_NAME = "https";
public HTTPSTransport () {
transportName = DEFAULT_TRANSPORT_NAME;
}
/**
* helper constructor
*/
public HTTPSTransport (String url, String action) {
super(url, action);
transportName = DEFAULT_TRANSPORT_NAME;
}
}
JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/transport/HTTPUtils.java 0000664 0000000 0000000 00000010563 12411160572 0031131 0 ustar 00root root 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed 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.globus.axis.transport;
import java.util.Hashtable;
import javax.xml.rpc.Stub;
import org.apache.axis.MessageContext;
import org.apache.axis.transport.http.HTTPConstants;
public class HTTPUtils {
public static final String DISABLE_CHUNKING =
"transport.http.disableChunking";
/**
* Sets connection timeout.
*
* @param stub The stub to set the property on
* @param timeout the new timeout value in milliseconds
*/
public static void setTimeout(Stub stub, int timeout) {
if (stub instanceof org.apache.axis.client.Stub) {
((org.apache.axis.client.Stub)stub).setTimeout(timeout);
}
}
/**
* Sets on option on the stub to close the connection
* after receiving the reply (connection will not
* be reused).
*
* @param stub The stub to set the property on
* @param close If true, connection close will be requested. Otherwise
* connection close will not be requested.
*/
public static void setCloseConnection(Stub stub, boolean close) {
Hashtable headers = getRequestHeaders(stub);
if (close) {
headers.put(HTTPConstants.HEADER_CONNECTION,
HTTPConstants.HEADER_CONNECTION_CLOSE);
} else {
headers.remove(HTTPConstants.HEADER_CONNECTION);
}
}
/**
* Sets on option on the stub to control what HTTP protocol
* version should be used.
*
* @param stub The stub to set the property on
* @param enable If true, HTTP 1.0 will be used. If false, HTTP 1.1
* will be used.
*/
public static void setHTTP10Version(Stub stub, boolean enable) {
setHTTPVersion(stub, enable);
}
/**
* Sets on option on the stub to control what HTTP protocol
* version should be used.
*
* @param stub The stub to set the property on
* @param http10 If true, HTTP 1.0 will be used. Otherwise HTTP 1.1
* will be used.
*/
public static void setHTTPVersion(Stub stub, boolean http10) {
stub._setProperty(MessageContext.HTTP_TRANSPORT_VERSION,
(http10)
? HTTPConstants.HEADER_PROTOCOL_V10
: HTTPConstants.HEADER_PROTOCOL_V11);
}
/**
* Sets on option on the stub to use to enable or disable chunked encoding
* (only if used with HTTP 1.1).
*
* @param stub The stub to set the property on
* @param enable If true, chunked encoding will be enabled. If false,
* chunked encoding will be disabled.
*/
public static void setChunkedEncoding(Stub stub, boolean enable) {
setDisableChunking(stub, !enable);
}
/**
* Sets on option on the stub to use to disable chunking
* (only if used with HTTP 1.1).
*
* @param stub The stub to set the property on
* @param disable If true, chunking will be disabled. Otherwise chunking
* will be performed (if HTTP 1.1 will be used).
*/
public static void setDisableChunking(Stub stub, boolean disable) {
stub._setProperty(DISABLE_CHUNKING,
(disable)
? Boolean.TRUE
: Boolean.FALSE);
Hashtable headers = getRequestHeaders(stub);
headers.put(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED,
(disable) ? "false" : "true");
}
private static Hashtable getRequestHeaders(Stub stub) {
Hashtable headers =
(Hashtable)stub._getProperty(HTTPConstants.REQUEST_HEADERS);
if (headers == null) {
headers = new Hashtable();
stub._setProperty(HTTPConstants.REQUEST_HEADERS, headers);
}
return headers;
}
}
JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/transport/SSLContextHelper.java 0000664 0000000 0000000 00000012533 12411160572 0032476 0 ustar 00root root 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed 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.globus.axis.transport;
import java.net.Socket;
import org.apache.axis.MessageContext;
import org.gridforum.jgss.ExtendedGSSContext;
import org.gridforum.jgss.ExtendedGSSManager;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;
import org.ietf.jgss.GSSManager;
import org.ietf.jgss.GSSName;
import org.ietf.jgss.Oid;
import org.globus.axis.util.Util;
import org.globus.gsi.GSIConstants;
import org.globus.gsi.TrustedCertificates;
import org.globus.gsi.gssapi.GSSConstants;
import org.globus.gsi.gssapi.auth.Authorization;
import org.globus.gsi.gssapi.auth.HostOrSelfAuthorization;
import org.globus.gsi.gssapi.net.GssSocket;
import org.globus.gsi.gssapi.net.GssSocketFactory;
/**
* This is meant to be used on a SOAP Client to call a SOAP server.
*
This code is based on Axis HTTPSender.java code.
*/
public class SSLContextHelper {
private String host;
private int port;
private Authorization myAuth;
private ExtendedGSSContext myContext;
public SSLContextHelper(MessageContext msgContext,
String host, int port)
throws GSSException {
Authorization auth = (Authorization)Util.getProperty(msgContext,
GSIHTTPTransport.GSI_AUTHORIZATION);
Boolean anonymous = (Boolean)Util.getProperty(msgContext,
GSIHTTPTransport.GSI_ANONYMOUS);
GSSCredential cred = (GSSCredential)Util.getProperty(msgContext,
GSIHTTPTransport.GSI_CREDENTIALS);
Integer protection = (Integer)Util.getProperty(msgContext,
GSIConstants.GSI_TRANSPORT);
TrustedCertificates trustedCerts =
(TrustedCertificates)Util.getProperty(msgContext,
GSIHTTPTransport
.TRUSTED_CERTIFICATES);
init(host, port,
auth, anonymous, cred, protection, trustedCerts);
}
public SSLContextHelper(String host, int port,
Authorization auth,
Boolean anonymous,
GSSCredential cred,
Integer protection,
TrustedCertificates trustedCerts)
throws GSSException {
init(host, port,
auth, anonymous, cred, protection, trustedCerts);
}
protected void init(String host, int port,
Authorization auth,
Boolean anonymous,
GSSCredential cred,
Integer protection,
TrustedCertificates trustedCerts)
throws GSSException {
this.host = host;
this.port = port;
if (auth == null) {
auth = HostOrSelfAuthorization.getInstance();
}
GSSManager manager = ExtendedGSSManager.getInstance();
boolean anon = false;
if (anonymous != null && anonymous.equals(Boolean.TRUE)) {
anon = true;
}
if (anon) {
GSSName name = manager.createName((String)null,
(Oid)null);
cred = manager.createCredential(
name,
GSSCredential.DEFAULT_LIFETIME,
(Oid)null,
GSSCredential.INITIATE_ONLY);
}
// Expected name is null since delegation is never
// done. Custom authorization is invoked after handshake is finished.
ExtendedGSSContext context =(ExtendedGSSContext)manager
.createContext(null,
GSSConstants.MECH_OID,
cred,
GSSContext.DEFAULT_LIFETIME);
if (anon) {
context.requestAnonymity(true);
}
context.setOption(GSSConstants.GSS_MODE, GSIConstants.MODE_SSL);
if (GSIConstants.ENCRYPTION.equals(protection)) {
context.requestConf(true);
} else {
context.requestConf(false);
}
if (trustedCerts != null) {
context.setOption(GSSConstants.TRUSTED_CERTIFICATES, trustedCerts);
}
this.myContext = context;
this.myAuth = auth;
}
public GssSocket wrapSocket(Socket socket) {
GssSocketFactory factory = GssSocketFactory.getDefault();
GssSocket gsiSocket =
(GssSocket)factory.createSocket(socket,
this.host,
this.port,
this.myContext);
gsiSocket.setAuthorization(this.myAuth);
return gsiSocket;
}
}
JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/transport/commons/ 0000775 0000000 0000000 00000000000 12411160572 0030134 5 ustar 00root root 0000000 0000000 CommonsHttpConnectionManager.java 0000664 0000000 0000000 00000022046 12411160572 0036512 0 ustar 00root root 0000000 0000000 JGlobus-JGlobus-Release-2.1.0/axis/src/main/java/org/globus/axis/transport/commons /*
* Copyright 1999-2006 University of Chicago
*
* Licensed 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.globus.axis.transport.commons;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.httpclient.HttpConnection;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.params.HostParams;
import org.apache.commons.httpclient.params.HttpConnectionParams;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.util.IdleConnectionTimeoutThread;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class CommonsHttpConnectionManager implements HttpConnectionManager {
private static final IdleConnectionTimeoutThread IDLE_THREAD;
static {
IDLE_THREAD = new IdleConnectionTimeoutThread();
IDLE_THREAD.setTimeoutInterval(1000 * 60 * 2);
IDLE_THREAD.start();
}
private static Log logger =
LogFactory.getLog(CommonsHttpConnectionManager.class);
private String [] hostConfigurationParams;
private HashMap hostPoolMap;
private long idleTime = 1000 * 60 * 2;
private boolean staleChecking = true;
private HttpConnectionManagerParams params =
new HttpConnectionManagerParams();
public CommonsHttpConnectionManager(String [] hostConfigurationParams) {
this.hostConfigurationParams = hostConfigurationParams;
this.hostPoolMap = new HashMap();
IDLE_THREAD.addConnectionManager(this);
}
public void setConnectionIdleTime(long time) {
this.idleTime = time;
}
public long getConnectionIdleTime() {
return this.idleTime;
}
public void setStaleCheckingEnabled(boolean staleChecking) {
this.staleChecking = staleChecking;
}
public boolean isStaleCheckingEnabled() {
return this.staleChecking;
}
public HttpConnection getConnection(HostConfiguration hostConfiguration) {
return getConnectionWithTimeout(hostConfiguration, 0);
}
public HttpConnection getConnection(HostConfiguration hostConfiguration,
long timeout) {
return getConnectionWithTimeout(hostConfiguration, timeout);
}
public HttpConnection getConnectionWithTimeout(
HostConfiguration hostConfiguration, long timeout) {
ExtendedHostConfiguration extendedHostConfiguration =
new ExtendedHostConfiguration(hostConfiguration,
this.hostConfigurationParams);
ConnectionPool pool = getConnectionPool(extendedHostConfiguration);
ExtendedHttpConnection httpConnection = pool.getPooledConnection();
if (httpConnection == null) {
// not in the pool - create a new connection
httpConnection = getNewConnection(extendedHostConfiguration);
httpConnection.setFromPool(false);
} else {
httpConnection.setFromPool(true);
}
if (this.staleChecking) {
// install our retry handler
hostConfiguration.getParams().setParameter(
HttpMethodParams.RETRY_HANDLER,
httpConnection.getRetryHandler());
}
return httpConnection;
}
private ExtendedHttpConnection getNewConnection(
HostConfiguration hostConfiguration) {
ExtendedHttpConnection httpConnection =
new ExtendedHttpConnection(hostConfiguration, this.staleChecking);
httpConnection.setHttpConnectionManager(this);
HttpConnectionParams connectionParams = httpConnection.getParams();
connectionParams.setDefaults(this.params);
if (this.hostConfigurationParams != null) {
HostParams hostParams = hostConfiguration.getParams();
for (int i=0;i