Package org.kapott.hbci.exceptions

Examples of org.kapott.hbci.exceptions.HBCI_Exception


               
                HBCIUtils.log("initializing HBCI4Java proxy authentication callback", HBCIUtils.LOG_DEBUG);
                Authenticator.setDefault(new PinTanProxyAuthenticator(parentPassport));
            }
        } catch (Exception e) {
            throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_CONNERR"),e);
        }
    }
View Full Code Here


            out.flush();
           
            HBCIUtils.log("closing output stream", HBCIUtils.LOG_DEBUG);
            out.close();
        } catch (Exception e) {
            HBCI_Exception he = new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_SENDERR"),e);
            he.setFatal(true); // Abbruch. Auch dann, wenn es ein anonymer BPD-Abruf war
            throw he;
        }
    }
View Full Code Here

            conn.disconnect();
            return new StringBuffer(filter.decode(ret.toString()));
        } catch (Exception e) {
            // Die hier marieren wir nicht als fatal - ich meine mich zu erinnern,
            // dass es Banken gibt, die einen anonymen BPD-Abruf mit einem HTTP-Fehlercode quittieren
            throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_RECVERR"),e);
        }
    }
View Full Code Here

        try {
            Class cl=Class.forName("org.kapott.hbci.comm.Filter"+filter);
            Constructor cons=cl.getConstructor((Class[])null);
            return (Filter)cons.newInstance((Object[])null);
        } catch (Exception e) {
            throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_CANTCREATEFILT",filter),e);
        }
    }
View Full Code Here

       
        try {
            gen=new MsgGen(syntaxStream);
            currentMsgName=null;
        } catch (Exception e) {
            throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_MSGGEN_INIT"),e);
        }
    }
View Full Code Here

    }
   
    public void setParentHandlerData(IHandlerData parentHandlerData)
    {
      if (this.parentHandlerData!=null) {
        throw new HBCI_Exception("*** can not overwrite existing handler object");
      }
      this.parentHandlerData=parentHandlerData;
    }
View Full Code Here

                    all nodes <MSGdef id="xxx"> contain descriptions for the message
                    with name "xxx" */
    public void rawNewMsg(String name)
    {
        if (name==null || name.length()==0)
            throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_EMPTY_MSGNAME"));

        currentMsgName=name;
        HBCIUtils.log("creating new raw message "+name,HBCIUtils.LOG_DEBUG2);
        gen.reset();
    }
View Full Code Here

    {
        HBCIUtils.log("setting raw property "+currentMsgName+"."+key+" to \""+value+"\"",
                      HBCIUtils.LOG_DEBUG2);
       
        if (currentMsgName==null)
            throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_NORAWMSG"));
        if (key==null)
            throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_KEYNULL"));
        if (value==null)
            throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_VALUENULL",key));
       
        if (value.length()!=0) {
            gen.set(currentMsgName+"."+key,value);
        }
    }
