Package org.kapott.hbci.exceptions

Examples of org.kapott.hbci.exceptions.HBCI_Exception


            } else {
                ret=4096;
            }
            break;
        default:
            throw new HBCI_Exception("*** dont know which keysize to use for profile rdh-"+profile);
        }
       
        HBCIUtils.log("using keysize "+ret+" bits for newly generated keys",HBCIUtils.LOG_DEBUG);
        return ret;
    }
View Full Code Here


                //   mac (tag=0x444d, len=20) (1..1)
                HBCIUtils.log("found mac field",HBCIUtils.LOG_INTERN);
                tlv=new MACField(tlv);
               
            } else {
                throw new HBCI_Exception("*** invalid field tag found: 0x"+Long.toString(tlv.getTag(),16));
            }
           
            addField(tlv);
            posi+=4+tlv.getLength();
        }
       
        if (getField(FileHeader.class)==null) {
            // ohne header-field geht gar nichts
            throw new HBCI_Exception("*** RDH-2/10-file does not contain a header field - aborting");
        }
       
        MACField macfield=(MACField)getField(MACField.class);
        if (macfield!=null) {
            byte[]  storedMac=macfield.getMac();
            byte[]  calculatedMac=calculateMAC();
            boolean macOK=Arrays.equals(storedMac,calculatedMac);
            HBCIUtils.log("MAC field ok: "+macOK,HBCIUtils.LOG_DEBUG);
            if (!macOK) {
                throw new InvalidPassphraseException();
            }
        } else {
            HBCIUtils.log("RDH-2/10-file does not contain a MAC field - ignoring this for now",HBCIUtils.LOG_ERR);
        }

        // decrypt private user keys
        try {
          // calculate decryption key
                FileHeader       fileHeader=(FileHeader)getField(FileHeader.class);
                String           algname=(fileHeader.getProfileVersion()==2)?"HmacSHA1":"HmacSHA256";
          byte[]           derivedKey=deriveKey(24, algname);
          SecretKeyFactory keyfac=SecretKeyFactory.getInstance("DESede");
          DESedeKeySpec    desKeyspec=new DESedeKeySpec(derivedKey);
          SecretKey        key=keyfac.generateSecret(desKeyspec);

          // loop through all userkeys to decrypt them
          TLV[] accounts=getFields(HBCIAccount.class);
          for (int i=0;i<accounts.length;i++) {
            HBCIAccount account=(HBCIAccount)accounts[i];
            List<UserKeys>        userkeys=account.getUserKeys();

            for (Iterator<UserKeys> j=userkeys.iterator();j.hasNext();) {
              HBCIAccount.UserKeys userkey= j.next();
              userkey.decrypt(key);
              HBCIUtils.log(userkey.toString(),HBCIUtils.LOG_INTERN);
            }
          }
        } catch (Exception e) {
          throw new HBCI_Exception(e);
        }
    }
View Full Code Here

                    newEncKey[0]=new HBCIKey(country,blz,userid,num,version,pair.getPublic());
                    newEncKey[1]=new HBCIKey(country,blz,userid,num,version,pair.getPrivate());
                }
            }
        } catch (Exception ex) {
            throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_GENKEYS_ERR"),ex);
        }
       
        HBCIKey[][] ret=new HBCIKey[3][];
        ret[0]=newSigKey;
        ret[1]=newEncKey;
View Full Code Here

                                HBCIAccount.UserKeys userkey= j.next();
                                userkey.encrypt(key);
                        }
                }
        } catch (Exception e) {
                throw new HBCI_Exception(e);
        }

        // reorder fields to standard order
        List<TLV> newFields=new ArrayList<TLV>();
        Class[] order=new Class[] {FileHeader.class, HBCIAccount.class,
View Full Code Here

            byte[] hashdata=getHashData();
            byte[] calculatedMac=mac.doFinal(hashdata);

            return calculatedMac;
        } catch (Exception e) {
            throw new HBCI_Exception(e);
        }
    }
View Full Code Here

            os.write(getSalt());
            os.write(long2ba(getNofIterations()));
           
            setData(os.toByteArray());
        } catch (Exception e) {
            throw new HBCI_Exception(e);
        }
    }
View Full Code Here

                new BigInteger(+1,modulus),
                new BigInteger(+1,exponent));
            KeyFactory fac=KeyFactory.getInstance("RSA");
            this.key=fac.generatePublic(spec);
        } catch (Exception e) {
            throw new HBCI_Exception(e);
        }
       
        HBCIUtils.log("found bank keys with keynum="+this.keynum, HBCIUtils.LOG_DEBUG);
    }
View Full Code Here

            os.write(int2ba(this.exponent.length));
            os.write(reverseba(this.exponent));

            setData(os.toByteArray());
        } catch (Exception e) {
            throw new HBCI_Exception(e);
        }
    }
View Full Code Here

    public byte[] encode(String st)
    {
        try {
            return st.getBytes(Comm.ENCODING);
        } catch (Exception e) {
            throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_ISOERR"),e);
        }
    }
View Full Code Here

                setMyPrivateEncKey(getElementKey(root,"user","V","private"));
               
                if (askForMissingData(true,true,true,true,false,true,true))
                    saveChanges();
            } catch (Exception e) {
                throw new HBCI_Exception("*** error while reading passport file",e);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.kapott.hbci.exceptions.HBCI_Exception

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.