本文整理汇总了Java中iaik.pkcs.pkcs11.TokenException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java TokenException.getMessage方法的具体用法?Java TokenException.getMessage怎么用?Java TokenException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iaik.pkcs.pkcs11.TokenException
的用法示例。
在下文中一共展示了TokenException.getMessage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkSessionLoggedIn
import iaik.pkcs.pkcs11.TokenException; //导入方法依赖的package包/类
private static boolean checkSessionLoggedIn(Session session) throws P11TokenException {
SessionInfo info;
try {
info = session.getSessionInfo();
} catch (TokenException ex) {
throw new P11TokenException(ex.getMessage(), ex);
}
if (LOG.isTraceEnabled()) {
LOG.debug("SessionInfo: {}", info);
}
State state = info.getState();
long deviceError = info.getDeviceError();
LOG.debug("to be verified PKCS11Module: state = {}, deviceError: {}", state, deviceError);
boolean isRwSessionLoggedIn = state.equals(State.RW_USER_FUNCTIONS);
boolean isRoSessionLoggedIn = state.equals(State.RO_USER_FUNCTIONS);
boolean sessionLoggedIn = ((isRoSessionLoggedIn || isRwSessionLoggedIn)
&& deviceError == 0);
LOG.debug("sessionLoggedIn: {}", sessionLoggedIn);
return sessionLoggedIn;
}
示例2: removeCerts0
import iaik.pkcs.pkcs11.TokenException; //导入方法依赖的package包/类
@Override
protected void removeCerts0(P11ObjectIdentifier objectId) throws P11TokenException {
X509PublicKeyCertificate[] existingCerts = getCertificateObjects(objectId.id(),
objectId.labelChars());
if (existingCerts == null || existingCerts.length == 0) {
LOG.warn("could not find certificates " + objectId);
return;
}
Session session = borrowWritableSession();
try {
for (X509PublicKeyCertificate cert : existingCerts) {
session.destroyObject(cert);
}
} catch (TokenException ex) {
throw new P11TokenException(ex.getMessage(), ex);
} finally {
returnWritableSession(session);
}
}
示例3: idExists
import iaik.pkcs.pkcs11.TokenException; //导入方法依赖的package包/类
private static boolean idExists(Session session, byte[] keyId) throws P11TokenException {
Key key = new Key();
key.getId().setByteArrayValue(keyId);
Object[] objects;
try {
session.findObjectsInit(key);
objects = session.findObjects(1);
session.findObjectsFinal();
if (objects.length > 0) {
return true;
}
X509PublicKeyCertificate cert = new X509PublicKeyCertificate();
cert.getId().setByteArrayValue(keyId);
session.findObjectsInit(cert);
objects = session.findObjects(1);
session.findObjectsFinal();
} catch (TokenException ex) {
throw new P11TokenException(ex.getMessage(), ex);
}
return objects.length > 0;
}
示例4: labelExists
import iaik.pkcs.pkcs11.TokenException; //导入方法依赖的package包/类
private static boolean labelExists(Session session, String keyLabel) throws P11TokenException {
ParamUtil.requireNonBlank("keyLabel", keyLabel);
Key key = new Key();
key.getLabel().setCharArrayValue(keyLabel.toCharArray());
Object[] objects;
try {
session.findObjectsInit(key);
objects = session.findObjects(1);
session.findObjectsFinal();
if (objects.length > 0) {
return true;
}
X509PublicKeyCertificate cert = new X509PublicKeyCertificate();
cert.getLabel().setCharArrayValue(keyLabel.toCharArray());
session.findObjectsInit(cert);
objects = session.findObjects(1);
session.findObjectsFinal();
} catch (TokenException ex) {
throw new P11TokenException(ex.getMessage(), ex);
}
return objects.length > 0;
}
示例5: singleSign
import iaik.pkcs.pkcs11.TokenException; //导入方法依赖的package包/类
private byte[] singleSign(long mechanism, P11Params parameters, byte[] content,
IaikP11Identity identity) throws P11TokenException {
Key signingKey = identity.signingKey();
Mechanism mechanismObj = getMechanism(mechanism, parameters);
if (LOG.isTraceEnabled()) {
LOG.debug("sign with signing key:\n{}", signingKey);
}
ConcurrentBagEntry<Session> session0 = borrowSession();
if (session0 == null) {
throw new P11TokenException("no idle session available");
}
byte[] signature;
try {
Session session = session0.value();
synchronized (session) {
session.signInit(mechanismObj, signingKey);
signature = session.sign(content);
}
} catch (TokenException ex) {
throw new P11TokenException(ex.getMessage(), ex);
} finally {
sessions.requite(session0);
}
if (LOG.isDebugEnabled()) {
LOG.debug("signature:\n{}", Hex.toHexString(signature));
}
return signature;
}
示例6: openSession
import iaik.pkcs.pkcs11.TokenException; //导入方法依赖的package包/类
private Session openSession(boolean rwSession) throws P11TokenException {
Session session;
try {
session = slot.getToken().openSession(Token.SessionType.SERIAL_SESSION, rwSession, null,
null);
} catch (TokenException ex) {
throw new P11TokenException(ex.getMessage(), ex);
}
countSessions.incrementAndGet();
return session;
}
示例7: singleLogin
import iaik.pkcs.pkcs11.TokenException; //导入方法依赖的package包/类
private void singleLogin(Session session, char[] pin) throws P11TokenException {
char[] tmpPin = pin;
// some driver does not accept null PIN
if (pin == null) {
tmpPin = new char[]{};
}
try {
session.login(userType, tmpPin);
} catch (TokenException ex) {
throw new P11TokenException(ex.getMessage(), ex);
}
}
示例8: removeObjects
import iaik.pkcs.pkcs11.TokenException; //导入方法依赖的package包/类
private int removeObjects(Storage template, String desc) throws P11TokenException {
Session session = borrowWritableSession();
try {
List<Storage> objects = getObjects(session, template);
for (Storage obj : objects) {
session.destroyObject(obj);
}
return objects.size();
} catch (TokenException ex) {
LogUtil.error(LOG, ex, "could not remove " + desc);
throw new P11TokenException(ex.getMessage(), ex);
} finally {
returnWritableSession(session);
}
}
示例9: addCert0
import iaik.pkcs.pkcs11.TokenException; //导入方法依赖的package包/类
@Override
protected void addCert0(P11ObjectIdentifier objectId, X509Certificate cert)
throws P11TokenException {
X509PublicKeyCertificate newCaCertTemp = createPkcs11Template(
new X509Cert(cert), objectId.id(), objectId.labelChars());
Session session = borrowWritableSession();
try {
session.createObject(newCaCertTemp);
} catch (TokenException ex) {
throw new P11TokenException(ex.getMessage(), ex);
} finally {
returnWritableSession(session);
}
}