View Full Code Here

                Sig sig=SigFactory.getInstance().createSig(getParentHandlerData(),msg,passports);
                try {
                    if (!sig.signIt()) {
                        String errmsg=HBCIUtilsInternal.getLocMsg("EXCMSG_CANTSIGN");
                        if (!HBCIUtilsInternal.ignoreError(null,"client.errors.ignoreSignErrors",errmsg)) {
                            throw new HBCI_Exception(errmsg);
                        }
                    }
                } finally {
                    SigFactory.getInstance().unuseObject(sig);
                }

                // alle rewrites erledigen, die *nach* dem hinzuf�gen der signatur stattfinden m�ssen
                for (int i=0;i<rewriters.length;i++) {
                    MSG old=msg;
                    msg=rewriters[i].outgoingSigned(old,gen);
                    if (msg!=old) {
                        MSGFactory.getInstance().unuseObject(old);
                    }
                }
            }
           
            /* zu jeder SyntaxElement-Referenz (2:3,1)==(SEG:DEG,DE) den Pfad
               des jeweiligen Elementes speichern */
            Properties paths=new Properties();
            msg.getElementPaths(paths,null,null,null);
            ret.addData(paths);
           
            /* f�r alle Elemente (Pfadnamen) die aktuellen Werte speichern,
               wie sie bei der ausgehenden Nachricht versandt werden */
            Hashtable<String,String> current=new Hashtable<String,String>();
            msg.extractValues(current);
            Properties origs=new Properties();
            for (Enumeration<String> e=current.keys();e.hasMoreElements();) {
                String key= e.nextElement();
                String value= current.get(key);
                origs.setProperty("orig_"+key,value);
            }
            ret.addData(origs);
           
            // zu versendene nachricht loggen
            String outstring=msg.toString(0);
            HBCIUtils.log("sending message: "+outstring,HBCIUtils.LOG_DEBUG2);

            // max. nachrichtengr��e aus BPD �berpr�fen
            int maxmsgsize=mainPassport.getMaxMsgSizeKB();
            if (maxmsgsize!=0 && (outstring.length()>>10)>maxmsgsize) {
                String errmsg=HBCIUtilsInternal.getLocMsg("EXCMSG_MSGTOOLARGE",
                                                  new Object[] {Integer.toString(outstring.length()>>10),Integer.toString(maxmsgsize)});
                if (!HBCIUtilsInternal.ignoreError(null,"client.errors.ignoreMsgSizeErrors",errmsg))
                    throw new HBCI_Exception(errmsg);
            }
           
            // soll nachricht verschl�sselt werden?
            if (cryptit) {
                HBCIUtils.log("trying to encrypt message",HBCIUtils.LOG_DEBUG);
                HBCIUtilsInternal.getCallback().status(mainPassport,HBCICallback.STATUS_MSG_CRYPT,null);
               
                // nachricht verschl�sseln
                MSG   old=msg;
                Crypt crypt=CryptFactory.getInstance().createCrypt(getParentHandlerData(),old);
                try {
                    msg=crypt.cryptIt("Crypted");
                } finally {
                    CryptFactory.getInstance().unuseObject(crypt);
                    if (msg!=old) {
                        MSGFactory.getInstance().unuseObject(old);
                    }
                }
               
                if (!msg.getName().equals("Crypted")) {
                    String errmsg=HBCIUtilsInternal.getLocMsg("EXCMSG_CANTCRYPT");
                    if (!HBCIUtilsInternal.ignoreError(null,"client.errors.ignoreCryptErrors",errmsg))
                        throw new HBCI_Exception(errmsg);
                }

                // verschl�sselte nachricht patchen
                for (int i=0;i<rewriters.length;i++) {
                    MSG oldMsg=msg;
                    msg=rewriters[i].outgoingCrypted(oldMsg,gen);
                    if (msg!=oldMsg) {
                        MSGFactory.getInstance().unuseObject(oldMsg);
                    }
                }
               
                HBCIUtils.log("encrypted message to be sent: "+msg.toString(0),HBCIUtils.LOG_DEBUG2);
            }

            // basic-values der ausgehenden nachricht merken
            String msgPath=msg.getPath();
            String msgnum=msg.getValueOfDE(msgPath+".MsgHead.msgnum");
            String dialogid=msg.getValueOfDE(msgPath+".MsgHead.dialogid");
            String hbciversion=msg.getValueOfDE(msgPath+".MsgHead.hbciversion");
           
            // nachricht versenden und antwortnachricht empfangen
            HBCIUtils.log("communicating dialogid/msgnum "+dialogid+"/"+msgnum,HBCIUtils.LOG_DEBUG);
            MSG old=msg;
            msg=mainPassport.getComm().pingpong(currentMsgName,old);
            if (msg!=old) {
                MSGFactory.getInstance().unuseObject(old);
            }

            // ist antwortnachricht verschl�sselt?
            boolean crypted=msg.getName().equals("CryptedRes");
            if (crypted) {
                HBCIUtilsInternal.getCallback().status(mainPassport,HBCICallback.STATUS_MSG_DECRYPT,null);
               
                // wenn ja, dann nachricht entschl�sseln
                Crypt  crypt=CryptFactory.getInstance().createCrypt(getParentHandlerData(),msg);
                String newmsgstring;
                try {
                    newmsgstring=crypt.decryptIt();
                } finally {
                    CryptFactory.getInstance().unuseObject(crypt);
                }
                gen.set("_origSignedMsg",newmsgstring);
               
                // alle patches f�r die unverschl�sselte nachricht durchlaufen
                for (int i=0;i<rewriters.length;i++) {
                    newmsgstring=rewriters[i].incomingClearText(newmsgstring,gen);
                }
               
                HBCIUtils.log("decrypted message after rewriting: "+newmsgstring,HBCIUtils.LOG_DEBUG2);
               
                // nachricht als plaintextnachricht parsen
                try {
                    HBCIUtilsInternal.getCallback().status(mainPassport,HBCICallback.STATUS_MSG_PARSE,currentMsgName+"Res");
                    HBCIUtils.log("message to pe parsed: "+msg.toString(0),HBCIUtils.LOG_DEBUG2);
                    MSG oldMsg=msg;
                    msg=MSGFactory.getInstance().createMSG(currentMsgName+"Res",newmsgstring,newmsgstring.length(),gen);
                    if (msg!=oldMsg) {
                        MSGFactory.getInstance().unuseObject(oldMsg);
                    }
                } catch (Exception ex) {
                    throw new CanNotParseMessageException(HBCIUtilsInternal.getLocMsg("EXCMSG_CANTPARSE"),newmsgstring,ex);
                }
            }
           
            HBCIUtils.log("received message after decryption: "+msg.toString(0),HBCIUtils.LOG_DEBUG2);

            // alle patches f�r die plaintextnachricht durchlaufen
            for (int i=0;i<rewriters.length;i++) {
                MSG oldMsg=msg;
                msg=rewriters[i].incomingData(oldMsg,gen);
                if (msg!=oldMsg) {
                    MSGFactory.getInstance().unuseObject(oldMsg);
                }
            }
           
            // daten aus nachricht in status-objekt einstellen
            HBCIUtils.log("extracting data from received message",HBCIUtils.LOG_DEBUG);
            Properties p=msg.getData();
            p.setProperty("_msg", gen.get("_origSignedMsg"));
            ret.addData(p);
           
            // �berpr�fen einiger constraints, die in einer antwortnachricht eingehalten werden m�ssen
            msgPath=msg.getPath();
            try {
                String hbciversion2=msg.getValueOfDE(msgPath+".MsgHead.hbciversion");
                if (!hbciversion2.equals(hbciversion))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVVERSION",new Object[] {hbciversion2,
                            hbciversion}));
                String msgnum2=msg.getValueOfDE(msgPath+".MsgHead.msgnum");
                if (!msgnum2.equals(msgnum))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVMSGNUM_HEAD",new Object[] {msgnum2,msgnum}));
                msgnum2=msg.getValueOfDE(msgPath+".MsgTail.msgnum");
                if (!msgnum2.equals(msgnum))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVMSGNUM_TAIL",new Object[] {msgnum2,msgnum}));
                String dialogid2=msg.getValueOfDE(msgPath+".MsgHead.dialogid");
                if (!dialogid.equals("0")&&!dialogid2.equals(dialogid))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVDIALOGID",new Object[] {dialogid2,dialogid}));
                if (!dialogid.equals("0")&&!msg.getValueOfDE(msgPath+".MsgHead.MsgRef.dialogid").equals(dialogid))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVDIALOGID_REF"));
                if (!msg.getValueOfDE(msgPath+".MsgHead.MsgRef.msgnum").equals(msgnum))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVMSGNUM_REF"));
            } catch (HBCI_Exception e) {
                String errmsg=HBCIUtilsInternal.getLocMsg("EXCMSG_MSGCHECK")+": "+HBCIUtils.exception2String(e);
                if (!HBCIUtilsInternal.ignoreError(null,"client.errors.ignoreMsgCheckErrors",errmsg))
                    throw e;
            }
           
            // �berpr�fen der signatur
            HBCIUtils.log("looking for a signature",HBCIUtils.LOG_DEBUG);
            HBCIUtilsInternal.getCallback().status(mainPassport,HBCICallback.STATUS_MSG_VERIFY,null);
            boolean sigOk=false;
            Sig     sig=SigFactory.getInstance().createSig(getParentHandlerData(),msg,passports);
            try {
                sigOk=sig.verify();
            } finally {
                SigFactory.getInstance().unuseObject(sig);
            }
           
            // fehlermeldungen erzeugen, wenn irgendwelche fehler aufgetreten sind
            HBCIUtils.log("looking if message is encrypted",HBCIUtils.LOG_DEBUG);
           
            // fehler wegen falscher verschl�sselung
            if (needCrypt && !crypted) {
                String errmsg=HBCIUtilsInternal.getLocMsg("EXCMSG_NOTCRYPTED");
                if (!HBCIUtilsInternal.ignoreError(null,"client.errors.ignoreCryptErrors",errmsg))
                    throw new HBCI_Exception(errmsg);
            }

            // signaturfehler
            if (!sigOk) {
                String errmsg=HBCIUtilsInternal.getLocMsg("EXCMSG_INVSIG");
                if (!HBCIUtilsInternal.ignoreError(null,"client.errors.ignoreSignErrors",errmsg))
                    throw new HBCI_Exception(errmsg);
            }
        } catch (Exception e) {
            // TODO: hack to be able to "disable" HKEND response message analysis
            // because some credit institutes are buggy regarding HKEND responses
            String paramName="client.errors.ignoreDialogEndErrors";
View Full Code Here

    public String decode(String st)
    {
        try {
            return new String(HBCIUtils.decodeBase64(st),Comm.ENCODING);
        } catch (Exception e) {
            throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_B64DECODEERR"),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.