-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add copy of UsbInterface copy to Management for legacy.
- Loading branch information
1 parent
70452f3
commit 7fdce77
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
management/src/main/java/com/yubico/yubikit/management/UsbInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (C) 2022 Yubico. | ||
* | ||
* 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. | ||
*/ | ||
package com.yubico.yubikit.management; | ||
|
||
/** | ||
* Provides constants for the different YubiKey USB interfaces, and the Mode enum for combinations of enabled interfaces. | ||
* @deprecated This class has been moved to the core module, and will remain here only until YubiKit 3.0 is released. | ||
*/ | ||
@Deprecated | ||
public final class UsbInterface { | ||
@Deprecated | ||
public static final int OTP = 0x01; | ||
@Deprecated | ||
public static final int FIDO = 0x02; | ||
@Deprecated | ||
public static final int CCID = 0x04; | ||
|
||
private UsbInterface() { | ||
} | ||
|
||
/** | ||
* Used for configuring USB Mode for YubiKey 3 and 4. | ||
* <p> | ||
* This is replaced by DeviceConfig starting with YubiKey 5. | ||
*/ | ||
@Deprecated | ||
public enum Mode { | ||
OTP((byte) 0x00, UsbInterface.OTP), | ||
CCID((byte) 0x01, UsbInterface.CCID), | ||
OTP_CCID((byte) 0x02, UsbInterface.OTP | UsbInterface.CCID), | ||
FIDO((byte) 0x03, UsbInterface.FIDO), | ||
OTP_FIDO((byte) 0x04, UsbInterface.OTP | UsbInterface.FIDO), | ||
FIDO_CCID((byte) 0x05, UsbInterface.FIDO | UsbInterface.CCID), | ||
OTP_FIDO_CCID((byte) 0x06, UsbInterface.OTP | UsbInterface.FIDO | UsbInterface.CCID); | ||
|
||
@Deprecated | ||
public final byte value; | ||
@Deprecated | ||
public final int interfaces; | ||
|
||
Mode(byte value, int interfaces) { | ||
this.value = value; | ||
this.interfaces = interfaces; | ||
} | ||
|
||
/** | ||
* Returns the USB Mode given the enabled USB interfaces it has. | ||
*/ | ||
@Deprecated | ||
public static Mode getMode(int interfaces) { | ||
for (Mode mode : Mode.values()) { | ||
if (mode.interfaces == interfaces) { | ||
return mode; | ||
} | ||
} | ||
throw new IllegalArgumentException("Invalid interfaces for Mode"); | ||
} | ||
} | ||
} |