当前位置: 首页>>代码示例>>Java>>正文


Java KeyStore.CallbackHandlerProtection方法代码示例

本文整理汇总了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());
 }
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:39,代码来源:CeresKeyStoreImpl.java

示例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));
  }
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:32,代码来源:DnieKeyStoreImpl.java

示例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());
 }
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:43,代码来源:DnieKeyStoreImpl.java


注:本文中的java.security.KeyStore.CallbackHandlerProtection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。