Search in sources :

Example 1 with HttpsUsageEntry

use of com.att.aro.core.bestpractice.pojo.HttpsUsageEntry in project VideoOptimzer by attdevsupport.

the class HttpsUsageImpl method buildHttpsUsageEntry.

/*
	 * If an IP contains a session that does not contain any SSL packet, we
	 * create a HttpsUsageEntry for it.
	 *
	 * This method loops through the IP-sessions map, and returns the list of
	 * HttpsUsageEntry created. If no IP from the IP-sessions map contains a
	 * connection that we consider as HTTP, the method returns an empty list.
	 */
private List<HttpsUsageEntry> buildHttpsUsageEntry(Map<InetAddress, List<Session>> ipSessionsMap) {
    List<HttpsUsageEntry> results = new ArrayList<HttpsUsageEntry>();
    for (Map.Entry<InetAddress, List<Session>> ipSessions : ipSessionsMap.entrySet()) {
        int totalNumConnectionsCurrentIp = 0;
        int totalNumHttpConnectionsCurrentIp = 0;
        int totalHttpTrafficInByteCurrentIp = 0;
        int totalTrafficInByteCurrentIp = 0;
        int httpTrafficPercentage = 0;
        for (Session session : ipSessions.getValue()) {
            boolean isSslSession = false;
            // Excluding UDP Sessions
            if (session.isUdpOnly()) {
                continue;
            }
            List<PacketInfo> packetsInfo = session.getTcpPackets();
            if (packetsInfo.isEmpty()) {
                LOGGER.error("Session without packets! Session's remote IP and port: " + session.getRemoteIP().getHostAddress() + ":" + session.getRemotePort());
                continue;
            }
            /*
				 * Determine if the TCP session is using SSL/TLS. If we find at
				 * least one TCP packet that contains one or more SSL record(s),
				 * we consider that session a SSL session.
				 */
            for (PacketInfo packetInfo : packetsInfo) {
                Packet packet = packetInfo.getPacket();
                if ((packet instanceof TCPPacket) && ((TCPPacket) packet).containsSSLRecord()) {
                    isSslSession = true;
                    break;
                }
            }
            /*
				 * Calculate traffic size for the TCP session
				 */
            // total packet size (ip header + tcp header + payload) of all
            // the packets in the session
            // total payload size of all the packets in the session
            int totalPacketsPayloadSize = 0;
            for (PacketInfo packetInfo : packetsInfo) {
                totalPacketsPayloadSize += packetInfo.getPayloadLen();
            }
            totalNumConnectionsCurrentIp++;
            totalTrafficInByteCurrentIp += totalPacketsPayloadSize;
            if (!(totalPacketsPayloadSize == 0 || isSslSession)) {
                totalHttpTrafficInByteCurrentIp += totalPacketsPayloadSize;
                totalNumHttpConnectionsCurrentIp++;
            }
        }
        // End all sessions associated to an IP
        if (totalNumHttpConnectionsCurrentIp > 0) {
            BigDecimal totalTrafficInKBCurrentIp = new BigDecimal(totalTrafficInByteCurrentIp).divide(new BigDecimal(1000), 3, RoundingMode.HALF_UP);
            BigDecimal totalHttpTrafficInKBCurrentIp = new BigDecimal(totalHttpTrafficInByteCurrentIp).divide(new BigDecimal(1000), 3, RoundingMode.HALF_UP);
            int httpConnectionsPercentage = getHttpConnectionsPercentage(totalNumHttpConnectionsCurrentIp, totalNumConnectionsCurrentIp);
            /*
				 * Initialize percentage to be 0 to avoid getting the
				 * divide-by-zero exception for any unexpected reason.
				 */
            if (totalTrafficInByteCurrentIp <= 0) {
                LOGGER.error("Total traffic size of all TCP sessions is zero or less (" + totalTrafficInByteCurrentIp + " byte)! IP: " + ipSessions.getKey().getHostAddress());
            } else {
                httpTrafficPercentage = getHttpTrafficPercentage(totalHttpTrafficInByteCurrentIp, totalTrafficInByteCurrentIp);
            }
            String parentDomainName = getParentDomainName(ipSessions.getKey(), ipSessions.getValue());
            results.add(new HttpsUsageEntry(ipSessions.getKey().getHostAddress(), parentDomainName, totalNumConnectionsCurrentIp, totalNumHttpConnectionsCurrentIp, httpConnectionsPercentage, totalTrafficInKBCurrentIp, totalHttpTrafficInKBCurrentIp, httpTrafficPercentage));
        }
        totalNumHttpConnectionsCurrentTrace += totalNumHttpConnectionsCurrentIp;
        totalNumConnectionsCurrentTrace += totalNumConnectionsCurrentIp;
    }
    // End all IPs
    return results;
}
Also used : TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) Packet(com.att.aro.core.packetreader.pojo.Packet) ArrayList(java.util.ArrayList) HttpsUsageEntry(com.att.aro.core.bestpractice.pojo.HttpsUsageEntry) BigDecimal(java.math.BigDecimal) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) InetAddress(java.net.InetAddress) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 2 with HttpsUsageEntry

