1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18/** 19 * @author Aleksei Y. Semenov 20 */ 21 22package org.apache.harmony.security.tests.support; 23 24import java.io.IOException; 25import java.io.InputStream; 26import java.io.OutputStream; 27import java.security.Certificate; 28import java.security.KeyException; 29import java.security.Principal; 30import java.security.PublicKey; 31 32/** 33 * Stub for interface Certificate, necessary for testing 34 */ 35 36public class CertificateStub implements Certificate { 37 38 String format; 39 Principal guarantor; 40 Principal principal; 41 PublicKey key; 42 43 public CertificateStub(String format, Principal guarantor, Principal principal, PublicKey key) { 44 this.format = format; 45 this.guarantor = guarantor; 46 this.principal = principal; 47 this.key = key; 48 } 49 50 /** 51 * Stub - does nothing 52 * 53 * @see java.security.Certificate#decode(java.io.InputStream) 54 */ 55 public void decode(InputStream stream) throws KeyException, 56 IOException { 57 58 59 } 60 61 /** 62 * Stub - does nothing 63 * 64 * @see java.security.Certificate#encode(java.io.OutputStream) 65 */ 66 public void encode(OutputStream stream) throws KeyException, 67 IOException { 68 69 70 } 71 72 /** 73 * @see java.security.Certificate#getFormat() 74 */ 75 public String getFormat() { 76 77 return format; 78 } 79 80 /** 81 * @see java.security.Certificate#getGuarantor() 82 */ 83 public Principal getGuarantor() { 84 85 return guarantor; 86 } 87 88 /** 89 * @see java.security.Certificate#getPrincipal() 90 */ 91 public Principal getPrincipal() { 92 return principal; 93 } 94 95 /** 96 * @see java.security.Certificate#getPublicKey() 97 */ 98 public PublicKey getPublicKey() { 99 return key; 100 } 101 102 /** 103 * Stub - returns <code>null</code> 104 * 105 * @see java.security.Certificate#toString(boolean) 106 */ 107 public String toString(boolean detailed) { 108 return null; 109 } 110 111} 112