+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Runtime.InteropServices;
-
-internal static partial class Interop
-{
- internal static partial class Glib
- {
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate bool GSourceFunc(IntPtr userData);
-
- [DllImport(Libraries.Glib, EntryPoint = "g_idle_add", CallingConvention = CallingConvention.Cdecl)]
- internal static extern uint IdleAdd(GSourceFunc d, IntPtr data);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Runtime.InteropServices;
-
-internal static partial class Interop
-{
- internal static partial class Libc
- {
- [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int Free(IntPtr ptr);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-internal static partial class Interop
-{
- internal static partial class Libraries
- {
- public const string Smartcard = "libcapi-network-smartcard.so.0";
- public const string Glib = "libglib-2.0.so.0";
- public const string Libc = "libc.so.6";
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Runtime.InteropServices;
-
-internal static partial class Interop
-{
- internal static partial class Smartcard
- {
- //capi-network-smartcard-0.0.6-2.1.armv7l.rpm
- //Smartcard Manager
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_initialize")]
- internal static extern int Initialize();
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_deinitialize")]
- internal static extern int Deinitialize();
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_get_readers")]
- internal static extern int GetReaders(out IntPtr readers, out int len);
-
- internal static class Reader
- {
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_get_name")]
- internal static extern int ReaderGetName(int reader, out IntPtr readerName);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_is_secure_element_present")]
- internal static extern int ReaderIsSecureElementPresent(int reader, out bool present);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_open_session")]
- internal static extern int ReaderOpenSession(int reader, out int session);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_close_sessions")]
- internal static extern int ReaderCloseSessions(int reader);
- }
-
- internal static class Session
- {
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_get_reader")]
- internal static extern int SessionGetReader(int session, out int reader);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_get_atr")]
- internal static extern int SessionGetAtr(int session, out IntPtr atr, out int len);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_close")]
- internal static extern int SessionClose(int session);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_is_closed")]
- internal static extern int SessionIsClosed(int session, out bool closed);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_close_channels")]
- internal static extern int SessionCloseChannels(int session);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_open_basic_channel")]
- internal static extern int SessionOpenBasicChannel(int session, byte[] aid, int aidLen, byte p2, out int channel);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_open_logical_channel")]
- internal static extern int SessionOpenLogicalChannel(int session, byte[] aid, int aidLen, byte p2, out int channel);
- }
-
- internal static class Channel
- {
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_close")]
- internal static extern int ChannelClose(int channel);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_is_basic_channel")]
- internal static extern int ChannelIsBasicChannel(int channel, out bool basicChannel);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_is_closed")]
- internal static extern int ChannelIsClosed(int channel, out bool closed);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_get_select_response")]
- internal static extern int ChannelGetSelectResponse(int channel, out IntPtr selectResp, out int len);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_get_session")]
- internal static extern int ChannelGetSession(int channel, out int session);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_transmit")]
- internal static extern int ChannelTransmit(int channel, byte[] cmd, int cmdLen, out IntPtr resp, out int len);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_transmit_retrieve_response")]
- internal static extern int ChannelTransmitRetrieveResponse(int channel, out IntPtr name, out int len);
- [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_select_next")]
- internal static extern int ChannelSelectNext(int channel, out bool success);
- }
- }
-}
+++ /dev/null
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Tizen.Smartcard")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Tizen.Smartcard")]
-[assembly: AssemblyCopyright("Copyright \u00A9 2016")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("99a90243-7db1-4704-a078-3529c2da4e81")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
- <PropertyGroup>\r
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
- <ProjectGuid>{BF719F11-CDEA-4D04-A85B-4521A69E3614}</ProjectGuid>\r
- <OutputType>Library</OutputType>\r
- <AppDesignerFolder>Properties</AppDesignerFolder>\r
- <RootNamespace>Tizen.Smartcard</RootNamespace>\r
- <AssemblyName>Tizen.Smartcard</AssemblyName>\r
- <FileAlignment>512</FileAlignment>\r
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
- <DebugSymbols>true</DebugSymbols>\r
- <DebugType>full</DebugType>\r
- <Optimize>false</Optimize>\r
- <OutputPath>bin\Debug\Net45\</OutputPath>\r
- <DefineConstants>DEBUG;TRACE</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- <Prefer32Bit>false</Prefer32Bit>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
- <DebugType>pdbonly</DebugType>\r
- <Optimize>true</Optimize>\r
- <OutputPath>bin\Release\Net45\</OutputPath>\r
- <DefineConstants>TRACE</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- <Prefer32Bit>false</Prefer32Bit>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <SignAssembly>true</SignAssembly>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <AssemblyOriginatorKeyFile>Tizen.Smartcard.snk</AssemblyOriginatorKeyFile>\r
- </PropertyGroup>\r
- <ItemGroup>\r
- <Reference Include="System" />\r
- <Reference Include="System.Core" />\r
- <Reference Include="System.Xml.Linq" />\r
- <Reference Include="System.Data.DataSetExtensions" />\r
- <Reference Include="Microsoft.CSharp" />\r
- <Reference Include="System.Data" />\r
- <Reference Include="System.Net.Http" />\r
- <Reference Include="System.Xml" />\r
- </ItemGroup>\r
- <ItemGroup>\r
- <Compile Include="Interop\Interop.Glib.cs" />\r
- <Compile Include="Interop\Interop.Libc.cs" />\r
- <Compile Include="Interop\Interop.Libraries.cs" />\r
- <Compile Include="Interop\Interop.Smartcard.cs" />\r
- <Compile Include="Properties\AssemblyInfo.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardChannel.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardErrorFactory.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardManager.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardManagerImpl.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardReader.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardSession.cs" />\r
- </ItemGroup>\r
- <ItemGroup>\r
- <None Include="Tizen.Smartcard.nuspec" />\r
- <None Include="Tizen.Smartcard.Net45.project.json" />\r
- <None Include="Tizen.Smartcard.snk" />\r
- </ItemGroup>\r
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.\r
- Other similar extension points exist, see Microsoft.Common.targets.\r
- <Target Name="BeforeBuild">\r
- </Target>\r
- <Target Name="AfterBuild">\r
- </Target>\r
- -->\r
-</Project>
\ No newline at end of file
+++ /dev/null
-{
- "dependencies": {
- "Tizen": "1.0.2"
- },
- "frameworks": {
- "net45": {}
- },
- "runtimes": {
- "win": {}
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
- <PropertyGroup>\r
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
- <ProjectGuid>{3EE5842E-7004-43BC-825B-29FFDEC18D4E}</ProjectGuid>\r
- <OutputType>Library</OutputType>\r
- <AppDesignerFolder>Properties</AppDesignerFolder>\r
- <RootNamespace>Tizen.Smartcard</RootNamespace>\r
- <AssemblyName>Tizen.Smartcard</AssemblyName>\r
- <FileAlignment>512</FileAlignment>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>\r
- <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>\r
- <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>\r
- <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>\r
- <NoStdLib>true</NoStdLib>\r
- <NoWarn>$(NoWarn);1701;1702</NoWarn>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
- <DebugSymbols>true</DebugSymbols>\r
- <DebugType>full</DebugType>\r
- <Optimize>false</Optimize>\r
- <OutputPath>bin\Debug\</OutputPath>\r
- <DefineConstants>DEBUG;TRACE</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- <Prefer32Bit>false</Prefer32Bit>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
- <DebugType>pdbonly</DebugType>\r
- <Optimize>true</Optimize>\r
- <OutputPath>bin\Release\</OutputPath>\r
- <DefineConstants>TRACE</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- <Prefer32Bit>false</Prefer32Bit>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <SignAssembly>true</SignAssembly>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <AssemblyOriginatorKeyFile>Tizen.Smartcard.snk</AssemblyOriginatorKeyFile>\r
- </PropertyGroup>\r
- <ItemGroup>\r
- <Compile Include="Interop\Interop.Glib.cs" />\r
- <Compile Include="Interop\Interop.Libc.cs" />\r
- <Compile Include="Interop\Interop.Libraries.cs" />\r
- <Compile Include="Interop\Interop.Smartcard.cs" />\r
- <Compile Include="Properties\AssemblyInfo.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardChannel.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardErrorFactory.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardManager.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardManagerImpl.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardReader.cs" />\r
- <Compile Include="Tizen.Smartcard\SmartcardSession.cs" />\r
- </ItemGroup>\r
- <ItemGroup>\r
- <None Include="Tizen.Smartcard.nuspec" />\r
- <None Include="Tizen.Smartcard.project.json" />\r
- <None Include="Tizen.Smartcard.snk" />\r
- </ItemGroup>\r
- <Import Project="$(MSBuildExtensionsPath)\Tizen\Tizen.CSharp.GBS.targets" Condition="Exists('$(MSBuildExtensionsPath)\Tizen\Tizen.CSharp.GBS.targets')" />\r
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.\r
- Other similar extension points exist, see Microsoft.Common.targets.\r
- <Target Name="BeforeBuild">\r
- </Target>\r
- <Target Name="AfterBuild">\r
- </Target>\r
- -->\r
- <PropertyGroup>\r
- <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and\r
- https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild\r
- -->\r
- <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two\r
- properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and\r
- to prevent it from outputting a warning (MSB3644).\r
- -->\r
- <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>\r
- <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>\r
- <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>\r
- </PropertyGroup>\r
-</Project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<package>
- <metadata>
- <id>Tizen.Smartcard</id>
- <version>$version$</version>
- <authors>Samsung Electronics</authors>
- <requireLicenseAcceptance>false</requireLicenseAcceptance>
- <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
- <projectUrl>https://www.tizen.org/</projectUrl>
- <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>
- <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>
- <description>Provides the Smartcard API for Tizen.Net</description>
- <dependencies>
- <dependency id="Tizen" version="1.0.2" />
- </dependencies>
- </metadata>
- <files>
- <file src="bin/$Configuration$/Tizen.Smartcard.dll" target="lib/netstandard1.3" />
- <file src="bin/$Configuration$/Net45/Tizen.Smartcard.dll" target="lib/net45" />
- </files>
-</package>
+++ /dev/null
-{
- "dependencies": {
- "NETStandard.Library": "1.6.0",
- "Tizen": "1.0.2"
- },
- "frameworks": {
- "netstandard1.3": {}
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Runtime.InteropServices;
-using System.Collections.Generic;
-using Tizen.Network;
-
-namespace Tizen.Network.Smartcard
-{
- /// <summary>
- /// A class for Smartcard channel informations. It allows applications to handle channel informations.
- /// </summary>
- /// <privilege>http://tizen.org/privilege/secureelement</privilege>
- public class SmartcardChannel : IDisposable
- {
- private int _channelHandle = -1;
- private bool disposed = false;
- private SmartcardSession _sessionObject;
-
- /// <summary>
- /// Whether the kind of channel is basic.
- /// </summary>
- public bool IsBasicChannel
- {
- get
- {
- bool isBasicChannel;
- int ret = Interop.Smartcard.Channel.ChannelIsBasicChannel(_channelHandle, out isBasicChannel);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get basic channel, Error - " + (SmartcardError)ret);
- }
- return isBasicChannel;
- }
- }
-
- /// <summary>
- /// Whether the kind of channel is logical.
- /// </summary>
- public bool IsLogicalChannel
- {
- get
- {
- bool isBasicChannel;
- int ret = Interop.Smartcard.Channel.ChannelIsBasicChannel(_channelHandle, out isBasicChannel);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get logical channel, Error - " + (SmartcardError)ret);
- }
- return !isBasicChannel;
- }
- }
-
- /// <summary>
- /// Whether the channel is closed.
- /// </summary>
- public bool IsClosed
- {
- get
- {
- bool isClosed;
- int ret = Interop.Smartcard.Channel.ChannelIsClosed(_channelHandle, out isClosed);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get closed, Error - " + (SmartcardError)ret);
- }
- return isClosed;
- }
- }
-
- /// <summary>
- /// The session that has opened the given channel.
- /// </summary>
- public SmartcardSession Session
- {
- get
- {
- int session;
- int ret = Interop.Smartcard.Channel.ChannelGetSession(_channelHandle, out session);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get session, Error - " + (SmartcardError)ret);
- }
-
- if (_sessionObject.GetHandle() != session)
- {
- Log.Error(Globals.LogTag, "Does not correspond with session, Error - " + _sessionObject.GetHandle() + " " + session);
- }
-
- return _sessionObject;
- }
- }
-
- internal SmartcardChannel(SmartcardSession sessionHandle, int channelHandle)
- {
- _sessionObject = sessionHandle;
- _channelHandle = channelHandle;
- }
-
- ~SmartcardChannel()
- {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (disposed)
- return;
-
- if (disposing)
- {
- // Free managed objects.
- }
- //Free unmanaged objects
- disposed = true;
- }
-
- /// <summary>
- /// Closes the given channel to the Secure Element.
- /// </summary>
- public void Close()
- {
- int ret = Interop.Smartcard.Channel.ChannelClose(_channelHandle);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to channel close, Error - " + (SmartcardError)ret);
- SmartcardErrorFactory.ThrowSmartcardException(ret);
- }
- Dispose(true);
- }
-
- /// <summary>
- /// Gets the response to the select command.
- /// </summary>
- /// <returns>Byte array to retrieve the SELECT response.</returns>
- public byte[] GetSelectedResponse()
- {
- byte[] respList;
- IntPtr strAtr;
- int len;
- int ret = Interop.Smartcard.Channel.ChannelGetSelectResponse(_channelHandle, out strAtr, out len);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get select response, Error - " + (SmartcardError)ret);
- }
-
- respList = new byte[len];
- for (int i = 0; i < len; i++)
- {
- respList[i] = Marshal.ReadByte(strAtr);
- strAtr += sizeof(byte);
- }
- return respList;
- }
-
- /// <summary>
- /// Transmits an APDU command (as per ISO/IEC 7816-4) to the Secure Element.
- /// </summary>
- /// <returns>Byte array for the response APDU plus status words.</returns>
- /// <param name="cmd">Command APDU to be send to the secure element.</param>
- public byte[] Transmit(byte[] cmd)
- {
- byte[] atrList;
- IntPtr strAtr;
- int len;
- int ret = Interop.Smartcard.Channel.ChannelTransmit(_channelHandle, cmd, cmd.Length, out strAtr, out len);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to transmit, Error - " + (SmartcardError)ret);
- }
-
- atrList = new byte[len];
- for (int i = 0; i < len; i++)
- {
- atrList[i] = Marshal.ReadByte(strAtr);
- strAtr += sizeof(byte);
- }
-
- return atrList;
- }
-
- /// <summary>
- /// Helper function to retrieves the response APDU of the previous transmit() call.
- /// </summary>
- /// <returns>Byte array for the response APDU plus status words.</returns>
- public byte[] GetTransmittedResponse()
- {
- byte[] respList;
- IntPtr strAtr;
- int len;
- int ret = Interop.Smartcard.Channel.ChannelTransmitRetrieveResponse(_channelHandle, out strAtr, out len);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get trasmit retrieve response, Error - " + (SmartcardError)ret);
- }
-
- respList = new byte[len];
- for (int i = 0; i < len; i++)
- {
- respList[i] = Marshal.ReadByte(strAtr);
- strAtr += sizeof(byte);
- }
- return respList;
- }
-
- /// <summary>
- /// Performs a selection of the next Applet on the given channel that matches to the partial Application ID(AID).
- /// </summary>
- /// <returns>True or false depending whether another applet with the partial Application ID(AID).</returns>
- public bool SelectNext()
- {
- bool selectNext;
- int ret = Interop.Smartcard.Channel.ChannelSelectNext(_channelHandle, out selectNext);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to select next, Error - " + (SmartcardError)ret);
- }
- return selectNext;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Tizen.Internals.Errors;
-
-namespace Tizen.Network.Smartcard
-{
- internal enum SmartcardError
- {
- None = ErrorCode.None,
- IoError = ErrorCode.IoError,
- InvalidParameterError = ErrorCode.InvalidParameter,
- PermissionDeniedError = ErrorCode.PermissionDenied,
- NotSupportedError = ErrorCode.NotSupported,
- GeneralError = -0x01C70000 | 0x01,
- NoSuchElementError = -0x01C70000 | 0x02,
- IllegalStateError = -0x01C70000 | 0x03,
- IllegalReferenceError = -0x01C70000 | 0x04,
- OperationNotSupportError = -0x01C70000 | 0x05,
- ChannelNotAvailableError = -0x01C70000 | 0x06,
- NotInitializedError = -0x01C70000 | 0x07
- }
-
- internal static class SmartcardErrorFactory
- {
- static internal void ThrowSmartcardException(int e)
- {
- ThrowException(e, false);
- }
-
- static internal void ThrowSmartcardException(int e, int handle)
- {
- ThrowException(e, (handle < 0));
- }
-
- static private void ThrowException(int e, bool isHandleNull)
- {
- SmartcardError err = (SmartcardError)e;
-
- if (isHandleNull)
- {
- throw new InvalidOperationException("Invalid instance (object may have been disposed or released)");
- }
-
- if (err == SmartcardError.InvalidParameterError)
- {
- throw new ArgumentException(err.ToString());
- }
- else
- {
- throw new InvalidOperationException(err.ToString());
- }
- }
-
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-
-namespace Tizen.Network.Smartcard
-{
- /// <summary>
- /// A class for Smartcard management. It allows applications to use Smartcard service.
- /// </summary>
- /// <privilege>http://tizen.org/privilege/secureelement</privilege>
- static public class SmartcardManager
- {
- /// <summary>
- /// Gets the list of available Secure Element readers.
- /// </summary>
- /// <returns>List of SmartcardReader objects.</returns>
- static public IEnumerable<SmartcardReader> GetReaders()
- {
- return SmartcardManagerImpl.Instance.GetReaders();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-
-namespace Tizen.Network.Smartcard
-{
- static internal class Globals
- {
- internal const string LogTag = "Tizen.Network.Smartcard";
- }
-
- internal class SmartcardManagerImpl : IDisposable
- {
- private static readonly SmartcardManagerImpl _instance = new SmartcardManagerImpl();
- private List<SmartcardReader> _readerList = new List<SmartcardReader>();
- private bool disposed = false;
-
- internal static SmartcardManagerImpl Instance
- {
- get
- {
- return _instance;
- }
- }
-
- private SmartcardManagerImpl()
- {
- initialize();
- }
-
- ~SmartcardManagerImpl()
- {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (disposed)
- return;
-
- if (disposing)
- {
- // Free managed objects.
- foreach (SmartcardReader reader in _readerList)
- {
- reader.Dispose();
- _readerList.Remove(reader);
- }
- }
- //Free unmanaged objects
- deinitialize();
- disposed = true;
- }
-
- private void initialize()
- {
- int ret = Interop.Smartcard.Initialize();
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to initialize smartcard, Error - " + (SmartcardError)ret);
- SmartcardErrorFactory.ThrowSmartcardException(ret);
- }
- }
-
- private void deinitialize()
- {
- int ret = Interop.Smartcard.Deinitialize();
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to deinitialize smartcard, Error - " + (SmartcardError)ret);
- SmartcardErrorFactory.ThrowSmartcardException(ret);
- }
- }
-
- internal IEnumerable<SmartcardReader> GetReaders()
- {
- IntPtr readerPtr;
- int len = 0;
-
- int ret = Interop.Smartcard.GetReaders(out readerPtr, out len);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to remove with AP, Error - " + (SmartcardError)ret);
- SmartcardErrorFactory.ThrowSmartcardException(ret);
- }
-
- for (int i = 0; i < len; i++)
- {
- int readerID = Marshal.ReadInt32(readerPtr);
-
- SmartcardReader readerItem = new SmartcardReader(readerID);
- _readerList.Add(readerItem);
- readerPtr += sizeof(int);
- }
-
- return _readerList;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Runtime.InteropServices;
-using System.Collections.Generic;
-using Tizen.Network;
-
-namespace Tizen.Network.Smartcard
-{
- /// <summary>
- /// A class for Smartcard reader informations. It allows applications to handle reader informations.
- /// </summary>
- /// <privilege>http://tizen.org/privilege/secureelement</privilege>
- public class SmartcardReader : IDisposable
- {
- private int _readerHandle = -1;
- private int _session;
- private bool disposed = false;
- private List<SmartcardSession> _sessionList = new List<SmartcardSession>();
-
- /// <summary>
- /// The name of reader.
- /// </summary>
- public string Name
- {
- get
- {
- IntPtr strPtr;
- int ret = Interop.Smartcard.Reader.ReaderGetName(_readerHandle, out strPtr);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get reader name, Error - " + (SmartcardError)ret);
- return "";
- }
- return Marshal.PtrToStringAnsi(strPtr);
- }
- }
-
- /// <summary>
- /// The existence of secure element.
- /// </summary>
- public bool IsSecureElementPresent
- {
- get
- {
- bool isPresent;
- int ret = Interop.Smartcard.Reader.ReaderIsSecureElementPresent(_readerHandle, out isPresent);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get present, Error - " + (SmartcardError)ret);
- }
- return isPresent;
- }
- }
-
- internal SmartcardReader(int handle)
- {
- _readerHandle = handle;
- }
-
- ~SmartcardReader()
- {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (disposed)
- return;
-
- if (disposing)
- {
- // Free managed objects.
- foreach (SmartcardSession session in _sessionList)
- {
- session.Dispose();
- _sessionList.Remove(session);
- }
- }
- //Free unmanaged objects
- disposed = true;
- }
-
- internal int GetHandle()
- {
- return _readerHandle;
- }
-
- internal int GetSession()
- {
- return _session;
- }
-
- /// <summary>
- /// Connects to a Secure Element in the given reader.
- /// </summary>
- /// <returns>The SmartcardSession object.</returns>
- public SmartcardSession OpenSession()
- {
- int ret = Interop.Smartcard.Reader.ReaderOpenSession(_readerHandle, out _session);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get session handle, Error - " + (SmartcardError)ret);
- }
-
- SmartcardSession session = new SmartcardSession(this, _session);
- _sessionList.Add(session);
- return session;
- }
-
- /// <summary>
- /// Closes all the sessions opened on the given reader.
- /// </summary>
- public void CloseSessions()
- {
- int ret = Interop.Smartcard.Reader.ReaderCloseSessions(_readerHandle);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to close sessions, Error - " + (SmartcardError)ret);
- SmartcardErrorFactory.ThrowSmartcardException(ret);
- }
-
- foreach (SmartcardSession session in _sessionList)
- {
- session.Dispose();
- _sessionList.Remove(session);
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Runtime.InteropServices;
-using System.Collections.Generic;
-using Tizen.Network;
-
-namespace Tizen.Network.Smartcard
-{
- /// <summary>
- /// A class for Smartcard session informations. It allows applications to handle session informations.
- /// </summary>
- /// <privilege>http://tizen.org/privilege/secureelement</privilege>
- public class SmartcardSession : IDisposable
- {
- private int _sessionHandle = -1;
- private bool disposed = false;
- private List<SmartcardChannel> _basicChannelList = new List<SmartcardChannel>();
- private List<SmartcardChannel> _logicalChannelList = new List<SmartcardChannel>();
- private SmartcardReader _readerObject;
- private int _basicChannel = 0;
- private int _logicalChannel = 0;
-
- /// <summary>
- /// The reader object that provides the given session.
- /// </summary>
- public SmartcardReader Reader
- {
- get
- {
- int reader;
- int ret = Interop.Smartcard.Session.SessionGetReader(_sessionHandle, out reader);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get reader, Error - " + (SmartcardError)ret);
- }
-
- if (_readerObject.GetHandle() != reader)
- {
- Log.Error(Globals.LogTag, "Does not correspond with reader, Error - " + _readerObject.GetHandle() + " " + reader);
- }
-
- return _readerObject;
- }
- }
-
- /// <summary>
- /// The Answer to Reset(ATR) of this Secure Element.
- /// </summary>
- public byte[] Atr
- {
- get
- {
- byte[] atrList;
- IntPtr strAtr;
- int len;
- int ret = Interop.Smartcard.Session.SessionGetAtr(_sessionHandle, out strAtr, out len);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get atr, Error - " + (SmartcardError)ret);
- }
-
- atrList = new byte[len];
- for (int i = 0; i < len; i++)
- {
- atrList[i] = Marshal.ReadByte(strAtr);
- strAtr += sizeof(byte);
- }
- return atrList;
- }
- }
-
- /// <summary>
- /// Whether the session is closed.
- /// </summary>
- public bool IsClosed
- {
- get
- {
- bool isClosed;
- int ret = Interop.Smartcard.Session.SessionIsClosed(_sessionHandle, out isClosed);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get present, Error - " + (SmartcardError)ret);
- }
- return isClosed;
- }
- }
-
- internal SmartcardSession(SmartcardReader readerHandle, int sessionHandle)
- {
- _readerObject = readerHandle;
- _sessionHandle = sessionHandle;
- }
-
- ~SmartcardSession()
- {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (disposed)
- return;
-
- if (disposing)
- {
- // Free managed objects.
- foreach (SmartcardChannel channel in _basicChannelList)
- {
- channel.Dispose();
- _basicChannelList.Remove(channel);
- }
-
- foreach (SmartcardChannel channel in _logicalChannelList)
- {
- channel.Dispose();
- _logicalChannelList.Remove(channel);
- }
- }
- //Free unmanaged objects
- disposed = true;
- }
-
- internal int GetHandle()
- {
- return _sessionHandle;
- }
-
- /// <summary>
- /// Closes the connection with the Secure Element.
- /// </summary>
- public void Close()
- {
- int ret = Interop.Smartcard.Session.SessionClose(_sessionHandle);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to close, Error - " + (SmartcardError)ret);
- SmartcardErrorFactory.ThrowSmartcardException(ret);
- }
- Dispose(true);
- }
-
- /// <summary>
- /// Closes any channel opened on the given session.
- /// </summary>
- public void CloseChannels()
- {
- int ret = Interop.Smartcard.Session.SessionCloseChannels(_sessionHandle);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to close, Error - " + (SmartcardError)ret);
- SmartcardErrorFactory.ThrowSmartcardException(ret);
- }
-
- foreach (SmartcardChannel channel in _basicChannelList)
- {
- channel.Dispose();
- _basicChannelList.Remove(channel);
- }
-
- foreach (SmartcardChannel channel in _logicalChannelList)
- {
- channel.Dispose();
- _logicalChannelList.Remove(channel);
- }
- }
-
- /// <summary>
- /// Gets an access to the basic channel, as defined in the ISO/IEC 7816-4 specification (the one that has number 0).
- /// </summary>
- /// <returns>The SmartcardChannel object for basic channel.</returns>
- /// <param name="aid">Byte array containing the Application ID(AID) to be selected on the given channel.</param>
- /// <param name="p2">P2 byte of the SELECT command if executed.</param>
- public SmartcardChannel OpenBasicChannel(byte[] aid, byte p2)
- {
- int ret = Interop.Smartcard.Session.SessionOpenBasicChannel(_sessionHandle, aid, aid.Length, p2, out _basicChannel);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to open basic channel, Error - " + (SmartcardError)ret);
- SmartcardErrorFactory.ThrowSmartcardException(ret);
- }
- SmartcardChannel basicChannel = new SmartcardChannel(this, _basicChannel);
- _basicChannelList.Add(basicChannel);
-
- return basicChannel;
- }
-
- /// <summary>
- /// Open a logical channel with the Secure Element, selecting the Applet represented by the given Application ID(AID).
- /// </summary>
- /// <returns>The SmartcardChannel object for logical channel.</returns>
- /// <param name="aid">Byte array containing the Application ID(AID) to be selected on the given channel.</param>
- /// <param name="p2">P2 byte of the SELECT command if executed.</param>
- public SmartcardChannel OpenLogicalChannel(byte[] aid, byte p2)
- {
- int ret = Interop.Smartcard.Session.SessionOpenLogicalChannel(_sessionHandle, aid, aid.Length, p2, out _logicalChannel);
- if (ret != (int)SmartcardError.None)
- {
- Log.Error(Globals.LogTag, "Failed to open logical channel, Error - " + (SmartcardError)ret);
- SmartcardErrorFactory.ThrowSmartcardException(ret);
- }
- SmartcardChannel logicalChannel = new SmartcardChannel(this, _logicalChannel);
- _logicalChannelList.Add(logicalChannel);
-
- return logicalChannel;
- }
- }
-}
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+%{!?dotnet_assembly_path: %define dotnet_assembly_path /opt/usr/share/dotnet.tizen/framework}
+
+%if 0%{?tizen_build_devel_mode}
+%define BUILDCONF Debug
+%else
+%define BUILDCONF Release
+%endif
+
+Name: csapi-network-smartcard
+Summary: Tizen Smartcard API for C#
+Version: 1.0.2
+Release: 1
+Group: Development/Libraries
+License: Apache-2.0
+URL: https://www.tizen.org
+Source0: %{name}-%{version}.tar.gz
+Source1: %{name}.manifest
+
+AutoReqProv: no
+ExcludeArch: %{ix86} aarch64
+
+BuildRequires: mono-compiler
+BuildRequires: mono-devel
+
+BuildRequires: dotnet-build-tools
+
+# C# API Requries
+BuildRequires: csapi-tizen-nuget
+
+%description
+Tizen Smartcard API for C#
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%define Assemblies Tizen.Network.Smartcard
+
+%build
+for ASM in %{Assemblies}; do
+# NuGet Restore
+find $ASM/*.project.json -exec nuget restore {} \;
+# Build
+find $ASM/*.csproj -exec xbuild {} /p:Configuration=%{BUILDCONF} \;
+# NuGet Pack
+nuget pack $ASM/$ASM.nuspec -Version %{version} -Properties Configuration=%{BUILDCONF}
+done
+
+%install
+# Runtime Binary
+mkdir -p %{buildroot}%{dotnet_assembly_path}
+for ASM in %{Assemblies}; do
+%if 0%{?_with_corefx}
+ install -p -m 644 $ASM/bin/%{BUILDCONF}/$ASM.dll %{buildroot}%{dotnet_assembly_path}
+%else
+ install -p -m 644 $ASM/bin/%{BUILDCONF}/Net45/$ASM.dll %{buildroot}%{dotnet_assembly_path}
+%endif
+done
+# NuGet
+mkdir -p %{buildroot}/nuget
+install -p -m 644 *.nupkg %{buildroot}/nuget
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%attr(644,root,root) %{dotnet_assembly_path}/*.dll
+
+%package nuget
+Summary: NuGet package for %{name}
+Group: Development/Libraries
+
+%description nuget
+NuGet package for %{name}
+
+%files nuget
+/nuget/*.nupkg
+++ /dev/null
-<manifest>
- <request>
- <domain name="_"/>
- </request>
-</manifest>
+++ /dev/null
-%{!?dotnet_assembly_path: %define dotnet_assembly_path /opt/usr/share/dotnet.tizen/framework}
-
-%if 0%{?tizen_build_devel_mode}
-%define BUILDCONF Debug
-%else
-%define BUILDCONF Release
-%endif
-
-Name: csapi-smartcard
-Summary: Tizen Smartcard API for C#
-Version: 1.0.2
-Release: 1
-Group: Development/Libraries
-License: Apache-2.0
-URL: https://www.tizen.org
-Source0: %{name}-%{version}.tar.gz
-Source1: %{name}.manifest
-
-AutoReqProv: no
-ExcludeArch: %{ix86} aarch64
-
-BuildRequires: mono-compiler
-BuildRequires: mono-devel
-
-BuildRequires: dotnet-build-tools
-
-# C# API Requries
-BuildRequires: csapi-tizen-nuget
-
-%description
-Tizen Smartcard API for C#
-
-%prep
-%setup -q
-cp %{SOURCE1} .
-
-%define Assemblies Tizen.Smartcard
-
-%build
-for ASM in %{Assemblies}; do
-# NuGet Restore
-find $ASM/*.project.json -exec nuget restore {} \;
-# Build
-find $ASM/*.csproj -exec xbuild {} /p:Configuration=%{BUILDCONF} \;
-# NuGet Pack
-nuget pack $ASM/$ASM.nuspec -Version %{version} -Properties Configuration=%{BUILDCONF}
-done
-
-%install
-# Runtime Binary
-mkdir -p %{buildroot}%{dotnet_assembly_path}
-for ASM in %{Assemblies}; do
-%if 0%{?_with_corefx}
- install -p -m 644 $ASM/bin/%{BUILDCONF}/$ASM.dll %{buildroot}%{dotnet_assembly_path}
-%else
- install -p -m 644 $ASM/bin/%{BUILDCONF}/Net45/$ASM.dll %{buildroot}%{dotnet_assembly_path}
-%endif
-done
-# NuGet
-mkdir -p %{buildroot}/nuget
-install -p -m 644 *.nupkg %{buildroot}/nuget
-
-%files
-%manifest %{name}.manifest
-%license LICENSE
-%attr(644,root,root) %{dotnet_assembly_path}/*.dll
-
-%package nuget
-Summary: NuGet package for %{name}
-Group: Development/Libraries
-
-%description nuget
-NuGet package for %{name}
-
-%files nuget
-/nuget/*.nupkg
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class Glib
+ {
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool GSourceFunc(IntPtr userData);
+
+ [DllImport(Libraries.Glib, EntryPoint = "g_idle_add", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern uint IdleAdd(GSourceFunc d, IntPtr data);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class Libc
+ {
+ [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int Free(IntPtr ptr);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+ internal static partial class Libraries
+ {
+ public const string Smartcard = "libcapi-network-smartcard.so.0";
+ public const string Glib = "libglib-2.0.so.0";
+ public const string Libc = "libc.so.6";
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class Smartcard
+ {
+ //capi-network-smartcard-0.0.6-2.1.armv7l.rpm
+ //Smartcard Manager
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_initialize")]
+ internal static extern int Initialize();
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_deinitialize")]
+ internal static extern int Deinitialize();
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_get_readers")]
+ internal static extern int GetReaders(out IntPtr readers, out int len);
+
+ internal static class Reader
+ {
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_get_name")]
+ internal static extern int ReaderGetName(int reader, out IntPtr readerName);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_is_secure_element_present")]
+ internal static extern int ReaderIsSecureElementPresent(int reader, out bool present);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_open_session")]
+ internal static extern int ReaderOpenSession(int reader, out int session);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_close_sessions")]
+ internal static extern int ReaderCloseSessions(int reader);
+ }
+
+ internal static class Session
+ {
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_get_reader")]
+ internal static extern int SessionGetReader(int session, out int reader);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_get_atr")]
+ internal static extern int SessionGetAtr(int session, out IntPtr atr, out int len);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_close")]
+ internal static extern int SessionClose(int session);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_is_closed")]
+ internal static extern int SessionIsClosed(int session, out bool closed);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_close_channels")]
+ internal static extern int SessionCloseChannels(int session);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_open_basic_channel")]
+ internal static extern int SessionOpenBasicChannel(int session, byte[] aid, int aidLen, byte p2, out int channel);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_open_logical_channel")]
+ internal static extern int SessionOpenLogicalChannel(int session, byte[] aid, int aidLen, byte p2, out int channel);
+ }
+
+ internal static class Channel
+ {
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_close")]
+ internal static extern int ChannelClose(int channel);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_is_basic_channel")]
+ internal static extern int ChannelIsBasicChannel(int channel, out bool basicChannel);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_is_closed")]
+ internal static extern int ChannelIsClosed(int channel, out bool closed);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_get_select_response")]
+ internal static extern int ChannelGetSelectResponse(int channel, out IntPtr selectResp, out int len);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_get_session")]
+ internal static extern int ChannelGetSession(int channel, out int session);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_transmit")]
+ internal static extern int ChannelTransmit(int channel, byte[] cmd, int cmdLen, out IntPtr resp, out int len);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_transmit_retrieve_response")]
+ internal static extern int ChannelTransmitRetrieveResponse(int channel, out IntPtr name, out int len);
+ [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_select_next")]
+ internal static extern int ChannelSelectNext(int channel, out bool success);
+ }
+ }
+}
--- /dev/null
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tizen.Network.Smartcard")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tizen.Network.Smartcard")]
+[assembly: AssemblyCopyright("Copyright \u00A9 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("99a90243-7db1-4704-a078-3529c2da4e81")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <PropertyGroup>\r
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+ <ProjectGuid>{BF719F11-CDEA-4D04-A85B-4521A69E3614}</ProjectGuid>\r
+ <OutputType>Library</OutputType>\r
+ <AppDesignerFolder>Properties</AppDesignerFolder>\r
+ <RootNamespace>Tizen.Network.Smartcard</RootNamespace>\r
+ <AssemblyName>Tizen.Network.Smartcard</AssemblyName>\r
+ <FileAlignment>512</FileAlignment>\r
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugSymbols>true</DebugSymbols>\r
+ <DebugType>full</DebugType>\r
+ <Optimize>false</Optimize>\r
+ <OutputPath>bin\Debug\Net45\</OutputPath>\r
+ <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ <Prefer32Bit>false</Prefer32Bit>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <DebugType>pdbonly</DebugType>\r
+ <Optimize>true</Optimize>\r
+ <OutputPath>bin\Release\Net45\</OutputPath>\r
+ <DefineConstants>TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ <Prefer32Bit>false</Prefer32Bit>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <SignAssembly>true</SignAssembly>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <AssemblyOriginatorKeyFile>Tizen.Network.Smartcard.snk</AssemblyOriginatorKeyFile>\r
+ </PropertyGroup>\r
+ <ItemGroup>\r
+ <Reference Include="System" />\r
+ <Reference Include="System.Core" />\r
+ <Reference Include="System.Xml.Linq" />\r
+ <Reference Include="System.Data.DataSetExtensions" />\r
+ <Reference Include="Microsoft.CSharp" />\r
+ <Reference Include="System.Data" />\r
+ <Reference Include="System.Net.Http" />\r
+ <Reference Include="System.Xml" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <Compile Include="Interop\Interop.Glib.cs" />\r
+ <Compile Include="Interop\Interop.Libc.cs" />\r
+ <Compile Include="Interop\Interop.Libraries.cs" />\r
+ <Compile Include="Interop\Interop.Smartcard.cs" />\r
+ <Compile Include="Properties\AssemblyInfo.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardChannel.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardErrorFactory.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardManager.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardManagerImpl.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardReader.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardSession.cs" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <None Include="Tizen.Network.Smartcard.nuspec" />\r
+ <None Include="Tizen.Network.Smartcard.Net45.project.json" />\r
+ <None Include="Tizen.Network.Smartcard.snk" />\r
+ </ItemGroup>\r
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.\r
+ Other similar extension points exist, see Microsoft.Common.targets.\r
+ <Target Name="BeforeBuild">\r
+ </Target>\r
+ <Target Name="AfterBuild">\r
+ </Target>\r
+ -->\r
+</Project>
\ No newline at end of file
--- /dev/null
+{
+ "dependencies": {
+ "Tizen": "1.0.2"
+ },
+ "frameworks": {
+ "net45": {}
+ },
+ "runtimes": {
+ "win": {}
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <PropertyGroup>\r
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+ <ProjectGuid>{3EE5842E-7004-43BC-825B-29FFDEC18D4E}</ProjectGuid>\r
+ <OutputType>Library</OutputType>\r
+ <AppDesignerFolder>Properties</AppDesignerFolder>\r
+ <RootNamespace>Tizen.Network.Smartcard</RootNamespace>\r
+ <AssemblyName>Tizen.Network.Smartcard</AssemblyName>\r
+ <FileAlignment>512</FileAlignment>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>\r
+ <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>\r
+ <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>\r
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>\r
+ <NoStdLib>true</NoStdLib>\r
+ <NoWarn>$(NoWarn);1701;1702</NoWarn>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugSymbols>true</DebugSymbols>\r
+ <DebugType>full</DebugType>\r
+ <Optimize>false</Optimize>\r
+ <OutputPath>bin\Debug\</OutputPath>\r
+ <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ <Prefer32Bit>false</Prefer32Bit>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <DebugType>pdbonly</DebugType>\r
+ <Optimize>true</Optimize>\r
+ <OutputPath>bin\Release\</OutputPath>\r
+ <DefineConstants>TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ <Prefer32Bit>false</Prefer32Bit>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <SignAssembly>true</SignAssembly>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <AssemblyOriginatorKeyFile>Tizen.Network.Smartcard.snk</AssemblyOriginatorKeyFile>\r
+ </PropertyGroup>\r
+ <ItemGroup>\r
+ <Compile Include="Interop\Interop.Glib.cs" />\r
+ <Compile Include="Interop\Interop.Libc.cs" />\r
+ <Compile Include="Interop\Interop.Libraries.cs" />\r
+ <Compile Include="Interop\Interop.Smartcard.cs" />\r
+ <Compile Include="Properties\AssemblyInfo.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardChannel.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardErrorFactory.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardManager.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardManagerImpl.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardReader.cs" />\r
+ <Compile Include="Tizen.Network.Smartcard\SmartcardSession.cs" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <None Include="Tizen.Network.Smartcard.nuspec" />\r
+ <None Include="Tizen.Network.Smartcard.project.json" />\r
+ <None Include="Tizen.Network.Smartcard.snk" />\r
+ </ItemGroup>\r
+ <Import Project="$(MSBuildExtensionsPath)\Tizen\Tizen.CSharp.GBS.targets" Condition="Exists('$(MSBuildExtensionsPath)\Tizen\Tizen.CSharp.GBS.targets')" />\r
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.\r
+ Other similar extension points exist, see Microsoft.Common.targets.\r
+ <Target Name="BeforeBuild">\r
+ </Target>\r
+ <Target Name="AfterBuild">\r
+ </Target>\r
+ -->\r
+ <PropertyGroup>\r
+ <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and\r
+ https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild\r
+ -->\r
+ <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two\r
+ properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and\r
+ to prevent it from outputting a warning (MSB3644).\r
+ -->\r
+ <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>\r
+ <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>\r
+ <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>\r
+ </PropertyGroup>\r
+</Project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<package>
+ <metadata>
+ <id>Tizen.Network.Smartcard</id>
+ <version>$version$</version>
+ <authors>Samsung Electronics</authors>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
+ <projectUrl>https://www.tizen.org/</projectUrl>
+ <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>
+ <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>
+ <description>Provides the Smartcard API for Tizen.Net</description>
+ <dependencies>
+ <dependency id="Tizen" version="1.0.2" />
+ </dependencies>
+ </metadata>
+ <files>
+ <file src="bin/$Configuration$/Tizen.Network.Smartcard.dll" target="lib/netstandard1.3" />
+ <file src="bin/$Configuration$/Net45/Tizen.Network.Smartcard.dll" target="lib/net45" />
+ </files>
+</package>
--- /dev/null
+{
+ "dependencies": {
+ "NETStandard.Library": "1.6.0",
+ "Tizen": "1.0.2"
+ },
+ "frameworks": {
+ "netstandard1.3": {}
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+
+namespace Tizen.Network.Smartcard
+{
+ /// <summary>
+ /// A class for Smartcard channel informations. It allows applications to handle channel informations.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/secureelement</privilege>
+ public class SmartcardChannel : IDisposable
+ {
+ private int _channelHandle = -1;
+ private bool disposed = false;
+ private SmartcardSession _sessionObject;
+
+ /// <summary>
+ /// Whether the kind of channel is basic.
+ /// </summary>
+ public bool IsBasicChannel
+ {
+ get
+ {
+ bool isBasicChannel;
+ int ret = Interop.Smartcard.Channel.ChannelIsBasicChannel(_channelHandle, out isBasicChannel);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get basic channel, Error - " + (SmartcardError)ret);
+ }
+ return isBasicChannel;
+ }
+ }
+
+ /// <summary>
+ /// Whether the kind of channel is logical.
+ /// </summary>
+ public bool IsLogicalChannel
+ {
+ get
+ {
+ bool isBasicChannel;
+ int ret = Interop.Smartcard.Channel.ChannelIsBasicChannel(_channelHandle, out isBasicChannel);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get logical channel, Error - " + (SmartcardError)ret);
+ }
+ return !isBasicChannel;
+ }
+ }
+
+ /// <summary>
+ /// Whether the channel is closed.
+ /// </summary>
+ public bool IsClosed
+ {
+ get
+ {
+ bool isClosed;
+ int ret = Interop.Smartcard.Channel.ChannelIsClosed(_channelHandle, out isClosed);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get closed, Error - " + (SmartcardError)ret);
+ }
+ return isClosed;
+ }
+ }
+
+ /// <summary>
+ /// The session that has opened the given channel.
+ /// </summary>
+ public SmartcardSession Session
+ {
+ get
+ {
+ int session;
+ int ret = Interop.Smartcard.Channel.ChannelGetSession(_channelHandle, out session);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get session, Error - " + (SmartcardError)ret);
+ }
+
+ if (_sessionObject.GetHandle() != session)
+ {
+ Log.Error(Globals.LogTag, "Does not correspond with session, Error - " + _sessionObject.GetHandle() + " " + session);
+ }
+
+ return _sessionObject;
+ }
+ }
+
+ internal SmartcardChannel(SmartcardSession sessionHandle, int channelHandle)
+ {
+ _sessionObject = sessionHandle;
+ _channelHandle = channelHandle;
+ }
+
+ ~SmartcardChannel()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposed)
+ return;
+
+ if (disposing)
+ {
+ // Free managed objects.
+ }
+ //Free unmanaged objects
+ disposed = true;
+ }
+
+ /// <summary>
+ /// Closes the given channel to the Secure Element.
+ /// </summary>
+ public void Close()
+ {
+ int ret = Interop.Smartcard.Channel.ChannelClose(_channelHandle);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to channel close, Error - " + (SmartcardError)ret);
+ SmartcardErrorFactory.ThrowSmartcardException(ret);
+ }
+ Dispose(true);
+ }
+
+ /// <summary>
+ /// Gets the response to the select command.
+ /// </summary>
+ /// <returns>Byte array to retrieve the SELECT response.</returns>
+ public byte[] GetSelectedResponse()
+ {
+ byte[] respList;
+ IntPtr strAtr;
+ int len;
+ int ret = Interop.Smartcard.Channel.ChannelGetSelectResponse(_channelHandle, out strAtr, out len);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get select response, Error - " + (SmartcardError)ret);
+ }
+
+ respList = new byte[len];
+ for (int i = 0; i < len; i++)
+ {
+ respList[i] = Marshal.ReadByte(strAtr);
+ strAtr += sizeof(byte);
+ }
+ return respList;
+ }
+
+ /// <summary>
+ /// Transmits an APDU command (as per ISO/IEC 7816-4) to the Secure Element.
+ /// </summary>
+ /// <returns>Byte array for the response APDU plus status words.</returns>
+ /// <param name="cmd">Command APDU to be send to the secure element.</param>
+ public byte[] Transmit(byte[] cmd)
+ {
+ byte[] atrList;
+ IntPtr strAtr;
+ int len;
+ int ret = Interop.Smartcard.Channel.ChannelTransmit(_channelHandle, cmd, cmd.Length, out strAtr, out len);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to transmit, Error - " + (SmartcardError)ret);
+ }
+
+ atrList = new byte[len];
+ for (int i = 0; i < len; i++)
+ {
+ atrList[i] = Marshal.ReadByte(strAtr);
+ strAtr += sizeof(byte);
+ }
+
+ return atrList;
+ }
+
+ /// <summary>
+ /// Helper function to retrieves the response APDU of the previous transmit() call.
+ /// </summary>
+ /// <returns>Byte array for the response APDU plus status words.</returns>
+ public byte[] GetTransmittedResponse()
+ {
+ byte[] respList;
+ IntPtr strAtr;
+ int len;
+ int ret = Interop.Smartcard.Channel.ChannelTransmitRetrieveResponse(_channelHandle, out strAtr, out len);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get trasmit retrieve response, Error - " + (SmartcardError)ret);
+ }
+
+ respList = new byte[len];
+ for (int i = 0; i < len; i++)
+ {
+ respList[i] = Marshal.ReadByte(strAtr);
+ strAtr += sizeof(byte);
+ }
+ return respList;
+ }
+
+ /// <summary>
+ /// Performs a selection of the next Applet on the given channel that matches to the partial Application ID(AID).
+ /// </summary>
+ /// <returns>True or false depending whether another applet with the partial Application ID(AID).</returns>
+ public bool SelectNext()
+ {
+ bool selectNext;
+ int ret = Interop.Smartcard.Channel.ChannelSelectNext(_channelHandle, out selectNext);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to select next, Error - " + (SmartcardError)ret);
+ }
+ return selectNext;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Network.Smartcard
+{
+ internal enum SmartcardError
+ {
+ None = ErrorCode.None,
+ IoError = ErrorCode.IoError,
+ InvalidParameterError = ErrorCode.InvalidParameter,
+ PermissionDeniedError = ErrorCode.PermissionDenied,
+ NotSupportedError = ErrorCode.NotSupported,
+ GeneralError = -0x01C70000 | 0x01,
+ NoSuchElementError = -0x01C70000 | 0x02,
+ IllegalStateError = -0x01C70000 | 0x03,
+ IllegalReferenceError = -0x01C70000 | 0x04,
+ OperationNotSupportError = -0x01C70000 | 0x05,
+ ChannelNotAvailableError = -0x01C70000 | 0x06,
+ NotInitializedError = -0x01C70000 | 0x07
+ }
+
+ internal static class SmartcardErrorFactory
+ {
+ static internal void ThrowSmartcardException(int e)
+ {
+ ThrowException(e, false);
+ }
+
+ static internal void ThrowSmartcardException(int e, int handle)
+ {
+ ThrowException(e, (handle < 0));
+ }
+
+ static private void ThrowException(int e, bool isHandleNull)
+ {
+ SmartcardError err = (SmartcardError)e;
+
+ if (isHandleNull)
+ {
+ throw new InvalidOperationException("Invalid instance (object may have been disposed or released)");
+ }
+
+ if (err == SmartcardError.InvalidParameterError)
+ {
+ throw new ArgumentException(err.ToString());
+ }
+ else
+ {
+ throw new InvalidOperationException(err.ToString());
+ }
+ }
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Tizen.Network.Smartcard
+{
+ /// <summary>
+ /// A class for Smartcard management. It allows applications to use Smartcard service.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/secureelement</privilege>
+ static public class SmartcardManager
+ {
+ /// <summary>
+ /// Gets the list of available Secure Element readers.
+ /// </summary>
+ /// <returns>List of SmartcardReader objects.</returns>
+ static public IEnumerable<SmartcardReader> GetReaders()
+ {
+ return SmartcardManagerImpl.Instance.GetReaders();
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+namespace Tizen.Network.Smartcard
+{
+ static internal class Globals
+ {
+ internal const string LogTag = "Tizen.Network.Smartcard";
+ }
+
+ internal class SmartcardManagerImpl : IDisposable
+ {
+ private static readonly SmartcardManagerImpl _instance = new SmartcardManagerImpl();
+ private List<SmartcardReader> _readerList = new List<SmartcardReader>();
+ private bool disposed = false;
+
+ internal static SmartcardManagerImpl Instance
+ {
+ get
+ {
+ return _instance;
+ }
+ }
+
+ private SmartcardManagerImpl()
+ {
+ initialize();
+ }
+
+ ~SmartcardManagerImpl()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposed)
+ return;
+
+ if (disposing)
+ {
+ // Free managed objects.
+ foreach (SmartcardReader reader in _readerList)
+ {
+ reader.Dispose();
+ _readerList.Remove(reader);
+ }
+ }
+ //Free unmanaged objects
+ deinitialize();
+ disposed = true;
+ }
+
+ private void initialize()
+ {
+ int ret = Interop.Smartcard.Initialize();
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to initialize smartcard, Error - " + (SmartcardError)ret);
+ SmartcardErrorFactory.ThrowSmartcardException(ret);
+ }
+ }
+
+ private void deinitialize()
+ {
+ int ret = Interop.Smartcard.Deinitialize();
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to deinitialize smartcard, Error - " + (SmartcardError)ret);
+ SmartcardErrorFactory.ThrowSmartcardException(ret);
+ }
+ }
+
+ internal IEnumerable<SmartcardReader> GetReaders()
+ {
+ IntPtr readerPtr;
+ int len = 0;
+
+ int ret = Interop.Smartcard.GetReaders(out readerPtr, out len);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to remove with AP, Error - " + (SmartcardError)ret);
+ SmartcardErrorFactory.ThrowSmartcardException(ret);
+ }
+
+ for (int i = 0; i < len; i++)
+ {
+ int readerID = Marshal.ReadInt32(readerPtr);
+
+ SmartcardReader readerItem = new SmartcardReader(readerID);
+ _readerList.Add(readerItem);
+ readerPtr += sizeof(int);
+ }
+
+ return _readerList;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+
+namespace Tizen.Network.Smartcard
+{
+ /// <summary>
+ /// A class for Smartcard reader informations. It allows applications to handle reader informations.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/secureelement</privilege>
+ public class SmartcardReader : IDisposable
+ {
+ private int _readerHandle = -1;
+ private int _session;
+ private bool disposed = false;
+ private List<SmartcardSession> _sessionList = new List<SmartcardSession>();
+
+ /// <summary>
+ /// The name of reader.
+ /// </summary>
+ public string Name
+ {
+ get
+ {
+ IntPtr strPtr;
+ int ret = Interop.Smartcard.Reader.ReaderGetName(_readerHandle, out strPtr);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get reader name, Error - " + (SmartcardError)ret);
+ return "";
+ }
+ return Marshal.PtrToStringAnsi(strPtr);
+ }
+ }
+
+ /// <summary>
+ /// The existence of secure element.
+ /// </summary>
+ public bool IsSecureElementPresent
+ {
+ get
+ {
+ bool isPresent;
+ int ret = Interop.Smartcard.Reader.ReaderIsSecureElementPresent(_readerHandle, out isPresent);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get present, Error - " + (SmartcardError)ret);
+ }
+ return isPresent;
+ }
+ }
+
+ internal SmartcardReader(int handle)
+ {
+ _readerHandle = handle;
+ }
+
+ ~SmartcardReader()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposed)
+ return;
+
+ if (disposing)
+ {
+ // Free managed objects.
+ foreach (SmartcardSession session in _sessionList)
+ {
+ session.Dispose();
+ _sessionList.Remove(session);
+ }
+ }
+ //Free unmanaged objects
+ disposed = true;
+ }
+
+ internal int GetHandle()
+ {
+ return _readerHandle;
+ }
+
+ internal int GetSession()
+ {
+ return _session;
+ }
+
+ /// <summary>
+ /// Connects to a Secure Element in the given reader.
+ /// </summary>
+ /// <returns>The SmartcardSession object.</returns>
+ public SmartcardSession OpenSession()
+ {
+ int ret = Interop.Smartcard.Reader.ReaderOpenSession(_readerHandle, out _session);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get session handle, Error - " + (SmartcardError)ret);
+ }
+
+ SmartcardSession session = new SmartcardSession(this, _session);
+ _sessionList.Add(session);
+ return session;
+ }
+
+ /// <summary>
+ /// Closes all the sessions opened on the given reader.
+ /// </summary>
+ public void CloseSessions()
+ {
+ int ret = Interop.Smartcard.Reader.ReaderCloseSessions(_readerHandle);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to close sessions, Error - " + (SmartcardError)ret);
+ SmartcardErrorFactory.ThrowSmartcardException(ret);
+ }
+
+ foreach (SmartcardSession session in _sessionList)
+ {
+ session.Dispose();
+ _sessionList.Remove(session);
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+
+namespace Tizen.Network.Smartcard
+{
+ /// <summary>
+ /// A class for Smartcard session informations. It allows applications to handle session informations.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/secureelement</privilege>
+ public class SmartcardSession : IDisposable
+ {
+ private int _sessionHandle = -1;
+ private bool disposed = false;
+ private List<SmartcardChannel> _basicChannelList = new List<SmartcardChannel>();
+ private List<SmartcardChannel> _logicalChannelList = new List<SmartcardChannel>();
+ private SmartcardReader _readerObject;
+ private int _basicChannel = 0;
+ private int _logicalChannel = 0;
+
+ /// <summary>
+ /// The reader object that provides the given session.
+ /// </summary>
+ public SmartcardReader Reader
+ {
+ get
+ {
+ int reader;
+ int ret = Interop.Smartcard.Session.SessionGetReader(_sessionHandle, out reader);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get reader, Error - " + (SmartcardError)ret);
+ }
+
+ if (_readerObject.GetHandle() != reader)
+ {
+ Log.Error(Globals.LogTag, "Does not correspond with reader, Error - " + _readerObject.GetHandle() + " " + reader);
+ }
+
+ return _readerObject;
+ }
+ }
+
+ /// <summary>
+ /// The Answer to Reset(ATR) of this Secure Element.
+ /// </summary>
+ public byte[] Atr
+ {
+ get
+ {
+ byte[] atrList;
+ IntPtr strAtr;
+ int len;
+ int ret = Interop.Smartcard.Session.SessionGetAtr(_sessionHandle, out strAtr, out len);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get atr, Error - " + (SmartcardError)ret);
+ }
+
+ atrList = new byte[len];
+ for (int i = 0; i < len; i++)
+ {
+ atrList[i] = Marshal.ReadByte(strAtr);
+ strAtr += sizeof(byte);
+ }
+ return atrList;
+ }
+ }
+
+ /// <summary>
+ /// Whether the session is closed.
+ /// </summary>
+ public bool IsClosed
+ {
+ get
+ {
+ bool isClosed;
+ int ret = Interop.Smartcard.Session.SessionIsClosed(_sessionHandle, out isClosed);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get present, Error - " + (SmartcardError)ret);
+ }
+ return isClosed;
+ }
+ }
+
+ internal SmartcardSession(SmartcardReader readerHandle, int sessionHandle)
+ {
+ _readerObject = readerHandle;
+ _sessionHandle = sessionHandle;
+ }
+
+ ~SmartcardSession()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposed)
+ return;
+
+ if (disposing)
+ {
+ // Free managed objects.
+ foreach (SmartcardChannel channel in _basicChannelList)
+ {
+ channel.Dispose();
+ _basicChannelList.Remove(channel);
+ }
+
+ foreach (SmartcardChannel channel in _logicalChannelList)
+ {
+ channel.Dispose();
+ _logicalChannelList.Remove(channel);
+ }
+ }
+ //Free unmanaged objects
+ disposed = true;
+ }
+
+ internal int GetHandle()
+ {
+ return _sessionHandle;
+ }
+
+ /// <summary>
+ /// Closes the connection with the Secure Element.
+ /// </summary>
+ public void Close()
+ {
+ int ret = Interop.Smartcard.Session.SessionClose(_sessionHandle);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to close, Error - " + (SmartcardError)ret);
+ SmartcardErrorFactory.ThrowSmartcardException(ret);
+ }
+ Dispose(true);
+ }
+
+ /// <summary>
+ /// Closes any channel opened on the given session.
+ /// </summary>
+ public void CloseChannels()
+ {
+ int ret = Interop.Smartcard.Session.SessionCloseChannels(_sessionHandle);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to close, Error - " + (SmartcardError)ret);
+ SmartcardErrorFactory.ThrowSmartcardException(ret);
+ }
+
+ foreach (SmartcardChannel channel in _basicChannelList)
+ {
+ channel.Dispose();
+ _basicChannelList.Remove(channel);
+ }
+
+ foreach (SmartcardChannel channel in _logicalChannelList)
+ {
+ channel.Dispose();
+ _logicalChannelList.Remove(channel);
+ }
+ }
+
+ /// <summary>
+ /// Gets an access to the basic channel, as defined in the ISO/IEC 7816-4 specification (the one that has number 0).
+ /// </summary>
+ /// <returns>The SmartcardChannel object for basic channel.</returns>
+ /// <param name="aid">Byte array containing the Application ID(AID) to be selected on the given channel.</param>
+ /// <param name="p2">P2 byte of the SELECT command if executed.</param>
+ public SmartcardChannel OpenBasicChannel(byte[] aid, byte p2)
+ {
+ int ret = Interop.Smartcard.Session.SessionOpenBasicChannel(_sessionHandle, aid, aid.Length, p2, out _basicChannel);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to open basic channel, Error - " + (SmartcardError)ret);
+ SmartcardErrorFactory.ThrowSmartcardException(ret);
+ }
+ SmartcardChannel basicChannel = new SmartcardChannel(this, _basicChannel);
+ _basicChannelList.Add(basicChannel);
+
+ return basicChannel;
+ }
+
+ /// <summary>
+ /// Open a logical channel with the Secure Element, selecting the Applet represented by the given Application ID(AID).
+ /// </summary>
+ /// <returns>The SmartcardChannel object for logical channel.</returns>
+ /// <param name="aid">Byte array containing the Application ID(AID) to be selected on the given channel.</param>
+ /// <param name="p2">P2 byte of the SELECT command if executed.</param>
+ public SmartcardChannel OpenLogicalChannel(byte[] aid, byte p2)
+ {
+ int ret = Interop.Smartcard.Session.SessionOpenLogicalChannel(_sessionHandle, aid, aid.Length, p2, out _logicalChannel);
+ if (ret != (int)SmartcardError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to open logical channel, Error - " + (SmartcardError)ret);
+ SmartcardErrorFactory.ThrowSmartcardException(ret);
+ }
+ SmartcardChannel logicalChannel = new SmartcardChannel(this, _logicalChannel);
+ _logicalChannelList.Add(logicalChannel);
+
+ return logicalChannel;
+ }
+ }
+}