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


Java ProviderException类代码示例

本文整理汇总了Java中java.security.ProviderException的典型用法代码示例。如果您正苦于以下问题:Java ProviderException类的具体用法?Java ProviderException怎么用?Java ProviderException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProviderException类属于java.security包,在下文中一共展示了ProviderException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOpSession

import java.security.ProviderException; //导入依赖的package包/类
Session getOpSession() throws PKCS11Exception {
    Session session = opSessions.poll();
    if (session != null) {
        return ensureValid(session);
    }
    // create a new session rather than re-using an obj session
    // that avoids potential expensive cancels() for Signatures & RSACipher
    if (maxSessions == Integer.MAX_VALUE ||
            activeSessions.get() < maxSessions) {
        session = openSession();
        return ensureValid(session);
    }
    session = objSessions.poll();
    if (session != null) {
        return ensureValid(session);
    }
    throw new ProviderException("Could not obtain session");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:SessionManager.java

示例2: openSession

import java.security.ProviderException; //导入依赖的package包/类
private Session openSession() throws PKCS11Exception {
    if ((maxSessions != Integer.MAX_VALUE) &&
            (activeSessions.get() >= maxSessions)) {
        throw new ProviderException("No more sessions available");
    }

    long id = token.p11.C_OpenSession
                (token.provider.slotID, openSessionFlags, null, null);
    Session session = new Session(token, id);
    activeSessions.incrementAndGet();
    if (debug != null) {
        synchronized(this) {
            if (activeSessions.get() > maxActiveSessions) {
                maxActiveSessions = activeSessions.get();
                if (maxActiveSessions % 10 == 0) {
                    System.out.println("Open sessions: " + maxActiveSessions);
                }
            }
        }
    }
    return session;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:SessionManager.java

示例3: openSession

import java.security.ProviderException; //导入依赖的package包/类
private Session openSession() throws PKCS11Exception {
    if ((maxSessions != Integer.MAX_VALUE) &&
            (activeSessions.get() >= maxSessions)) {
        throw new ProviderException("No more sessions available");
    }

    long id = token.p11.C_OpenSession
                (token.provider.slotID, openSessionFlags, null, null);
    Session session = new Session(token, id);
    activeSessions.incrementAndGet();
    if (debug != null) {
        synchronized(maxActiveSessionsLock) {
            if (activeSessions.get() > maxActiveSessions) {
                maxActiveSessions = activeSessions.get();
                if (maxActiveSessions % 10 == 0) {
                    System.out.println("Open sessions: " + maxActiveSessions);
                }
            }
        }
    }
    return session;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:SessionManager.java

示例4: encrypt

import java.security.ProviderException; //导入依赖的package包/类
/**
 * Performs encryption operation.
 *
 * <p>The input plain text <code>plain</code>, starting at
 * <code>plainOffset</code> and ending at
 * <code>(plainOffset + plainLen - 1)</code>, is encrypted.
 * The result is stored in <code>cipher</code>, starting at
 * <code>cipherOffset</code>.
 *
 * @param plain the buffer with the input data to be encrypted
 * @param plainOffset the offset in <code>plain</code>
 * @param plainLen the length of the input data
 * @param cipher the buffer for the result
 * @param cipherOffset the offset in <code>cipher</code>
 * @exception ProviderException if <code>plainLen</code> is not
 * a multiple of the <code>numBytes</code>
 * @return the length of the encrypted data
 */
int encrypt(byte[] plain, int plainOffset, int plainLen,
            byte[] cipher, int cipherOffset) {

    if ((plainLen % numBytes) != 0) {
        throw new ProviderException("Internal error in input buffering");
    }
    int nShift = blockSize - numBytes;
    int loopCount = plainLen / numBytes;

    for (; loopCount > 0;
         plainOffset += numBytes, cipherOffset += numBytes,
         loopCount--) {
        embeddedCipher.encryptBlock(register, 0, k, 0);
        for (int i = 0; i < numBytes; i++) {
            cipher[i + cipherOffset] =
                (byte)(k[i] ^ plain[i + plainOffset]);
        }
        if (nShift != 0) {
            System.arraycopy(register, numBytes, register, 0, nShift);
        }
        System.arraycopy(k, 0, register, nShift, numBytes);
    }
    return plainLen;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:43,代码来源:OutputFeedback.java

示例5: encrypt

import java.security.ProviderException; //导入依赖的package包/类
/**
 * Performs encryption operation.
 *
 * <p>The input plain text <code>plain</code>, starting at
 * <code>plainOffset</code> and ending at
 * <code>(plainOffset + plainLen - 1)</code>, is encrypted.
 * The result is stored in <code>cipher</code>, starting at
 * <code>cipherOffset</code>.
 *
 * @param plain the buffer with the input data to be encrypted
 * @param plainOffset the offset in <code>plain</code>
 * @param plainLen the length of the input data
 * @param cipher the buffer for the result
 * @param cipherOffset the offset in <code>cipher</code>
 * @exception ProviderException if <code>plainLen</code> is not
 * a multiple of the block size
 * @return the length of the encrypted data
 */
int encrypt(byte[] plain, int plainOffset, int plainLen,
            byte[] cipher, int cipherOffset)
{
    if ((plainLen % blockSize) != 0) {
        throw new ProviderException("Internal error in input buffering");
    }
    int i;
    int endIndex = plainOffset + plainLen;

    for (; plainOffset < endIndex;
         plainOffset += blockSize, cipherOffset += blockSize) {
        for (i = 0; i < blockSize; i++) {
            k[i] ^= plain[i + plainOffset];
        }
        embeddedCipher.encryptBlock(k, 0, cipher, cipherOffset);
        for (i = 0; i < blockSize; i++) {
            k[i] = (byte)(plain[i + plainOffset] ^ cipher[i + cipherOffset]);
        }
    }
    return plainLen;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:40,代码来源:PCBC.java

示例6: decrypt

import java.security.ProviderException; //导入依赖的package包/类
/**
 * Performs decryption operation.
 *
 * <p>The input cipher text <code>cipher</code>, starting at
 * <code>cipherOffset</code> and ending at
 * <code>(cipherOffset + cipherLen - 1)</code>, is decrypted.
 * The result is stored in <code>plain</code>, starting at
 * <code>plainOffset</code>.
 *
 * @param cipher the buffer with the input data to be decrypted
 * @param cipherOffset the offset in <code>cipherOffset</code>
 * @param cipherLen the length of the input data
 * @param plain the buffer for the result
 * @param plainOffset the offset in <code>plain</code>
 * @exception ProviderException if <code>cipherLen</code> is not
 * a multiple of the block size
 * @return the length of the decrypted data
 */
int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
            byte[] plain, int plainOffset)
{
    if ((cipherLen % blockSize) != 0) {
         throw new ProviderException("Internal error in input buffering");
    }
    int i;
    int endIndex = cipherOffset + cipherLen;

    for (; cipherOffset < endIndex;
         plainOffset += blockSize, cipherOffset += blockSize) {
        embeddedCipher.decryptBlock(cipher, cipherOffset,
                               plain, plainOffset);
        for (i = 0; i < blockSize; i++) {
            plain[i + plainOffset] ^= k[i];
        }
        for (i = 0; i < blockSize; i++) {
            k[i] = (byte)(plain[i + plainOffset] ^ cipher[i + cipherOffset]);
        }
    }
    return cipherLen;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:41,代码来源:PCBC.java

示例7: encrypt

import java.security.ProviderException; //导入依赖的package包/类
/**
 * Performs encryption operation.
 *
 * <p>The input plain text <code>plain</code>, starting at
 * <code>plainOffset</code> and ending at
 * <code>(plainOffset + plainLen - 1)</code>, is encrypted.
 * The result is stored in <code>cipher</code>, starting at
 * <code>cipherOffset</code>.
 *
 * @param plain the buffer with the input data to be encrypted
 * @param plainOffset the offset in <code>plain</code>
 * @param plainLen the length of the input data
 * @param cipher the buffer for the result
 * @param cipherOffset the offset in <code>cipher</code>
 * @exception ProviderException if <code>plainLen</code> is not
 * a multiple of the <code>numBytes</code>
 * @return the length of the encrypted data
 */
int encrypt(byte[] plain, int plainOffset, int plainLen,
            byte[] cipher, int cipherOffset) {
    if ((plainLen % numBytes) != 0) {
        throw new ProviderException("Internal error in input buffering");
    }

    int nShift = blockSize - numBytes;
    int loopCount = plainLen / numBytes;

    for (; loopCount > 0 ;
         plainOffset += numBytes, cipherOffset += numBytes,
         loopCount--) {
        embeddedCipher.encryptBlock(register, 0, k, 0);
        if (nShift != 0) {
            System.arraycopy(register, numBytes, register, 0, nShift);
        }
        for (int i = 0; i < numBytes; i++) {
            register[nShift + i] = cipher[i + cipherOffset] =
                    (byte)(k[i] ^ plain[i + plainOffset]);
        }
    }
    return plainLen;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:42,代码来源:CipherFeedback.java

示例8: decrypt

import java.security.ProviderException; //导入依赖的package包/类
/**
 * Performs decryption operation.
 *
 * <p>The input cipher text <code>cipher</code>, starting at
 * <code>cipherOffset</code> and ending at
 * <code>(cipherOffset + cipherLen - 1)</code>, is decrypted.
 * The result is stored in <code>plain</code>, starting at
 * <code>plainOffset</code>.
 *
 * @param cipher the buffer with the input data to be decrypted
 * @param cipherOffset the offset in <code>cipherOffset</code>
 * @param cipherLen the length of the input data
 * @param plain the buffer for the result
 * @param plainOffset the offset in <code>plain</code>
 * @exception ProviderException if <code>cipherLen</code> is not
 * a multiple of the <code>numBytes</code>
 * @return the length of the decrypted data
 */
int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
            byte[] plain, int plainOffset) {
    if ((cipherLen % numBytes) != 0) {
        throw new ProviderException("Internal error in input buffering");
    }

    int nShift = blockSize - numBytes;
    int loopCount = cipherLen / numBytes;

    for (; loopCount > 0;
         plainOffset += numBytes, cipherOffset += numBytes,
         loopCount--) {
        embeddedCipher.encryptBlock(register, 0, k, 0);
        if (nShift != 0) {
            System.arraycopy(register, numBytes, register, 0, nShift);
        }
        for (int i = 0; i < numBytes; i++) {
            register[i + nShift] = cipher[i + cipherOffset];
            plain[i + plainOffset]
                = (byte)(cipher[i + cipherOffset] ^ k[i]);
        }
    }
    return cipherLen;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:43,代码来源:CipherFeedback.java

示例9: encrypt

import java.security.ProviderException; //导入依赖的package包/类
/**
 * Performs encryption operation.
 *
 * <p>The input plain text <code>plain</code>, starting at
 * <code>plainOffset</code> and ending at
 * <code>(plainOffset + plainLen - 1)</code>, is encrypted.
 * The result is stored in <code>cipher</code>, starting at
 * <code>cipherOffset</code>.
 *
 * @param plain the buffer with the input data to be encrypted
 * @param plainOffset the offset in <code>plain</code>
 * @param plainLen the length of the input data
 * @param cipher the buffer for the result
 * @param cipherOffset the offset in <code>cipher</code>
 * @exception ProviderException if <code>len</code> is not
 * a multiple of the block size
 * @return the length of the encrypted data
 */
int encrypt(byte[] plain, int plainOffset, int plainLen,
            byte[] cipher, int cipherOffset)
{
    if ((plainLen % blockSize) != 0) {
        throw new ProviderException("Internal error in input buffering");
    }
    int endIndex = plainOffset + plainLen;

    for (; plainOffset < endIndex;
         plainOffset+=blockSize, cipherOffset += blockSize) {
        for (int i = 0; i < blockSize; i++) {
            k[i] = (byte)(plain[i + plainOffset] ^ r[i]);
        }
        embeddedCipher.encryptBlock(k, 0, cipher, cipherOffset);
        System.arraycopy(cipher, cipherOffset, r, 0, blockSize);
    }
    return plainLen;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:CipherBlockChaining.java

示例10: test

import java.security.ProviderException; //导入依赖的package包/类
static void test(String algo, Provider provider, boolean priv,
        Consumer<Key> method) throws Exception {
    KeyPairGenerator generator;
    try {
        generator = KeyPairGenerator.getInstance(algo, provider);
    } catch (NoSuchAlgorithmException nsae) {
        return;
    }

    System.out.println("Checking " + provider.getName() + ", " + algo);

    KeyPair pair = generator.generateKeyPair();
    Key key = priv ? pair.getPrivate() : pair.getPublic();

    pair = null;
    for (int i = 0; i < 32; ++i) {
        System.gc();
    }

    try {
        method.accept(key);
    } catch (ProviderException pe) {
        failures++;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:FinalizeHalf.java

示例11: newInstance

import java.security.ProviderException; //导入依赖的package包/类
@Override
public Object newInstance(Object ctrParamObj)
    throws NoSuchAlgorithmException {
    String type = getType();
    if (ctrParamObj != null) {
        throw new InvalidParameterException
            ("constructorParameter not used with " + type +
             " engines");
    }
    String algo = getAlgorithm();
    try {
        if (type.equals("GssApiMechanism")) {
            if (algo.equals("1.2.840.113554.1.2.2")) {
                return new Krb5MechFactory();
            } else if (algo.equals("1.3.6.1.5.5.2")) {
                return new SpNegoMechFactory();
            }
        }
    } catch (Exception ex) {
        throw new NoSuchAlgorithmException
            ("Error constructing " + type + " for " +
            algo + " using SunJGSS", ex);
    }
    throw new ProviderException("No impl for " + algo +
        " " + type);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:SunProvider.java

示例12: newInstance

import java.security.ProviderException; //导入依赖的package包/类
@Override
public Object newInstance(Object ctrParamObj)
    throws NoSuchAlgorithmException {
    String type = getType();
    if (ctrParamObj != null) {
        throw new InvalidParameterException
            ("constructorParameter not used with " + type + " engines");
    }
    String algo = getAlgorithm();
    // GSSAPI uses same impl class for client and server
    try {
        if (algo.equals("GSSAPI")) {
            return new com.sun.security.sasl.gsskerb.FactoryImpl();
        }
    } catch (Exception ex) {
        throw new NoSuchAlgorithmException("Error constructing " +
             type + " for " + algo + " using JdkSASL", ex);
    }
    throw new ProviderException("No impl for " + algo +
        " " + type);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:JdkSASL.java

示例13: engineGetKey

import java.security.ProviderException; //导入依赖的package包/类
/** {@inheritDoc} */
  @Override
  public Key engineGetKey(final String alias, final char[] password) {
  	if (!engineContainsAlias(alias)) {
  		return null;
  	}

  	// No permitimos PIN nulo, si llega nulo pedimos por dialogo grafico
  	if (password != null) {
  		this.cryptoCard.setPasswordCallback(
		new CachePasswordCallback(password)
	);
  	}
      final PrivateKeyReference pkRef = this.cryptoCard.getPrivateKey(alias);
if (!(pkRef instanceof CeresPrivateKeyReference)) {
	throw new ProviderException("La clave obtenida de la tarjeta no es del tipo esperado, se ha obtenido: " + pkRef.getClass().getName()); //$NON-NLS-1$
}
return new CeresPrivateKey(
	(CeresPrivateKeyReference) pkRef,
	this.cryptoCard,
	((RSAPublicKey)engineGetCertificate(alias).getPublicKey()).getModulus()
);
  }
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:24,代码来源:CeresKeyStoreImpl.java

示例14: engineGetKey

import java.security.ProviderException; //导入依赖的package包/类
/** {@inheritDoc} */
  @Override
  public Key engineGetKey(final String alias, final char[] password) {
  	if (!engineContainsAlias(alias)) {
  		return null;
  	}
  	if (password != null) {
  		// Establecemos el PasswordCallback
  		final PasswordCallback pwc = new CachePasswordCallback(password);
  		this.cryptoCard.setPasswordCallback(pwc);
  	}
      final PrivateKeyReference pkRef = this.cryptoCard.getPrivateKey(alias);
if (!(pkRef instanceof DniePrivateKeyReference)) {
	throw new ProviderException(
		"La clave obtenida de la tarjeta no es del tipo esperado, se ha obtenido: " + pkRef.getClass().getName() //$NON-NLS-1$
	);
}
return new DniePrivateKey((DniePrivateKeyReference) pkRef);
  }
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:20,代码来源:DnieKeyStoreImpl.java

示例15: encrypt

import java.security.ProviderException; //导入依赖的package包/类
/**
 * Performs encryption operation.
 *
 * <p>The input plain text <code>plain</code>, starting at
 * <code>plainOffset</code> and ending at
 * <code>(plainOffset + plainLen - 1)</code>, is encrypted.
 * The result is stored in <code>cipher</code>, starting at
 * <code>cipherOffset</code>.
 *
 * @param plain the buffer with the input data to be encrypted
 * @param plainOffset the offset in <code>plain</code>
 * @param plainLen the length of the input data
 * @param cipher the buffer for the result
 * @param cipherOffset the offset in <code>cipher</code>
 * @exception ProviderException if <code>plainLen</code> is not
 * a multiple of the <code>numBytes</code>
 * @return the length of the encrypted data
 */
int encrypt(byte[] plain, int plainOffset, int plainLen,
            byte[] cipher, int cipherOffset) {

    if ((plainLen % numBytes) != 0) {
        throw new ProviderException("Internal error in input buffering");
    }
    int nShift = blockSize - numBytes;
    int loopCount = plainLen / numBytes;

    for (; loopCount > 0;
         plainOffset += numBytes, cipherOffset += numBytes,
         loopCount--) {
        embeddedCipher.encryptBlock(register, 0, k, 0);
        for (int i = 0; i < numBytes; i++) {
            cipher[i + cipherOffset] =
                (byte)(k[i] ^ plain[i + plainOffset]);
            if (nShift != 0) {
                System.arraycopy(register, numBytes, register, 0, nShift);
            }
            System.arraycopy(k, 0, register, nShift, numBytes);
        }
    }
    return plainLen;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:43,代码来源:OutputFeedback.java


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