use of com.att.aro.core.bestpractice.pojo.HttpsUsageEntry in project VideoOptimzer by attdevsupport.

the class BpSecurityHttpsUsageTablePanel method getContentTable.

@SuppressWarnings("unchecked")
@Override
public DataTable<HttpsUsageEntry> getContentTable() {
    if (contentTable == null) {
        contentTable = new DataTable<HttpsUsageEntry>(tableModel);
        contentTable.setName(ResourceBundleHelper.getMessageString("security.https.usage.tableName"));
        contentTable.setAutoCreateRowSorter(true);
        contentTable.setGridColor(Color.LIGHT_GRAY);
        contentTable.setRowHeight(ROW_HEIGHT);
        contentTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
        TableRowSorter<TableModel> sorter = new TableRowSorter<>(tableModel);
        contentTable.setRowSorter(sorter);
        sorter.setComparator(0, Util.getDomainSorter());
        sorter.setComparator(7, Util.getIntSorter());
        sorter.setComparator(4, Util.getIntSorter());
        sorter.setComparator(5, Util.getFloatSorter());
        sorter.setComparator(6, Util.getFloatSorter());
        sorter.setComparator(1, Util.getDomainSorter());
        DataTablePopupMenu popupMenu = (DataTablePopupMenu) contentTable.getPopup();
        popupMenu.initialize();
    }
    return contentTable;
}
Also used : DataTablePopupMenu(com.att.aro.ui.model.DataTablePopupMenu) HttpsUsageEntry(com.att.aro.core.bestpractice.pojo.HttpsUsageEntry) TableModel(javax.swing.table.TableModel) HttpsUsageTableModel(com.att.aro.ui.model.bestpractice.HttpsUsageTableModel) TableRowSorter(javax.swing.table.TableRowSorter)

Example 3 with HttpsUsageEntry

use of com.att.aro.core.bestpractice.pojo.HttpsUsageEntry in project VideoOptimzer by attdevsupport.

the class HttpsUsageImplTest method testHttpTrafficPercentage.

@Test
public void testHttpTrafficPercentage() {
    PacketAnalyzerResult pktAnalyzerResult = resultTestSetup(5);
    HttpsUsageResult httpsUsageResult = (HttpsUsageResult) httpsUsageImpl.runTest(pktAnalyzerResult);
    List<HttpsUsageEntry> httpsUsageEntries = httpsUsageResult.getResults();
    assertEquals(2, httpsUsageEntries.size());
    if (httpsUsageEntries.get(0).getIPAddress().equals("157.56.19.80")) {
        assertEquals("100", String.valueOf(httpsUsageEntries.get(0).getTotalHttpTrafficPercentage()));
        assertEquals("25", String.valueOf(httpsUsageEntries.get(1).getTotalHttpTrafficPercentage()));
    } else {
        assertEquals("25", String.valueOf(httpsUsageEntries.get(0).getTotalHttpTrafficPercentage()));
        assertEquals("100", String.valueOf(httpsUsageEntries.get(1).getTotalHttpTrafficPercentage()));
    }
}
Also used : HttpsUsageEntry(com.att.aro.core.bestpractice.pojo.HttpsUsageEntry) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) HttpsUsageResult(com.att.aro.core.bestpractice.pojo.HttpsUsageResult) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 4 with HttpsUsageEntry

