This project has retired. For details please refer to its Attic page.
TckSecurity xref
View Javadoc
1   /*
2    * Copyright 2001-2009 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 at
7    *      http://www.apache.org/licenses/LICENSE-2.0
8    * 
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.apache.juddi.v3.tck;
16  
17  import java.rmi.RemoteException;
18  import javax.xml.ws.BindingProvider;
19  
20  import org.uddi.v3_service.DispositionReportFaultMessage;
21  import org.uddi.v3_service.UDDISecurityPortType;
22  /**
23   * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
24   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
25   */
26  public class TckSecurity {
27  
28  	public static String getAuthToken(UDDISecurityPortType securityService, String pubId, String cred) throws DispositionReportFaultMessage, RemoteException {
29  	
30                  if (!TckPublisher.isUDDIAuthMode())
31                          return null;
32  		org.uddi.api_v3.GetAuthToken ga = new org.uddi.api_v3.GetAuthToken();
33  		ga.setUserID(pubId);
34  		ga.setCred(cred);
35  
36  		org.uddi.api_v3.AuthToken token = securityService.getAuthToken(ga);
37  		
38  		return token.getAuthInfo();
39  	}
40  
41          /**
42           * used for non UDDI AuthToken authentication. I.e. HTTP NTLM, HTTP BASIC, HTTP DIGEST
43           * @param bindingProvider
44           * @param publisherId
45           * @param password 
46           */
47          public static void setCredentials(BindingProvider bindingProvider, String publisherId, String password) {
48                  bindingProvider.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, publisherId);
49                  bindingProvider.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
50          }
51  
52  }