1/*2 * Copyright 2013 The Apache Software Foundation.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package org.apache.juddi.v3.migration.tool;
1718import java.rmi.RemoteException;
19import java.util.logging.Level;
20import java.util.logging.Logger;
21import org.uddi.api_v3.GetAuthToken;
22import org.uddi.api_v3.GetOperationalInfo;
23import org.uddi.api_v3.OperationalInfos;
24import org.uddi.v3_service.DispositionReportFaultMessage;
25import org.uddi.v3_service.UDDIInquiryPortType;
26import org.uddi.v3_service.UDDISecurityPortType;
2728/**29 * Some common functions for the migration tool30 *31 * @author Alex O'Ree32 * @since 3.233 */34publicclassCommon {
3536publicstatic String GetOwner(String key, String token, UDDIInquiryPortType inquiry) {
37 GetOperationalInfo goi = new GetOperationalInfo();
38 goi.setAuthInfo(token);
39 goi.getEntityKey().add(key);
40 OperationalInfos operationalInfo = null;
41try {
42 operationalInfo = inquiry.getOperationalInfo(goi);
43if (operationalInfo != null && operationalInfo.getOperationalInfo() != null44 && !operationalInfo.getOperationalInfo().isEmpty()) {
45return operationalInfo.getOperationalInfo().get(0).getAuthorizedName();
46 }
47 } catch (Exception ex) {
48 ex.printStackTrace();
49 }
50returnnull;
51 }
5253publicstatic String GetAuthToken(String username, String password, UDDISecurityPortType sec) {
54try {
55 System.out.println(username + " logging in");
56 GetAuthToken getAuthTokenRoot = new GetAuthToken();
57 getAuthTokenRoot.setUserID(username);
58 getAuthTokenRoot.setCred(password);
59 String authInfo = sec.getAuthToken(getAuthTokenRoot).getAuthInfo();
60 System.out.println(username + " login success");
61return authInfo;
62 } catch (Exception ex) {
63 ex.printStackTrace();
64 }
65returnnull;
66 }
67 }