use of com.att.aro.core.bestpractice.pojo.HttpsUsageEntry in project VideoOptimzer by attdevsupport.

the class HttpsUsageImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    /*
		 * Reset these total numbers before each test-run due to bean being
		 * singleton.
		 */
    totalNumConnectionsCurrentTrace = 0;
    totalNumHttpConnectionsCurrentTrace = 0;
    List<Session> sessions = tracedata.getSessionlist();
    Map<InetAddress, List<Session>> ipSessionsMap = buildIpSessionsMap(sessions);
    List<HttpsUsageEntry> httpsUsageEntries = buildHttpsUsageEntry(ipSessionsMap);
    int httpConnectionsPercentageCurrentTrace = getHttpConnectionsPercentage(totalNumHttpConnectionsCurrentTrace, totalNumConnectionsCurrentTrace);
    HttpsUsageResult result = new HttpsUsageResult();
    String testResultText = "";
    Statistic stat = tracedata.getStatistic();
    if (passTest()) {
        result.setResultType(BPResultType.PASS);
        testResultText = MessageFormat.format(testResultPassText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, formatDoubleToString(stat.getTotalHTTPSByte() / 1000.0, 2), formatDoubleToString(stat.getTotalHTTPSByte() * 100.0 / stat.getTotalByte(), 2), formatDoubleToString(stat.getTotalHTTPSBytesNotAnalyzed() / 1000.0, 2));
        result.setResultExcelText(BPResultType.PASS.getDescription());
    } else if (failTest(httpsUsageEntries, httpConnectionsPercentageCurrentTrace)) {
        result.setResultType(BPResultType.FAIL);
        testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace, formatDoubleToString(stat.getTotalHTTPSByte() / 1000.0, 2), formatDoubleToString(stat.getTotalHTTPSByte() * 100.0 / stat.getTotalByte(), 2), formatDoubleToString(stat.getTotalHTTPSBytesNotAnalyzed() / 1000.0, 2));
        result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace));
    } else {
        result.setResultType(BPResultType.WARNING);
        testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace, formatDoubleToString(stat.getTotalHTTPSByte() / 1000.0, 2), formatDoubleToString(stat.getTotalHTTPSByte() * 100.0 / stat.getTotalByte(), 2), formatDoubleToString(stat.getTotalHTTPSBytesNotAnalyzed() / 1000.0, 2));
        result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.WARNING.getDescription(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace));
    }
    result.setOverviewTitle(overviewTitle);
    result.setDetailTitle(detailedTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setAboutText(aboutText);
    result.setResults(httpsUsageEntries);
    result.setResultText(testResultText);
    result.setExportAll(exportAll);
    return result;
}
Also used : Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) ArrayList(java.util.ArrayList) List(java.util.List) HttpsUsageEntry(com.att.aro.core.bestpractice.pojo.HttpsUsageEntry) InetAddress(java.net.InetAddress) HttpsUsageResult(com.att.aro.core.bestpractice.pojo.HttpsUsageResult) Session(com.att.aro.core.packetanalysis.pojo.Session)

Aggregations

HttpsUsageEntry (com.att.aro.core.bestpractice.pojo.HttpsUsageEntry)4 HttpsUsageResult (com.att.aro.core.bestpractice.pojo.HttpsUsageResult)2 Session (com.att.aro.core.packetanalysis.pojo.Session)2 InetAddress (java.net.InetAddress)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 BaseTest (com.att.aro.core.BaseTest)1 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)1 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)1 Statistic (com.att.aro.core.packetanalysis.pojo.Statistic)1 Packet (com.att.aro.core.packetreader.pojo.Packet)1 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)1 DataTablePopupMenu (com.att.aro.ui.model.DataTablePopupMenu)1 HttpsUsageTableModel (com.att.aro.ui.model.bestpractice.HttpsUsageTableModel)1 BigDecimal (java.math.BigDecimal)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TableModel (javax.swing.table.TableModel)1 TableRowSorter (javax.swing.table.TableRowSorter)1 Test (org.junit.Test)1