Search in sources :

Example 16 with TokenException

use of iaik.pkcs.pkcs11.TokenException in project xipki by xipki.

the class IaikP11Slot method firstLogin.

private void firstLogin(Session session, List<char[]> password) throws P11TokenException {
    try {
        boolean isProtectedAuthenticationPath = session.getToken().getTokenInfo().isProtectedAuthenticationPath();
        if (isProtectedAuthenticationPath || CollectionUtil.isEmpty(password)) {
            LOG.info("verify on PKCS11Module with PROTECTED_AUTHENTICATION_PATH");
            singleLogin(session, null);
        } else {
            LOG.info("verify on PKCS11Module with PIN");
            for (char[] singlePwd : password) {
                singleLogin(session, singlePwd);
            }
            this.password = password;
        }
    } catch (PKCS11Exception ex) {
        // 0x100: user already logged in
        if (ex.getErrorCode() != 0x100) {
            throw new P11TokenException(ex.getMessage(), ex);
        }
    } catch (TokenException ex) {
        throw new P11TokenException(ex.getMessage(), ex);
    }
}
Also used : PKCS11Exception(iaik.pkcs.pkcs11.wrapper.PKCS11Exception) P11TokenException(org.xipki.security.exception.P11TokenException) P11TokenException(org.xipki.security.exception.P11TokenException) TokenException(iaik.pkcs.pkcs11.TokenException)

Aggregations

TokenException (iaik.pkcs.pkcs11.TokenException)16 P11TokenException (org.xipki.security.exception.P11TokenException)16 Session (iaik.pkcs.pkcs11.Session)10 SecretKey (iaik.pkcs.pkcs11.objects.SecretKey)9 ValuedSecretKey (iaik.pkcs.pkcs11.objects.ValuedSecretKey)9 DSAPrivateKey (iaik.pkcs.pkcs11.objects.DSAPrivateKey)8 ECPrivateKey (iaik.pkcs.pkcs11.objects.ECPrivateKey)8 PrivateKey (iaik.pkcs.pkcs11.objects.PrivateKey)8 RSAPrivateKey (iaik.pkcs.pkcs11.objects.RSAPrivateKey)8 SM2PrivateKey (iaik.pkcs.pkcs11.objects.SM2PrivateKey)8 DSAPublicKey (iaik.pkcs.pkcs11.objects.DSAPublicKey)6 ECPublicKey (iaik.pkcs.pkcs11.objects.ECPublicKey)6 PublicKey (iaik.pkcs.pkcs11.objects.PublicKey)6 RSAPublicKey (iaik.pkcs.pkcs11.objects.RSAPublicKey)6 SM2PublicKey (iaik.pkcs.pkcs11.objects.SM2PublicKey)6 X509PublicKeyCertificate (iaik.pkcs.pkcs11.objects.X509PublicKeyCertificate)6 Key (iaik.pkcs.pkcs11.objects.Key)5 Mechanism (iaik.pkcs.pkcs11.Mechanism)4 P11ObjectIdentifier (org.xipki.security.pkcs11.P11ObjectIdentifier)4 DEROctetString (org.bouncycastle.asn1.DEROctetString)3