Package java.security

Examples of java.security.PrivateKey


     {
       BigInteger D = new BigInteger(input);
      
       KeySpec keyspec = new ECPrivateKeySpec(D,(ECParameterSpec)ECCparam);
      
       PrivateKey privkey = null;
      
       try{
         privkey = KeyFactory.getInstance("ECDSA","BC").generatePrivate(keyspec);
        
         return privkey;
View Full Code Here


    byte[]    data,
    String    reason )
 
    throws CryptoManagerException
  {
    PrivateKey  priv = getMyPrivateKey( reason );
   
    Signature sig = CryptoECCUtils.getSignature( priv );
   
    try{
      sig.update( data );
View Full Code Here

     * @return Alias name for the desired key
     */
    public String chooseServerAlias(String keyType, Principal[] issuers,
            Socket socket) {
        if (serverKeyAlias != null) {
            PrivateKey key = delegate.getPrivateKey(serverKeyAlias);
            if (key != null) {
                if (key.getAlgorithm().equals(keyType)) {
                    return serverKeyAlias;
                } else {
                    return null;
                }
            } else {
View Full Code Here

     * @return Alias name for the desired key
     */
    public String chooseServerAlias(String keyType, Principal[] issuers,
            Socket socket) {
        if (serverKeyAlias != null) {
            PrivateKey key = delegate.getPrivateKey(serverKeyAlias);
            if (key != null) {
                if (key.getAlgorithm().equals(keyType)) {
                    return serverKeyAlias;
                } else {
                    return null;
                }
            } else {
View Full Code Here

    @Override
    public String chooseEngineServerAlias(String keyType, Principal[] issuers,
            SSLEngine engine) {

        if (serverKeyAlias != null) {
            PrivateKey key = delegate.getPrivateKey(serverKeyAlias);
            if (key != null) {
                if (key.getAlgorithm().equals(keyType)) {
                    return serverKeyAlias;
                } else {
                    return null;
                }
            } else {
View Full Code Here

        String ksp = System.getProperty("ch.ethz.prose.keystore.password");
        String alias = "runes-system"; // FIX

        KeyStore ks = KeyStore.getInstance("JKS");
        ks.load(new FileInputStream(ksl), ksp.toCharArray());
        PrivateKey privateKey = (PrivateKey) ks.getKey(alias, alias.toCharArray()); // FIX, password
        PublicKey publicKey = ks.getCertificate(alias).getPublicKey();
        keyPair = new KeyPair(publicKey, privateKey);
      }

      return new SignedAspect(ext, keyPair);
View Full Code Here

   {
      DKIMSignature signature = new DKIMSignature();
      signature.setDomain("samplezone.org");
      signature.setSelector("test");
      KeyPair keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
      PrivateKey badKey = keyPair.getPrivate();
      signature.setPrivateKey(badKey);

      return Response.ok("hello world").header(DKIMSignature.DKIM_SIGNATURE, signature).build();
   }
View Full Code Here

   protected void sign(MessageBodyWriterContext context, MultivaluedMap<String, Object> headers, byte[] body, DKIMSignature dosetaSignature) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, UnsupportedEncodingException
   {
      // if its already signed, don't bother
      if (dosetaSignature.getBased64Signature() != null) return;

      PrivateKey privateKey = dosetaSignature.getPrivateKey();
      if (privateKey == null)
      {
         KeyRepository repository = (KeyRepository) context.getAttribute(KeyRepository.class.getName());
         if (repository == null)
         {
View Full Code Here

        }
        File clientCertFile = new File(CoreUtil.getTempDownloadDirectory(getSessionInfo(request)), sel + ".p12");
        FileOutputStream out = new FileOutputStream(clientCertFile);
        char[] password = ((ShowKeyStoreForm) form).getSelectedKeyStore().getKeyStorePassword().toCharArray();
        if (systemClientStore.isKeyEntry(sel)){
            PrivateKey keypair = ((ShowKeyStoreForm) form).getSelectedKeyStore().getPrivateKey(sel,
                            password);
          KeyStore userStore = KeyStore.getInstance("PKCS12", "BC");
          userStore.load(null, null);
          userStore.setKeyEntry(sel, keypair, ((ShowKeyStoreForm) form).getPassword().toCharArray(), ((ShowKeyStoreForm) form).getSelectedKeyStore().getCertificateChain(sel));
          userStore.store(out, ((ShowKeyStoreForm) form).getPassword().toCharArray());
View Full Code Here

    * @throws java.security.GeneralSecurityException
    *
    */
   public void sign(Map headers, byte[] body, PrivateKey defaultKey) throws SignatureException
   {
      PrivateKey key = privateKey == null ? defaultKey : privateKey;
      if (key == null)
      {
         throw new SignatureException("private key is null, cannot sign");
      }
      attributes.put(VERSION, "1");
View Full Code Here

TOP

Related Classes of java.security.PrivateKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.