⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 localejbcahardtokenbatchjobsessionbean.java

📁 一套JAVA的CA证书签发系统.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      ArrayList returnval = new ArrayList();      int issuerid = getHardTokenSession().getHardTokenIssuerId(admin, alias);      if(issuerid != IHardTokenSessionLocal.NO_ISSUER){        ResultSet rs = null;        Connection con = null;        PreparedStatement ps = null;        try{           // Construct SQL query.            con = getConnection();            ps = con.prepareStatement("select " + USERDATA_COL + " from UserData where hardTokenIssuerId=? and tokenType>? and (status=? or status=?)" );            ps.setInt(1,issuerid);            ps.setInt(2,SecConst.TOKEN_SOFT);            ps.setInt(3,UserDataLocal.STATUS_NEW);            ps.setInt(4,UserDataLocal.STATUS_KEYRECOVERY);            // Assemble result.           while(rs.next() && returnval.size() <= IHardTokenBatchJobSessionLocal.MAX_RETURNED_QUEUE_SIZE){              UserAdminData data = new UserAdminData(rs.getString(1), rs.getString(2), rs.getInt(14), rs.getString(3), rs.getString(4), rs.getInt(5), rs.getInt(6)                                               , rs.getInt(10), rs.getInt(11)                                               , new java.util.Date(rs.getLong(8)), new java.util.Date(rs.getLong(9))                                               ,  rs.getInt(12), rs.getInt(13));              data.setPassword(rs.getString(7));              getHardTokenSession().getIsHardTokenProfileAvailableToIssuer(admin, issuerid, data);              returnval.add(data);              getLogSession().log(admin, data.getCAId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),data.getUsername(), null, LogEntry.EVENT_INFO_HARDTOKEN_USERDATASENT,"Userdata sent for token generation to issuer with alias :" + alias);            }        }catch(Exception e){          getLogSession().log(admin, admin.getCAId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_HARDTOKEN_USERDATASENT,"Error when retrieving next tokens for issuer with alias: " + alias);          throw new EJBException(e);        }finally{           try{           	             if(rs != null) rs.close();             if(ps != null) ps.close();             if(con!= null) con.close();           }catch(SQLException se){               error("Fel vid upprensning: ", se);           }        }      }      if(returnval.size()==0)        returnval=null;      debug("<getNextHardTokensToGenerate()");      return returnval;    }// getNextHardTokensToGenerate    /**     * Returns the indexed user in queue scheduled for batch generation for the given issuer.     *     * @param admin the administrator performing the actions     * @param issuercert the certificate of the hard token issuer.     * @param index index in queue of user to retrieve.     *     * @return The next token to generate or NULL if the given user doesn't exist in queue.     * @throws EJBException if a communication or other error occurs.     */    public UserAdminData getNextHardTokenToGenerateInQueue(Admin admin, String alias, int index) throws UnavailableTokenException{      debug(">getNextHardTokenToGenerateInQueue()");      UserAdminData returnval=null;      int issuerid = getHardTokenSession().getHardTokenIssuerId(admin, alias);      if(issuerid != IHardTokenSessionLocal.NO_ISSUER){        Connection con = null;        PreparedStatement ps = null;        ResultSet rs = null;        try{           // Construct SQL query.            con = getConnection();            ps = con.prepareStatement("select " + USERDATA_COL + " from UserData where hardTokenIssuerId=? and tokenType>? and (status=? or status=?)" );            ps.setInt(1,issuerid);            ps.setInt(2,SecConst.TOKEN_SOFT);            ps.setInt(3,UserDataLocal.STATUS_NEW);            ps.setInt(4,UserDataLocal.STATUS_KEYRECOVERY);                        // Assemble result.           if(rs.relative(index)){              returnval = new UserAdminData(rs.getString(1), rs.getString(2), rs.getInt(14), rs.getString(3), rs.getString(4), rs.getInt(5), rs.getInt(6)                                               , rs.getInt(10), rs.getInt(11)                                               , new java.util.Date(rs.getLong(8)), new java.util.Date(rs.getLong(9))                                               ,  rs.getInt(12), rs.getInt(13));              returnval.setPassword(rs.getString(7));            }            if(returnval !=null){              getHardTokenSession().getIsHardTokenProfileAvailableToIssuer(admin, issuerid, returnval);              getLogSession().log(admin, returnval.getCAId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),returnval.getUsername(), null, LogEntry.EVENT_INFO_HARDTOKEN_USERDATASENT,"Userdata sent for token generation to issuer with alias: " + alias);            }        }catch(Exception e){          getLogSession().log(admin, admin.getCAId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_HARDTOKEN_USERDATASENT,"Error when retrieving next token for issuer with alias: " + alias);          throw new EJBException(e);        }finally{           try{           	              if(rs != null) rs.close();             if(ps != null) ps.close();             if(con!= null) con.close();           }catch(SQLException se){               error("Fel vid upprensning: ", se);           }        }      }      debug("<getNextHardTokenToGenerateInQueue()");      return returnval;    }// getNextHardTokenToGenerateInQueue    /**     * Returns the number of users scheduled for batch generation for the given issuer.     *     * @param admin the administrator performing the actions     * @param issuercert the certificate of the hard token issuer.     *     * @return the number of users to generate.     * @throws EJBException if a communication or other error occurs.     */    public int getNumberOfHardTokensToGenerate(Admin admin, String alias){      debug(">getNumberOfHardTokensToGenerate()");      int count = 0;      int issuerid = getHardTokenSession().getHardTokenIssuerId(admin, alias);      if(issuerid != IHardTokenSessionLocal.NO_ISSUER){        Connection con = null;        PreparedStatement ps = null;        ResultSet rs = null;        try{           // Construct SQL query.            con = getConnection();            ps = con.prepareStatement("select COUNT(*) from UserData where hardTokenIssuerId=? and tokenType>? and (status=? or status=?)");            ps.setInt(1,issuerid);            ps.setInt(2,SecConst.TOKEN_SOFT);			ps.setInt(3,UserDataLocal.STATUS_NEW);			ps.setInt(4,UserDataLocal.STATUS_KEYRECOVERY);            // Execute query.            rs = ps.executeQuery();            // Assemble result.            while(rs.next()){              count = rs.getInt(1);            }        }catch(Exception e){          throw new EJBException(e);        }finally{           try{             if(rs != null) rs.close();             if(ps != null) ps.close();             if(con!= null) con.close();           }catch(SQLException se){               error("Fel vid upprensning: ", se);           }        }      }      debug("<getNumberOfHardTokensToGenerate()");      return count;    }// getNumberOfHardTokensToGenerate    /**     * Methods that checks if a user exists in the database having the given hard token issuer id. This function is mainly for avoiding     * desyncronisation when a hard token issuer is deleted.     *     * @param hardtokenissuerid the id of hard token issuer to look for.     * @return true if hardtokenissuerid exists in userdatabase.     */    public boolean checkForHardTokenIssuerId(Admin admin, int hardtokenissuerid){        debug(">checkForHardTokenIssuerId(id: " + hardtokenissuerid + ")");        Connection con = null;        PreparedStatement ps = null;        ResultSet rs = null;        int count = 1; // return true as default.        try{           // Construct SQL query.            con = getConnection();            ps = con.prepareStatement("select COUNT(*) from UserData where hardTokenIssuerId=?");            ps.setInt(1,hardtokenissuerid);            // Execute query.            rs = ps.executeQuery();            // Assemble result.            if(rs.next()){              count = rs.getInt(1);            }            debug("<checkForHardTokenIssuerId()");            return count > 0;        }catch(Exception e){          throw new EJBException(e);        }finally{           try{             if(rs != null) rs.close();             if(ps != null) ps.close();             if(con!= null) con.close();           }catch(SQLException se){               error("Fel vid upprensning: ", se);           }        }    } // checkForHardTokenIssuerId} // LocalRaAdminSessionBean

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -