Coverage Report - org.kuali.rice.ksb.config.wss4j.CryptoPasswordCallbackHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
CryptoPasswordCallbackHandler
0%
0/11
0%
0/6
6
 
 1  
 /*
 2  
  * Copyright 2006-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  
 
 17  
 package org.kuali.rice.ksb.config.wss4j;
 18  
 
 19  
 import java.io.IOException;
 20  
 
 21  
 import javax.security.auth.callback.Callback;
 22  
 import javax.security.auth.callback.CallbackHandler;
 23  
 import javax.security.auth.callback.UnsupportedCallbackException;
 24  
 
 25  
 import org.apache.ws.security.WSPasswordCallback;
 26  
 import org.kuali.rice.core.config.Config;
 27  
 import org.kuali.rice.core.config.ConfigContext;
 28  
 import org.kuali.rice.core.config.ConfigurationException;
 29  
 
 30  
 
 31  
 /**
 32  
  * Workflow CryptoPasswordCallbackHandler which retrieves the keystore password
 33  
  * from the workflow Config.
 34  
  * 
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  */
 37  0
 public class CryptoPasswordCallbackHandler implements CallbackHandler {
 38  
 
 39  
     /**
 40  
      * The actual CallBackHandler implementation.
 41  
      */
 42  
     public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
 43  0
         for (int i = 0; i < callbacks.length; i++) {
 44  0
             if (callbacks[i] instanceof WSPasswordCallback) {
 45  0
                 WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
 46  0
                 String password = ConfigContext.getCurrentContextConfig().getKeystorePassword();
 47  0
                 if (password == null) {
 48  0
                         throw new ConfigurationException("Could not locate the webservice password.  Should be configured as the '" + Config.KEYSTORE_PASSWORD + "' property.");
 49  
                 }
 50  0
                 pc.setPassword(password);
 51  0
             } else {
 52  0
                 throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
 53  
             }
 54  
         }
 55  0
     }
 56  
 }