Coverage Report - org.kuali.rice.ksb.security.AbstractDigitalSigner
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractDigitalSigner
0%
0/7
N/A
1
 
 1  
 /**
 2  
  * Copyright 2005-2011 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;
 17  
 
 18  
 import java.security.Signature;
 19  
 import java.security.cert.Certificate;
 20  
 
 21  
 import org.apache.commons.codec.binary.Base64;
 22  
 
 23  
 /**
 24  
  * An abstract implementation of a DigitalSigner which provides convienance utilities for storing a reference
 25  
  * to the Signature and also generating and encoding the actual digital signature.
 26  
  * 
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  
 public abstract class AbstractDigitalSigner implements DigitalSigner {
 30  
 
 31  
         private Signature signature;
 32  
         
 33  0
         public AbstractDigitalSigner(Signature signature) {
 34  0
                 this.signature = signature;
 35  0
         }
 36  
         
 37  
         public Signature getSignature() {
 38  0
                 return this.signature;
 39  
         }
 40  
         
 41  
         protected byte[] getSignatureBytes() throws Exception {
 42  0
                 return getSignature().sign();
 43  
         }
 44  
         
 45  
     protected String getEncodedSignature() throws Exception {
 46  0
         return new String(Base64.encodeBase64(getSignatureBytes()), "UTF-8");
 47  
     }
 48  
 
 49  
     protected String getEncodedCertificate(Certificate certificate) throws Exception {
 50  0
         return new String(Base64.encodeBase64(certificate.getEncoded()), "UTF-8");
 51  
     }
 52  
 
 53  
 }