Author: tyrell
Date: Wed May 14 09:17:06 2008
New Revision: 16993
Log:
Adding UI code to handle per user keystores.
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
trunk/mashup/java/modules/coreservices/servicesharinghelper/src/org/wso2/mashup/coreservices/servicesharinghelper/ServiceSharingHelper.java
trunk/mashup/java/modules/www/js/mashup-utils.js
trunk/mashup/java/modules/www/js/services.js
trunk/mashup/java/modules/www/taskbar.jsp
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
==============================================================================
---
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
(original)
+++
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
Wed May 14 09:17:06 2008
@@ -208,7 +208,7 @@
public void uploadMashupService(String destinationServerAddress,
DataHandler dataHandler,
ConfigurationContext configCtx, String
serviceJsFileName,
String mashupServiceName, String username,
String password,
- String overwriteExisting)
+ String overwriteExisting, String
localUserName)
throws IOException{
if (destinationServerAddress.startsWith("http://")) {
@@ -235,10 +235,13 @@
options.setProperty(HTTPConstants.CHUNKED, "false");
options.setProperty(Constants.Configuration.ENABLE_MTOM,
Constants.VALUE_TRUE);
- // Creating a custom protocol based on the user's keystores and
trusted certs within
- ProtocolSocketFactory psf = new
CustomProtocolSocketFactory(MashupUtils.getUserKeystoreResource(null,
configCtx));
- Protocol protocol = new Protocol("https", psf, 443);
- options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER, protocol);
+ // Creating a custom protocol based on the user's keystores and
trusted certs within
+ if (localUserName != null) {
+ ProtocolSocketFactory psf = new CustomProtocolSocketFactory(
+ MashupUtils.getUserKeystoreResource(localUserName));
+ Protocol protocol = new Protocol("custom-https", psf, 443);
+ options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER,
protocol);
+ }
QName opAddEntry = new
QName("http://service.share.mashup.wso2.org/xsd", "shareMashup");
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
Wed May 14 09:17:06 2008
@@ -1032,24 +1032,17 @@
}
- public static Resource getUserKeystoreResource(String userName,
ConfigurationContext configCtx){
-
+ public static Resource getUserKeystoreResource(String userName){
+ ServerManager serverManager = ServerManager.getInstance();
+ ConfigurationContext configContext = serverManager.configContext;
EmbeddedRegistry embeddedRegistry =
- (EmbeddedRegistry)
configCtx.getAxisConfiguration().getParameterValue(
+ (EmbeddedRegistry)
configContext.getAxisConfiguration().getParameterValue(
RegistryConstants.REGISTRY);
+
try {
UserRegistry systemRegistry = embeddedRegistry.getSystemRegistry();
-
- // If a user name is provided using that, else using the currently
logged in user's name.
- String path = "";
- if(userName != null){
- path = MashupConstants.USERS_PATH + "/" + userName +
MashupConstants.USER_KEYSTORE_PATH;
- }else{
- path = MashupConstants.USERS_PATH + "/" +
systemRegistry.getUserName() + MashupConstants.USER_KEYSTORE_PATH;
- }
-
+ String path = MashupConstants.USERS_PATH + "/" + userName +
MashupConstants.USER_KEYSTORE_PATH;
return systemRegistry.get(path);
-
} catch (RegistryException e) {
log.error(e);
}
Modified:
trunk/mashup/java/modules/coreservices/servicesharinghelper/src/org/wso2/mashup/coreservices/servicesharinghelper/ServiceSharingHelper.java
==============================================================================
---
trunk/mashup/java/modules/coreservices/servicesharinghelper/src/org/wso2/mashup/coreservices/servicesharinghelper/ServiceSharingHelper.java
(original)
+++
trunk/mashup/java/modules/coreservices/servicesharinghelper/src/org/wso2/mashup/coreservices/servicesharinghelper/ServiceSharingHelper.java
Wed May 14 09:17:06 2008
@@ -47,7 +47,7 @@
public Boolean shareService(String serviceName, String username, String
password,
String destinationServerAddress, String
overwriteExisting,
- String migrateTags)
+ String migrateTags, String localUser)
throws IOException {
boolean success;
File serviceFile;
@@ -92,7 +92,7 @@
serviceName.substring(serviceName.indexOf(MashupConstants.SEPARATOR_CHAR) + 1);
masshupArchiveManupulator.uploadMashupService(destinationServerAddress,
dataHandler,
configContext,
serviceFile.getName(),
- shortServiceName,
username, password, overwriteExisting);
+ shortServiceName,
username, password, overwriteExisting, localUser);
log
.info("Shared Service \'" + serviceName + "' to the
destination server"
+ destinationServerAddress + " at " +
date.format(currentTime) + "from "
Modified: trunk/mashup/java/modules/www/js/mashup-utils.js
==============================================================================
--- trunk/mashup/java/modules/www/js/mashup-utils.js (original)
+++ trunk/mashup/java/modules/www/js/mashup-utils.js Wed May 14 09:17:06 2008
@@ -156,7 +156,7 @@
* @method showMashupSharingDialog
* @param {String} serviceName The name of the service elected to share
*/
-WSO2.MashupUtils.showMashupSharingDialog = function (serviceName) {
+WSO2.MashupUtils.showMashupSharingDialog = function (serviceName,
localUserName) {
//Creating the content div
var strFrmService = '<table align="center" border="0">' +
@@ -167,13 +167,13 @@
'<tr><td nowrap height="25"><b>Destination Server
Username: </b></td><td><input name="txtDestUsername" type="text"
id="txtDestUsername" size="50"/></td></tr>' +
'<tr><td nowrap height="25"><b>Destination Server
Password: </b></td><td><input name="txtDestPassword" type="password"
id="txtDestPassword" size="50"/></td></tr>' +
'<tr><td></td><td nowrap height="30"
valign="bottom"><input type="button" id="cmdShare" value="Share"
onclick="WSO2.MashupUtils.shareService(\'' +
- serviceName + '\', \'userpass\');"/></td></tr>';
+ serviceName + '\', \'userpass\',\'' + localUserName +
'\');"/></td></tr>';
if (InformationCard.AreCardsSupported()) {
strFrmService +=
'<tr><td height="25"><hr>If you have an associated InfoCard to login
to the destination server, use the option below</td><td><img
src="images/infocard_92x64.png" border="0"</td></tr>' +
'<tr><td height="25"><input type="button"
onclick="WSO2.MashupUtils.shareService(\'' +
- serviceName + '\', \'infocard\');" value="Share with
infocard"/></td></tr>';
+ serviceName + '\', \'infocard\',\'' + localUserName + '\');"
value="Share with infocard"/></td></tr>';
}
strFrmService += '</table>' +
@@ -187,7 +187,7 @@
};
-WSO2.MashupUtils.shareService = function (serviceName, mode) {
+WSO2.MashupUtils.shareService = function (serviceName, mode, localUserName) {
function submitServiceCallback() {
var response ;
@@ -255,7 +255,7 @@
var infoCardToken = InformationCard.GetToken();
wso2.mashup.services.shareServiceIC(serviceName, destAddress,
infoCardToken, overwriteExisting, migrateTags, submitServiceCallback,
labelElement, submitServiceError);
} else {
- wso2.mashup.services.shareService(serviceName, destAddress,
destUsername, destPassword, overwriteExisting, migrateTags,
submitServiceCallback, labelElement, submitServiceError);
+ wso2.mashup.services.shareService(serviceName, destAddress,
destUsername, destPassword, overwriteExisting, migrateTags, localUserName,
submitServiceCallback, labelElement, submitServiceError);
}
}
Modified: trunk/mashup/java/modules/www/js/services.js
==============================================================================
--- trunk/mashup/java/modules/www/js/services.js (original)
+++ trunk/mashup/java/modules/www/js/services.js Wed May 14 09:17:06 2008
@@ -288,7 +288,7 @@
* @param {callback} params Parameters to be set in the callback
*/
wso2.mashup.services.shareService =
-function (serviceName, destinationAddress, username, password,
overwriteExisting, migrateTags, callback, params,
+function (serviceName, destinationAddress, username, password,
overwriteExisting, migrateTags, localUserName, callback, params,
errorCallback) {
var callURL = serverURL + "/" + "ServiceSharingHelper" + "/" ;
@@ -303,6 +303,8 @@
'</req:overwriteExisting>\n' +
' <req:migrateTags>' + migrateTags +
'</req:migrateTags>\n' +
+ ' <req:localUser>' + localUserName +
+ '</req:localUser>\n' +
' </req:shareServiceRequest>\n';
new wso2.wsf.WSRequest(callURL, "shareService", body_xml, callback,
params, errorCallback);
Modified: trunk/mashup/java/modules/www/taskbar.jsp
==============================================================================
--- trunk/mashup/java/modules/www/taskbar.jsp (original)
+++ trunk/mashup/java/modules/www/taskbar.jsp Wed May 14 09:17:06 2008
@@ -34,7 +34,7 @@
UserRegistry userRegistry = RegistryUtils.getRegistry(request);
//Getting the currently logged in user
- String currentUser = RegistryUtils.getCurrentUser(userRegistry);
+ String currentUser = RegistryUtils.getCurrentUser(userRegistry).trim();
//Getting the mashup author
String author = null;
@@ -126,7 +126,7 @@
"Service started. [<a href='#'
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=paramMashupServiceName%>\",
false, handleServiceStartStopCallback)'>Stop</a>]";
//Enabling service sharing
document.getElementById("share-mashup").innerHTML =
- ' <a href="#"
onclick="WSO2.MashupUtils.showMashupSharingDialog(\'<%=paramMashupServiceName%>\');">Share
this mashup</a>';
+ ' <a href="#"
onclick="WSO2.MashupUtils.showMashupSharingDialog(\'<%=paramMashupServiceName%>\',
\'<%=currentUser%>\');">Share this mashup</a>';
} else {
document.getElementById("service-status").innerHTML =
@@ -156,7 +156,7 @@
"Service started. [<a href='#'
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=paramMashupServiceName%>\",
false, handleServiceStartStopCallback)'>Stop</a>]";
//Enabling service sharing
document.getElementById("share-mashup").innerHTML =
- ' <a href="#"
onclick="WSO2.MashupUtils.showMashupSharingDialog(\'<%=paramMashupServiceName%>\');">Share
this mashup</a>';
+ ' <a href="#"
onclick="WSO2.MashupUtils.showMashupSharingDialog(\'<%=paramMashupServiceName%>\',
\'<%=currentUser%>\');">Share this mashup</a>';
} else {
document.getElementById("service-status").innerHTML =
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev