當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。