001/** 002 * Copyright 2021 Emmanuel Bourg 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package net.jsign.jca; 018 019import java.security.PrivateKey; 020import java.util.HashMap; 021import java.util.Map; 022 023/** 024 * Reference to a private key held by the signing service. 025 * 026 * @since 4.0 027 */ 028public class SigningServicePrivateKey implements PrivateKey { 029 030 /** The identifier of the key */ 031 private final String id; 032 033 /** The algorithm of the key (for example RSA or ECDSA) */ 034 private final String algorithm; 035 036 /** Extra properties of the key */ 037 private final Map<String, Object> properties = new HashMap<>(); 038 039 /** 040 * Creates a new reference to a privaye key. 041 * 042 * @param id The identifier of the key 043 * @param algorithm The algorithm of the key (RSA or ECDSA) 044 */ 045 public SigningServicePrivateKey(String id, String algorithm) { 046 this.id = id; 047 this.algorithm = algorithm; 048 } 049 050 public String getId() { 051 return id; 052 } 053 054 public Map<String, Object> getProperties() { 055 return properties; 056 } 057 058 @Override 059 public String getAlgorithm() { 060 return algorithm; 061 } 062 063 @Override 064 public String getFormat() { 065 throw new UnsupportedOperationException(); 066 } 067 068 @Override 069 public byte[] getEncoded() { 070 throw new UnsupportedOperationException(); 071 } 072}