All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jpos.security.SecurePrivateKey Maven / Gradle / Ivy

Go to download

jPOS is an ISO-8583 based financial transaction library/framework that can be customized and extended in order to implement financial interchanges.

There is a newer version: 2.1.9
Show newest version
/*
 * jPOS Project [http://jpos.org]
 * Copyright (C) 2000-2021 jPOS Software SRL
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see .
 */

package org.jpos.security;

import java.io.PrintStream;
import java.io.Serializable;
import org.jpos.iso.ISOUtil;
import org.jpos.util.Logger;

/**
 * The {@code SecurePrivateKey} class wraps any private key, which is protected
 * by the security module with variant methods.
 * 

* The wrapped private key should be in the secure proprietary format of * the security module. *

The {@code keyType} indicates type of private key (currently only RSA * keys are supported - others may be in future) * * @author Robert Demski */ public class SecurePrivateKey extends SecureVariantKey implements Serializable{ private static final long serialVersionUID = -9145281998779008306L; /** * Constructs an {@code SecurePrivateKey}. * * @param keyType eg. {@link SMAdapter#TYPE_RSA_PK} or {@link SMAdapter#TYPE_RSA_SK} * @param keyBytes private key in the secure proprietary format of the security module. */ public SecurePrivateKey(String keyType, byte[] keyBytes) { setKeyType(keyType); setKeyBytes(keyBytes); } @Override public void setVariant(byte variant) {} @Override public byte getVariant() { throw new UnsupportedOperationException("Operation getVariant() not" + " allowed for " + SecurePrivateKey.class.getName()); } @Override public void setScheme(KeyScheme scheme) {} @Override public KeyScheme getScheme() { throw new UnsupportedOperationException("Operation getScheme() not" + " allowed for " + SecurePrivateKey.class.getName()); } /** * Dumps {@code SecureRSAPrivateKey} basic information. * * @param p a PrintStream usually supplied by {@link Logger} * @param indent indention string, usually suppiled by {@link Logger} */ @Override public void dump (PrintStream p, String indent) { String inner = indent + " "; p.print(indent + ""); p.println(inner + "" + ISOUtil.hexString(getKeyBytes()) + ""); p.println(indent + ""); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy