001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.jbpm.handler;
022:
023: import com.liferay.client.portal.service.http.GroupServiceSoap;
024: import com.liferay.client.portal.service.http.GroupServiceSoapServiceLocator;
025: import com.liferay.client.portal.service.http.RoleServiceSoap;
026: import com.liferay.client.portal.service.http.RoleServiceSoapServiceLocator;
027: import com.liferay.client.portal.service.http.UserServiceSoap;
028: import com.liferay.client.portal.service.http.UserServiceSoapServiceLocator;
029: import com.liferay.jbpm.util.JbpmWebProps;
030: import com.liferay.util.Encryptor;
031:
032: import java.net.MalformedURLException;
033: import java.net.URL;
034:
035: /**
036: * <a href="DefaultHandler.java.html"><b><i>View Source</i></b></a>
037: *
038: * @author Charles May
039: *
040: */
041: public class DefaultHandler {
042:
043: protected URL getURL(String serviceName)
044: throws MalformedURLException {
045: return getURL(serviceName, true);
046: }
047:
048: protected URL getURL(String serviceName, boolean authenticated)
049: throws MalformedURLException {
050:
051: String url = JbpmWebProps.get("soap.url");
052:
053: if (authenticated) {
054: String userId = JbpmWebProps.get("soap.user.id");
055: String password = Encryptor.digest(JbpmWebProps
056: .get("soap.password"));
057:
058: int pos = url.indexOf("://");
059:
060: String protocol = url.substring(0, pos + 3);
061: String host = url.substring(pos + 3, url.length());
062:
063: url = protocol + userId + ":" + password + "@" + host
064: + "/tunnel-web/secure/axis/" + serviceName;
065: } else {
066: url += "/tunnel-web/axis/" + serviceName;
067: }
068:
069: return new URL(url);
070: }
071:
072: protected GroupServiceSoap getGroupService() throws Exception {
073: GroupServiceSoapServiceLocator locator = new GroupServiceSoapServiceLocator();
074:
075: GroupServiceSoap service = locator
076: .getPortal_GroupService(getURL("Portal_GroupService"));
077:
078: return service;
079: }
080:
081: protected RoleServiceSoap getRoleService() throws Exception {
082: RoleServiceSoapServiceLocator locator = new RoleServiceSoapServiceLocator();
083:
084: RoleServiceSoap service = locator
085: .getPortal_RoleService(getURL("Portal_RoleService"));
086:
087: return service;
088: }
089:
090: protected UserServiceSoap getUserService() throws Exception {
091: UserServiceSoapServiceLocator locator = new UserServiceSoapServiceLocator();
092:
093: UserServiceSoap service = locator
094: .getPortal_UserService(getURL("Portal_UserService"));
095:
096: return service;
097: }
098:
099: protected String swimlane;
100: protected String msg;
101:
102: }
|