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.v2.tck;
16  
17  import java.rmi.RemoteException;
18  import javax.xml.ws.BindingProvider;
19  
20  import org.uddi.v2_service.DispositionReport;
21  import org.uddi.v2_service.Publish;
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   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
26   */
27  public class TckSecurity {
28  
29  	public static String getAuthToken(Publish securityService, String pubId, String cred) throws DispositionReport, RemoteException {
30  	
31                  if (!TckPublisher.isUDDIAuthMode())
32                          return null;
33  		org.uddi.api_v2.GetAuthToken ga = new org.uddi.api_v2.GetAuthToken();
34            ga.setGeneric("2.0");
35  		ga.setUserID(pubId);
36  		ga.setCred(cred);
37  
38  		org.uddi.api_v2.AuthToken token = securityService.getAuthToken(ga);
39  		
40  		return token.getAuthInfo();
41  	}
42  
43          /**
44           * used for non UDDI AuthToken authentication. I.e. HTTP NTLM, HTTP BASIC, HTTP DIGEST
45           * @param bindingProvider
46           * @param publisherId
47           * @param password 
48           */
49          public static void setCredentials(BindingProvider bindingProvider, String publisherId, String password) {
50                  bindingProvider.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, publisherId);
51                  bindingProvider.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
52          }
53  
54  }