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 * @version $Revision$ 21 */ 22 23 package org.apache.harmony.security.tests.support; 24 25 import java.security.Identity; 26 import java.security.IdentityScope; 27 import java.security.KeyManagementException; 28 import java.security.PublicKey; 29 import java.util.Enumeration; 30 31 /** 32 * This is stub implementation of IdentityScope for testing purposes 33 */ 34 @SuppressWarnings("deprecation") 35 public class IdentityScopeStub extends IdentityScope { 36 37 38 /** 39 * Stub constructor 40 */ 41 public IdentityScopeStub() { 42 super(); 43 } 44 45 /** 46 * Stub constructor 47 * @param name 48 */ 49 public IdentityScopeStub(String name) { 50 super(name); 51 } 52 53 /** 54 * Stub constructor 55 * @param name 56 * @param scope 57 * @throws KeyManagementException 58 */ 59 public IdentityScopeStub(String name, IdentityScope scope) 60 throws KeyManagementException { 61 super(name, scope); 62 } 63 64 /** 65 * Stub - returns 0 66 * @see java.security.IdentityScope#size() 67 */ 68 public int size() { 69 70 return 0; 71 } 72 73 /** 74 * Stub - returns <code>this</code> 75 * @see java.security.IdentityScope#getIdentity(java.lang.String) 76 */ 77 public Identity getIdentity(String name) { 78 79 return this; 80 } 81 82 /** 83 * Stub - returns <code>this</code> 84 * @see java.security.IdentityScope#getIdentity(java.security.PublicKey) 85 */ 86 public Identity getIdentity(PublicKey key) { 87 return this; 88 } 89 90 /** 91 * Stub - does nothing 92 * @see java.security.IdentityScope#addIdentity(java.security.Identity) 93 */ 94 public void addIdentity(Identity identity) throws KeyManagementException { 95 96 97 } 98 99 /** 100 * Stub - does nothing 101 * @see java.security.IdentityScope#removeIdentity(java.security.Identity) 102 */ 103 public void removeIdentity(Identity identity) throws KeyManagementException { 104 105 106 } 107 108 /** 109 * Stub - returns <code>null</code> 110 * @see java.security.IdentityScope#identities() 111 */ 112 public Enumeration identities() { 113 return null; 114 } 115 116 /** 117 * Sets the system's identity scope 118 * @param scope 119 */ 120 public static void mySetSystemScope(IdentityScope scope) { 121 122 IdentityScope.setSystemScope(scope); 123 } 124 125 } 126