001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.vfs2.provider.sftp; 018 019import java.io.File; 020 021/** 022 * Structure for an identity. 023 * 024 * @since 2.1 025 */ 026public class IdentityInfo { 027 private final File privateKey; 028 private final File publicKey; 029 private final byte[] passPhrase; 030 031 /** 032 * Constructs an identity info with private key. 033 * <p> 034 * The key is not passphrase protected. 035 * <p> 036 * We use java.io.File because JSch cannot deal with VFS FileObjects. 037 * 038 * @param privateKey The file with the private key 039 * @since 2.1 040 */ 041 public IdentityInfo(final File privateKey) { 042 this(privateKey, null, null); 043 } 044 045 /** 046 * Constructs an identity info with private key and its passphrase. 047 * <p> 048 * We use java.io.File because JSch cannot deal with VFS FileObjects. 049 * 050 * @param privateKey The file with the private key 051 * @param passPhrase The passphrase to decrypt the private key (can be {@code null} if no passphrase is used) 052 * @since 2.1 053 */ 054 public IdentityInfo(final File privateKey, final byte[] passPhrase) { 055 this(privateKey, null, passPhrase); 056 } 057 058 /** 059 * Constructs an identity info with private and public key and passphrase for the private key. 060 * <p> 061 * We use java.io.File because JSch cannot deal with VFS FileObjects. 062 * 063 * @param privateKey The file with the private key 064 * @param publicKey The public key part used for connections with exchange of certificates (can be {@code null}) 065 * @param passPhrase The passphrase to decrypt the private key (can be {@code null} if no passphrase is used) 066 * @since 2.1 067 */ 068 public IdentityInfo(final File privateKey, final File publicKey, final byte[] passPhrase) { 069 this.privateKey = privateKey; 070 this.publicKey = publicKey; 071 this.passPhrase = passPhrase; 072 } 073 074 /** 075 * Get the file with the private key. 076 * 077 * @return the file 078 * @since 2.1 079 */ 080 public File getPrivateKey() { 081 return privateKey; 082 } 083 084 /** 085 * Get the file with the public key. 086 * 087 * @return the file 088 * @since 2.1 089 */ 090 public File getPublicKey() { 091 return publicKey; 092 } 093 094 /** 095 * Get the passphrase of the private key. 096 * 097 * @return the passphrase 098 * @since 2.1 099 */ 100 public byte[] getPassPhrase() { 101 return passPhrase; 102 } 103}