Coverage Report - org.kuali.rice.ksb.security.soap.CredentialsOutHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
CredentialsOutHandler
0%
0/12
N/A
1
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community 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  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * 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 and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.ksb.security.soap;
 17  
 
 18  
 import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
 19  
 import org.apache.ws.security.WSPasswordCallback;
 20  
 import org.apache.ws.security.WSSecurityException;
 21  
 import org.apache.ws.security.handler.RequestData;
 22  
 import org.apache.ws.security.handler.WSHandlerConstants;
 23  
 import org.kuali.rice.core.api.security.credentials.Credentials;
 24  
 import org.kuali.rice.core.api.security.credentials.CredentialsSource;
 25  
 import org.kuali.rice.ksb.api.bus.ServiceConfiguration;
 26  
 import org.kuali.rice.ksb.security.credentials.UsernamePasswordCredentials;
 27  
 import org.springframework.util.Assert;
 28  
 
 29  
 
 30  
 /**
 31  
  * 
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  * @since 0.9
 34  
  * 
 35  
  */
 36  
 public class CredentialsOutHandler extends WSS4JOutInterceptor {
 37  
 
 38  
         private final CredentialsSource credentialsSource;
 39  
 
 40  
         private final ServiceConfiguration serviceConfiguration;
 41  
 
 42  
         public CredentialsOutHandler(final CredentialsSource credentialsSource,
 43  0
                         final ServiceConfiguration serviceConfiguration) {
 44  0
                 Assert.notNull(credentialsSource, "credentialsSource cannot be null.");
 45  0
                 Assert.notNull(serviceConfiguration, "serviceConfiguration cannot be null.");
 46  0
                 this.credentialsSource = credentialsSource;
 47  0
                 this.serviceConfiguration = serviceConfiguration;
 48  
 
 49  0
                 final Credentials credentials = this.credentialsSource
 50  
                                 .getCredentials(this.serviceConfiguration.getEndpointUrl().toString());
 51  
 
 52  0
                 Assert.isTrue(credentials instanceof UsernamePasswordCredentials,
 53  
                                 "Credentials must be of type usernamepassword.");
 54  
 
 55  0
                 final UsernamePasswordCredentials c = (UsernamePasswordCredentials) credentials;
 56  0
                 setProperty(WSHandlerConstants.USER, c.getUsername());
 57  0
         }
 58  
 
 59  
         public WSPasswordCallback getPassword(final String username,
 60  
                         final int doAction, final String clsProp, final String refProp,
 61  
                         final RequestData reqData) throws WSSecurityException {
 62  0
                 final UsernamePasswordCredentials c = (UsernamePasswordCredentials) this.credentialsSource
 63  
                                 .getCredentials(this.serviceConfiguration.getEndpointUrl().toString());
 64  
 
 65  0
                 return new WSPasswordCallback(c.getUsername(), c.getPassword(), null,
 66  
                                 WSPasswordCallback.USERNAME_TOKEN);
 67  
         }
 68  
 }
 69