Author: tyrell
Date: Fri Mar 7 19:47:00 2008
New Revision: 14592
Log:
Adding InfoCard support for sharing.
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
trunk/mashup/java/modules/coreservices/servicesharinghelper/src/org/wso2/mashup/coreservices/servicesharinghelper/ServiceSharingHelper.java
trunk/mashup/java/modules/coreservices/sharingservice/src/org/wso2/mashup/share/service/MashupSharingService.java
trunk/mashup/java/modules/www/css/styles.css
trunk/mashup/java/modules/www/js/mashup-utils.js
trunk/mashup/java/modules/www/js/services.js
trunk/mashup/java/modules/www/mashup.jsp
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
Fri Mar 7 19:47:00 2008
@@ -45,13 +45,21 @@
public static String SESSION_MANAGEMENT = "SessionManagement";
public static String REMEMBER_ME_PERIOD = "RememberMePeriod";
-
+
public static String CAPTCHA_CONFIG = "Captcha";
public static String CAPTCHA_CONFIG_STATUS = "EnableCaptcha";
public static String QUARTZ_FUNCTION_SCHEDULER = "FunctionScheduler";
public static String QUARTZ_FUNCTION_SCHEDULER_JOB_IDS =
"FunctionSchedulerJobIds";
+ public static String SECURITY_CONFIG = "Security";
+ public static String SECURITY_CONFIG_KEYSTORE = "KeyStore";
+ public static String SECURITY_CONFIG_KEYSTORE_LOCATION = "Location";
+ public static String SECURITY_CONFIG_KEYSTORE_TYPE = "Type";
+ public static String SECURITY_CONFIG_KEYSTORE_PASSWORD = "Password";
+ public static String SECURITY_CONFIG_KEYSTORE_KEYALIAS = "KeyAlias";
+ public static String SECURITY_CONFIG_KEYSTORE_KEYPASSWORD = "KeyPassword";
+
public static final String EMAIL_RELAY_HOST = "email_relay_host";
public static final String REG_VALIDATION_URL =
"registration_validation_url";
public static final String EMAIL_FROM_ADDRESS = "email_from_address";
@@ -126,5 +134,5 @@
public static final int MIN_PASSWORD_LENGTH = 5;
- public static String MASHUP_PRIVATE_FOLDER_NAME = "_private";
+ public static String MASHUP_PRIVATE_FOLDER_NAME = "_private";
}
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
Fri Mar 7 19:47:00 2008
@@ -74,27 +74,27 @@
if (workDirObject != null) {
DataSource dataSource;
String workDir = (String) workDirObject;
- // Directory to store the temp archive
- File tempDir = new File(workDir);
- tempDir.mkdirs();
- try {
- // Creating a FileDataSource
- dataSource =
- new FileDataSource(File.createTempFile("mashup",
"upload", tempDir));
- // write the service js file & the contents of the
- // service.resources folder to the outstream of the data
source
-
- createMashupArchive(mashupService, configCtx,
dataSource.getOutputStream());
- } catch (IOException e) {
- throw new MashupFault(e);
- }
- return new DataHandler(dataSource);
+ // Directory to store the temp archive
+ File tempDir = new File(workDir);
+ tempDir.mkdirs();
+ try {
+ // Creating a FileDataSource
+ dataSource =
+ new FileDataSource(File.createTempFile("mashup",
"upload", tempDir));
+ // write the service js file & the contents of the
+ // service.resources folder to the outstream of the data source
+
+ createMashupArchive(mashupService, configCtx,
dataSource.getOutputStream());
+ } catch (IOException e) {
+ throw new MashupFault(e);
+ }
+ return new DataHandler(dataSource);
}
throw new MashupFault("Server work directory cannot be found.");
}
public void createMashupArchive(AxisService mashupService,
ConfigurationContext configCtx,
- OutputStream outputStream)
throws MashupFault {
+ OutputStream outputStream) throws
MashupFault {
File serviceJS;
File serviceResourceFolder = null;
// Get the service js file for the given service
@@ -143,7 +143,8 @@
*/
public void uploadMashupService(String destinationServerAddress,
DataHandler dataHandler,
ConfigurationContext configCtx, String
serviceJsFileName,
- String mashupServiceName, String username,
String password, String overwriteExisting)
+ String mashupServiceName, String username,
String password,
+ String overwriteExisting)
throws AxisFault {
if (destinationServerAddress.startsWith("http://")) {
@@ -174,7 +175,64 @@
// parameters to the service ServiceName string, service file name,
// dataHandler of the bundled archive
Object[] opAddEntryArgs =
- new Object[] {mashupServiceName, username,
password,serviceJsFileName, dataHandler, overwriteExisting};
+ new Object[] { mashupServiceName, username, password,
serviceJsFileName,
+ dataHandler, overwriteExisting };
+ try {
+ serviceClient.invokeRobust(opAddEntry, opAddEntryArgs);
+ } catch (AxisFault axisFault) {
+ OperationContext operationContext =
serviceClient.getLastOperationContext();
+ if (operationContext != null) {
+ MessageContext messageContext =
+
operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
+ if (messageContext != null) {
+ SOAPEnvelope envelope = messageContext.getEnvelope();
+ if (envelope != null) {
+ if (envelope.getBody().hasFault()) {
+ throw new AxisFault(envelope.getBody().getFault());
+ }
+ }
+ }
+ }
+ throw AxisFault.makeFault(axisFault);
+ }
+ }
+
+ public void uploadMashupService(String destinationServerAddress,
DataHandler dataHandler,
+ ConfigurationContext configCtx, String
serviceJsFileName,
+ String mashupServiceName, String
infoCardToken,
+ String overwriteExisting)
+ throws AxisFault {
+
+ if (destinationServerAddress.startsWith("http://")) {
+ // We should call this service in https mode as we are sending the
users username
+ // and password as plain text.
+ throw new MashupFault("Cannot share via http please use Https.");
+ }
+ // We use the RPCClient to call the sharing service
+ RPCServiceClient serviceClient = new RPCServiceClient(configCtx, null);
+ Options options = serviceClient.getOptions();
+ EndpointReference sharingServiceEPR;
+ // Check whether used has given the HostAdress with or without the
+ // trailing '/'
+ if (destinationServerAddress.endsWith("/")) {
+ sharingServiceEPR = new EndpointReference(destinationServerAddress
+ + "services/MashupSharingService/shareMashupIC");
+ } else {
+ sharingServiceEPR = new EndpointReference(destinationServerAddress
+ + "/services/MashupSharingService/shareMashupIC");
+ }
+
+ options.setTo(sharingServiceEPR);
+ options.setAction("urn:shareMashupIC");
+ options.setProperty(HTTPConstants.CHUNKED, "false");
+ options.setProperty(Constants.Configuration.ENABLE_MTOM,
Constants.VALUE_TRUE);
+ QName opAddEntry = new
QName("http://service.share.mashup.wso2.org/xsd", "shareMashupIC");
+
+ // parameters to the service ServiceName string, service file name,
+ // dataHandler of the bundled archive
+ Object[] opAddEntryArgs =
+ new Object[] { mashupServiceName, infoCardToken,
serviceJsFileName, dataHandler,
+ overwriteExisting };
try {
serviceClient.invokeRobust(opAddEntry, opAddEntryArgs);
} catch (AxisFault axisFault) {
@@ -242,7 +300,7 @@
* @throws AxisFault - Thrown in case an exception occurs
*/
public void downloadMashupService(String remoteServer, String serviceName,
String username,
- String password, MessageContext
messageContext,
+ String password, MessageContext
messageContext,
AxisConfiguration axisConfiguration)
throws AxisFault {
// We use the RPCClient to call the download service
RPCServiceClient serviceClient = new RPCServiceClient(messageContext
@@ -285,8 +343,20 @@
String fileName = fileNameElement.getText();
System.out.println(fileName + dataHandler);
try {
- deploySharedService(fileName, username, password,
- dataHandler,
axisConfiguration);
+
+ //Authenticating the user
+ boolean authenticated = false;
+ try {
+ authenticated =
MashupUtils.authenticateUser(username, password);
+ } catch (AuthenticatorException e) {
+ throw new MashupFault(e);
+ }
+ if (!authenticated) {
+ throw new MashupFault(
+ "Cannot authenticate user. Username or
password is incorrect");
+ }
+
+ deploySharedService(fileName, username,
dataHandler, axisConfiguration);
} catch (IOException e) {
throw new MashupFault(e);
}
@@ -310,19 +380,10 @@
* @param axisConfiguration - Axis Configuration
* @throws AxisFault - Thrown in case an exception occurs
*/
- public void deploySharedService(String fileName, String username, String
password,
- DataHandler dataHandler, AxisConfiguration
axisConfiguration)
+ public void deploySharedService(String fileName, String username,
DataHandler dataHandler,
+ AxisConfiguration axisConfiguration)
throws AxisFault {
- boolean authenticated = false;
- try {
- authenticated = MashupUtils.authenticateUser(username, password);
- } catch (AuthenticatorException e) {
- throw new MashupFault(e);
- }
- if (!authenticated) {
- throw new MashupFault("Cannot authenticate user. Username or
password is incorrect");
- }
URL repository = axisConfiguration.getRepository();
if (repository != null) {
// Access the scripts deployment folder
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
Fri Mar 7 19:47:00 2008
@@ -90,4 +90,54 @@
success = true;
return Boolean.valueOf(success);
}
+
+ public Boolean shareService(String serviceName, String infoCardToken,
+ String destinationServerAddress, String
overwriteExisting)
+ throws IOException {
+ boolean success;
+
+ //Adding this to maintain backward compatibility with older versions
of the Mashup Server
+ String overWrite = "false";
+ if(overwriteExisting != null){
+ overWrite = overwriteExisting;
+ }
+
+ MessageContext currentMessageContext =
MessageContext.getCurrentMessageContext();
+ AxisConfiguration configuration =
currentMessageContext.getAxisService()
+ .getAxisConfiguration();
+ ConfigurationContext configContext =
currentMessageContext.getConfigurationContext();
+
+ // for logging purposes
+ String remoteIP = (String)
currentMessageContext.getProperty(MessageContext.REMOTE_ADDR);
+ SimpleDateFormat date = new SimpleDateFormat("'['yyyy-MM-dd
HH:mm:ss,SSSS']'");
+ Date currentTime = Calendar.getInstance().getTime();
+
+ AxisService axisService = configuration.getService(serviceName);
+ if (axisService == null) {
+ throw new MashupFault(
+ "Requested Mashup service cannot be found in the remote
Mashup server.");
+ }
+ MashupArchiveManupulator masshupArchiveManupulator = new
MashupArchiveManupulator();
+ DataHandler dataHandler =
masshupArchiveManupulator.createMashupArchiveDataHandler(
+ axisService, configContext);
+
+ Parameter serviceJSParameter = axisService
+ .getParameter(JavaScriptEngineConstants.SERVICE_JS);
+ // We do not need to check for Null or whether this is a file as we
+ // have already checked it inside the createMashupArchiveDataHandler
+ // method.
+ File serviceJS = (File) serviceJSParameter.getValue();
+
+ String shortServiceName =
+
serviceName.substring(serviceName.indexOf(MashupConstants.SEPARATOR_CHAR) + 1);
+
masshupArchiveManupulator.uploadMashupService(destinationServerAddress,
dataHandler,
+ configContext,
serviceJS.getName(),
+ shortServiceName,
infoCardToken, overWrite);
+ log
+ .info("Shared Service \'" + serviceName + "' to the
destination server"
+ + destinationServerAddress + " at " +
date.format(currentTime) + "from "
+ + remoteIP);
+ success = true;
+ return Boolean.valueOf(success);
+ }
}
Modified:
trunk/mashup/java/modules/coreservices/sharingservice/src/org/wso2/mashup/share/service/MashupSharingService.java
==============================================================================
---
trunk/mashup/java/modules/coreservices/sharingservice/src/org/wso2/mashup/share/service/MashupSharingService.java
(original)
+++
trunk/mashup/java/modules/coreservices/sharingservice/src/org/wso2/mashup/share/service/MashupSharingService.java
Fri Mar 7 19:47:00 2008
@@ -16,20 +16,34 @@
package org.wso2.mashup.share.service;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
import org.apache.axis2.engine.AxisConfiguration;
-import org.wso2.javascript.rhino.JavaScriptEngineConstants;
+import org.w3c.dom.Element;
+import org.wso2.authenticator.AuthenticatorException;
import org.wso2.mashup.MashupConstants;
import org.wso2.mashup.MashupFault;
-import org.wso2.mashup.utils.DownloadServiceResponse;
import org.wso2.mashup.utils.MashupArchiveManupulator;
+import org.wso2.mashup.utils.MashupUtils;
+import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.users.UserRealm;
+import org.wso2.registry.users.UserStoreException;
+import org.wso2.registry.users.UserStoreReader;
+import org.wso2.solutions.identity.IdentityConstants;
+import org.wso2.solutions.identity.relyingparty.RelyingPartyException;
+import org.wso2.solutions.identity.relyingparty.TokenVerifier;
+import org.wso2.utils.ServerConfiguration;
import javax.activation.DataHandler;
-import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.util.Iterator;
+import java.util.Map;
/**
* This service facilitates the sharing of Mashup services deplyoed in this
server with other Mashup servers.
@@ -56,17 +70,158 @@
public void shareMashup(String serviceName, String username, String
password, String fileName,
DataHandler dataHandler, String overwriteExisting)
throws IOException {
+
+ //Authenticating the user
+ boolean authenticated = false;
+
+ try {
+ authenticated = MashupUtils.authenticateUser(username, password);
+ } catch (AuthenticatorException e) {
+ throw new MashupFault(e);
+ }
+ if (!authenticated) {
+ throw new MashupFault("Cannot authenticate user. Username or
password is incorrect");
+ }
+
if (dataHandler == null) {
throw new MashupFault("Cannot read the uploaded Mashup Service.");
}
MessageContext messageContext =
MessageContext.getCurrentMessageContext();
AxisConfiguration axisConfiguration =
messageContext.getConfigurationContext()
.getAxisConfiguration();
- if ((axisConfiguration.getService(username +
MashupConstants.SEPARATOR_CHAR + serviceName) != null) &&
(!overwriteExisting.equals("true"))) {
+ if ((axisConfiguration
+ .getService(username + MashupConstants.SEPARATOR_CHAR +
serviceName) != null) &&
+ (!overwriteExisting.equals("true"))) {
+ throw new AxisFault(
+ "A Service with a same name already exists in the remote
Mashup Server.");
+ }
+ MashupArchiveManupulator archiveManupulator = new
MashupArchiveManupulator();
+ archiveManupulator
+ .deploySharedService(fileName, username, dataHandler,
axisConfiguration);
+ }
+
+ public void shareMashupIC(String serviceName, String infoCardToken, String
fileName,
+ DataHandler dataHandler, String overwriteExisting)
+ throws IOException {
+
+ String username = null;
+
+ if (dataHandler == null) {
+ throw new MashupFault("Cannot read the uploaded Mashup Service.");
+ }
+
+ //Decrypting the infocard token and doing the authentication for user
+ ServerConfiguration serverConfig = ServerConfiguration.getInstance();
+
+ String keyStore =
serverConfig.getFirstProperty(MashupConstants.SECURITY_CONFIG + "." +
+ MashupConstants.SECURITY_CONFIG_KEYSTORE + MashupConstants
+ .SECURITY_CONFIG_KEYSTORE_LOCATION);
+ String keyStorePass =
serverConfig.getFirstProperty(MashupConstants.SECURITY_CONFIG + "." +
+ MashupConstants.SECURITY_CONFIG_KEYSTORE + MashupConstants
+ .SECURITY_CONFIG_KEYSTORE_PASSWORD);
+ String keyAlias =
serverConfig.getFirstProperty(MashupConstants.SECURITY_CONFIG + "." +
+ MashupConstants.SECURITY_CONFIG_KEYSTORE + MashupConstants
+ .SECURITY_CONFIG_KEYSTORE_KEYALIAS);
+ String keyPass =
serverConfig.getFirstProperty(MashupConstants.SECURITY_CONFIG + "." +
+ MashupConstants.SECURITY_CONFIG_KEYSTORE + MashupConstants
+ .SECURITY_CONFIG_KEYSTORE_KEYPASSWORD);
+
+ try {
+ //Loading the private key from file
+ FileInputStream is = new FileInputStream(keyStore);
+ KeyStore ks = KeyStore.getInstance("JKS");
+ ks.load(is, keyStorePass.toCharArray());
+ PrivateKey privateKey = (PrivateKey) ks.getKey(keyAlias, keyPass
+ .toCharArray());
+
+ //Decrypting the InfoCard token
+ TokenVerifier verifier = new TokenVerifier();
+ Element decryptedToken = verifier.decryptToken(infoCardToken,
privateKey);
+
+ if (verifier.verifyDecryptedToken(decryptedToken)) {
+ //Getting the user PPID from the token
+ String userPPID = null;
+ Iterator propertyEntry =
verifier.getAttributeTable().entrySet()
+ .iterator();
+ while (propertyEntry.hasNext()) {
+ Map.Entry entry = (Map.Entry) propertyEntry.next();
+ if ((entry.getKey()).equals(IdentityConstants.CLAIM_PPID))
{
+ userPPID = (String) entry.getValue();
+ break;
+ }
+ }
+
+ if (userPPID != null) {
+ //Getting the username using the PPID
+ MessageContext msgCtx =
MessageContext.getCurrentMessageContext();
+ AxisConfiguration configuration =
+
msgCtx.getConfigurationContext().getAxisConfiguration();
+
+ UserRealm realm = (UserRealm) configuration
+
.getParameterValue(RegistryConstants.REGISTRY_REALM);
+ try {
+ UserStoreReader storeReader =
realm.getUserStoreReader();
+
+ // Null for key gets all users with the PPID - there
can be only one.
+ String[] userNames =
+
storeReader.getUserNamesWithPropertyValue(null, userPPID);
+
+ // If a name is returned, instantiate a secure
registry for user.
+ if (userNames.length == 1) {
+ username = userNames[0];
+ }
+ } catch (UserStoreException e) {
+ throw new MashupFault("Exception while processing ppid
: " + userPPID, e);
+ }
+
+ if (username == null) {
+ throw new MashupFault(
+ "A user can not be found matching the
information contained in this InfoCard.");
+ }
+
+ //Now that we have verified this is a valid user, trying
to deploy the mashup in this server
+ if ((configuration
+ .getService(username +
MashupConstants.SEPARATOR_CHAR + serviceName) !=
+ null) &&
+ (!overwriteExisting.equals("true"))) {
+ throw new AxisFault(
+ "A Service with a same name already exists in
the remote Mashup Server.");
+ }
+
+ MashupArchiveManupulator archiveManupulator = new
MashupArchiveManupulator();
+ archiveManupulator
+ .deploySharedService(fileName, username,
dataHandler,
+ configuration);
+
+ } else {
+ throw new MashupFault("Failed to read PPID from the
InfoCard token.");
+ }
+ }
+
+ } catch (KeyStoreException e) {
+ throw new MashupFault(e);
+ } catch (NoSuchAlgorithmException e) {
+ throw new MashupFault(e);
+ } catch (CertificateException e) {
+ throw new MashupFault(e);
+ } catch (UnrecoverableKeyException e) {
+ throw new MashupFault(e);
+ } catch (RelyingPartyException e) {
+ throw new MashupFault(e);
+ }
+
+
+ MessageContext messageContext =
MessageContext.getCurrentMessageContext();
+ AxisConfiguration axisConfiguration =
messageContext.getConfigurationContext()
+ .getAxisConfiguration();
+ if ((axisConfiguration
+ .getService(username + MashupConstants.SEPARATOR_CHAR +
serviceName) != null) &&
+ (!overwriteExisting.equals("true"))) {
throw new AxisFault(
"A Service with a same name already exists in the remote
Mashup Server.");
}
MashupArchiveManupulator archiveManupulator = new
MashupArchiveManupulator();
- archiveManupulator.deploySharedService(fileName, username, password,
dataHandler, axisConfiguration);
- }
+ archiveManupulator
+ .deploySharedService(fileName, username, dataHandler,
axisConfiguration);
+ }
}
Modified: trunk/mashup/java/modules/www/css/styles.css
==============================================================================
--- trunk/mashup/java/modules/www/css/styles.css (original)
+++ trunk/mashup/java/modules/www/css/styles.css Fri Mar 7 19:47:00 2008
@@ -716,3 +716,32 @@
background: url( ../images/bt.gif ) no-repeat bottom
}
+/* styles for Information Card support. */
+ .InformationCardsSupported {
+ display:none;
+ }
+ .InformationCardsNotSupported {
+ display:none;
+ }
+
+ button.ic, button#icSignIn, button#icSignUp, button#icProtectAccount,
button#icRecoverAccount, button#icConfirmation {
+ width:180px;
+ height:50px;
+ padding: 0px;
+ cursor:default;
+ }
+
+ img.ic {
+ float:left;
+ margin: 3px 0px 0px 3px;
+ }
+ div.ic {
+ margin:7px 0px 7px 0px;
+ float:right;
+ }
+
+ div.icContainer {
+ width:200px;
+ text-align:center;
+ }
+/* END styles for Information Card support. */
\ No newline at end of file
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 Fri Mar 7 19:47:00 2008
@@ -161,13 +161,22 @@
//Creating the content div
var strFrmService = '<table align="center" border="0">' +
'<tr><td nowrap height="25"><b>Destination Server
Address: </b></td><td><input name="txtDestAddress" type="text"
id="txtDestAddress" value="https://mooshup.com" size="50"/></td></tr>' +
+ '<tr><td nowrap height="25"><b>Overwrite if the
service already exists? </b></td><td><input name="chkOverwrite" type="checkbox"
id="chkOverwrite"/></td></tr>' +
+ '<tr><td height="25"><hr>Please enter your login
information for the destination server</td></tr>' +
'<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 nowrap height="25"><b>Overwrite if the
service already exists? </b></td><td><input name="chkOverwrite" type="checkbox"
id="chkOverwrite"/></td></tr>' +
- '<tr><td nowrap height="30" valign="bottom"><input
type="button" id="cmdShare" value="Share"
onclick="WSO2.MashupUtils.shareService(\'' +
- serviceName + '\');"/></td></tr>' +
- '</table>' +
- '<label id="lblStatus" style="width: auto;"></label>';
+ '<tr><td></td><td nowrap height="30"
valign="bottom"><input type="button" id="cmdShare" value="Share"
onclick="WSO2.MashupUtils.shareService(\'' +
+ serviceName + '\', \'userpass\');"/></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>';
+ }
+
+ strFrmService += '</table>' +
+ '<label id="lblStatus" style="width: auto;"></label>';
YAHOO.util.Event.onContentReady('doc3', function() {
// Instantiate the Dialog
@@ -177,7 +186,7 @@
};
-WSO2.MashupUtils.shareService = function (serviceName) {
+WSO2.MashupUtils.shareService = function (serviceName, mode) {
function submitServiceCallback() {
var response ;
@@ -236,7 +245,14 @@
if (WSO2.MashupUtils.isUrl(destAddress)) {
labelElement.innerHTML = "Contacting backend services. Please wait...";
- wso2.mashup.services.shareService(serviceName, destAddress,
destUsername, destPassword, overwriteExisting, submitServiceCallback,
labelElement, submitServiceError);
+
+ if (mode == "infocard") {
+ var infoCardToken = InformationCard.GetToken();
+ wso2.mashup.services.shareServiceIC(serviceName, destAddress,
infoCardToken, overwriteExisting, submitServiceCallback, labelElement,
submitServiceError);
+ } else {
+ wso2.mashup.services.shareService(serviceName, destAddress,
destUsername, destPassword, overwriteExisting, submitServiceCallback,
labelElement, submitServiceError);
+
+ }
}
else {
labelElement.innerHTML = "Please enter a valid server address here
...";
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 Fri Mar 7 19:47:00 2008
@@ -165,15 +165,17 @@
var params = new Array(serviceName, serviceStatus);
if (serviceStatus) {
- body_xml = '<req:startServiceRequest
xmlns:req="http://service.admin.mashup.wso2.org/xsd">\n' +
- ' <req:serviceName>' + serviceName + '</req:serviceName>\n'
+
- ' </req:startServiceRequest>\n';
+ body_xml =
+ '<req:startServiceRequest
xmlns:req="http://service.admin.mashup.wso2.org/xsd">\n' +
+ ' <req:serviceName>' + serviceName + '</req:serviceName>\n' +
+ ' </req:startServiceRequest>\n';
soapAction = "startService";
}
if (!serviceStatus) {
- body_xml = '<req:stopServiceRequest
xmlns:req="http://service.admin.mashup.wso2.org/xsd">\n' +
- ' <req:serviceName>' + serviceName + '</req:serviceName>\n'
+
- ' </req:stopServiceRequest>\n';
+ body_xml =
+ '<req:stopServiceRequest
xmlns:req="http://service.admin.mashup.wso2.org/xsd">\n' +
+ ' <req:serviceName>' + serviceName + '</req:serviceName>\n' +
+ ' </req:stopServiceRequest>\n';
soapAction = "stopService";
}
@@ -286,7 +288,8 @@
* @param {callback} params Parameters to be set in the callback
*/
wso2.mashup.services.shareService =
-function (serviceName, destinationAddress, username, password,
overwriteExisting, callback, params, errorCallback) {
+function (serviceName, destinationAddress, username, password,
overwriteExisting, callback, params,
+ errorCallback) {
var callURL = serverURL + "/" + "ServiceSharingHelper" + "/" ;
@@ -303,6 +306,34 @@
new wso2.wsf.WSRequest(callURL, "shareService", body_xml, callback,
params, errorCallback);
};
+/**
+ * @description Method used to share a selected service with another server
using InfoCard authentication
+ * @method shareService
+ * @public
+ * @static
+ * @param {String} serviceName Name of the service to retrieve
operations
+ * @param {String} destinationAddress Address of the destination server
+ * @param {callback} callBack User-defined callback function or object
+ * @param {callback} params Parameters to be set in the callback
+ */
+wso2.mashup.services.shareServiceIC =
+function (serviceName, destinationAddress, infocardtoken, overwriteExisting,
callback, params,
+ errorCallback) {
+
+ var callURL = serverURL + "/" + "ServiceSharingHelper" + "/" ;
+
+ var body_xml = '<req:shareServiceICRequest
xmlns:req="http://servicesharinghelper.coreservices.mashup.wso2.org/xsd">\n' +
+ ' <req:serviceName>' + serviceName + '</req:serviceName>\n'
+
+ ' <req:infoCardToken>' + infocardtoken +
'</req:infoCardToken>\n' +
+ ' <req:destinationServerAddress>' + destinationAddress +
+ '</req:destinationServerAddress>\n' +
+ ' <req:overwriteExisting>' + overwriteExisting +
+ '</req:overwriteExisting>\n' +
+ ' </req:shareServiceICRequest>\n';
+
+ new wso2.wsf.WSRequest(callURL, "shareServiceIC", body_xml, callback,
params, errorCallback);
+};
+
/**
* @description Method used to get a list of faulty service archives
@@ -485,7 +516,8 @@
wso2.wsf.Util.alertMessage("Your session has expired.");
//Envoking force logout
wso2.mashup.handleLogout();
- } else if (typeof (error.detail.indexOf) != "undefined" &&
error.detail.indexOf("NS_ERROR_NOT_AVAILABLE") > -1) {
+ } else if (typeof (error.detail.indexOf) != "undefined" &&
+ error.detail.indexOf("NS_ERROR_NOT_AVAILABLE") > -1) {
wso2.wsf.Util.alertMessage("Your session has expired.");
//Envoking force logout
wso2.mashup.handleLogout();
Modified: trunk/mashup/java/modules/www/mashup.jsp
==============================================================================
--- trunk/mashup/java/modules/www/mashup.jsp (original)
+++ trunk/mashup/java/modules/www/mashup.jsp Fri Mar 7 19:47:00 2008
@@ -111,6 +111,7 @@
<script type="text/javascript" src="js/services.js"></script>
<script type="text/javascript" src="js/mashup.js"></script>
<script type="text/javascript" src="js/mashup-utils.js"></script>
+<script type="text/javascript" src="js/InformationCards.js"></script>
<script language="javascript" type="text/javascript">
userLoggedOn = <%=RegistryUtils.isLoggedIn(registry) %>;
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev