本文整理匯總了Java中java.security.KeyStore.CallbackHandlerProtection方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyStore.CallbackHandlerProtection方法的具體用法?Java KeyStore.CallbackHandlerProtection怎麽用?Java KeyStore.CallbackHandlerProtection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.security.KeyStore
的用法示例。
在下文中一共展示了KeyStore.CallbackHandlerProtection方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: engineLoad
import java.security.KeyStore; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public void engineLoad(final KeyStore.LoadStoreParameter param) throws IOException {
if (param != null) {
final ProtectionParameter pp = param.getProtectionParameter();
if (pp instanceof KeyStore.CallbackHandlerProtection) {
if (((KeyStore.CallbackHandlerProtection) pp).getCallbackHandler() == null) {
throw new IllegalArgumentException("El CallbackHandler no puede ser nulo"); //$NON-NLS-1$
}
this.cryptoCard = new Ceres(
CeresProvider.getDefaultApduConnection(),
new JseCryptoHelper()
);
this.cryptoCard.setCallbackHandler(((KeyStore.CallbackHandlerProtection) pp).getCallbackHandler());
}
else if (pp instanceof KeyStore.PasswordProtection) {
final PasswordCallback pwc = new CeresPasswordCallback((PasswordProtection) pp);
this.cryptoCard = new Ceres(
CeresProvider.getDefaultApduConnection(),
new JseCryptoHelper()
);
this.cryptoCard.setPasswordCallback(pwc);
}
else {
Logger.getLogger("es.gob.jmulticard").warning( //$NON-NLS-1$
"Se ha proporcionado un LoadStoreParameter de tipo no soportado, se ignorara: " + (pp != null ? pp.getClass().getName() : "NULO") //$NON-NLS-1$ //$NON-NLS-2$
);
}
}
else {
this.cryptoCard = new Ceres(
CeresProvider.getDefaultApduConnection(),
new JseCryptoHelper()
);
}
userCertAliases = Arrays.asList(this.cryptoCard.getAliases());
}
示例2: engineGetEntry
import java.security.KeyStore; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public KeyStore.Entry engineGetEntry(final String alias,
final ProtectionParameter protParam) {
if(protParam instanceof KeyStore.CallbackHandlerProtection) {
// Establecemos el CallbackHandler
final CallbackHandler chp = ((KeyStore.CallbackHandlerProtection) protParam).getCallbackHandler();
if(chp != null) {
this.cryptoCard.setCallbackHandler(chp);
}
}
else if (protParam instanceof KeyStore.PasswordProtection) {
// Establecemos el PasswordCallback
final PasswordCallback pwc = new CachePasswordCallback(((KeyStore.PasswordProtection)protParam).getPassword());
this.cryptoCard.setPasswordCallback(pwc);
}
else {
LOGGER.warning(
"Se ha proporcionado un ProtectionParameter de tipo no soportado, se ignorara: " + (protParam != null ? protParam.getClass().getName() : "NULO") //$NON-NLS-1$ //$NON-NLS-2$
);
}
if (!engineContainsAlias(alias)) {
return null;
}
final PrivateKey key = (PrivateKey) engineGetKey(
alias,
null // Le pasamos null porque ya hemos establecido el PasswordCallback o el CallbackHander antes
);
return new PrivateKeyEntry(key, engineGetCertificateChain(alias));
}
示例3: engineLoad
import java.security.KeyStore; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public void engineLoad(final KeyStore.LoadStoreParameter param) throws IOException {
if (param != null) {
final ProtectionParameter pp = param.getProtectionParameter();
if (pp instanceof KeyStore.CallbackHandlerProtection) {
if (((KeyStore.CallbackHandlerProtection) pp).getCallbackHandler() == null) {
throw new IllegalArgumentException("El CallbackHandler no puede ser nulo"); //$NON-NLS-1$
}
this.cryptoCard = DnieFactory.getDnie(
DnieProvider.getDefaultApduConnection(),
null,
new JseCryptoHelper(),
((KeyStore.CallbackHandlerProtection) pp).getCallbackHandler()
);
}
else if (pp instanceof KeyStore.PasswordProtection) {
final PasswordCallback pwc = new DniePasswordCallback((PasswordProtection) pp);
this.cryptoCard = DnieFactory.getDnie(
DnieProvider.getDefaultApduConnection(),
pwc,
new JseCryptoHelper(),
null
);
}
else {
LOGGER.warning(
"Se ha proporcionado un LoadStoreParameter de tipo no soportado, se ignorara: " + (pp != null ? pp.getClass().getName() : "NULO") //$NON-NLS-1$ //$NON-NLS-2$
);
}
}
else {
this.cryptoCard = DnieFactory.getDnie(
DnieProvider.getDefaultApduConnection(),
null,
new JseCryptoHelper(),
null
);
}
this.aliases = Arrays.asList(this.cryptoCard.getAliases());
}