@TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "equals", args = {java.lang.Object.class} ) public void testEqualsObject() { Timestamp one = new Timestamp(now, cpath); Timestamp two = new Timestamp(now, cpath); assertTrue(one.equals(one)); assertTrue(one.equals(two)); assertTrue(two.equals(one)); assertFalse(one.equals(null)); assertFalse(one.equals(new Object())); Timestamp two1 = new Timestamp(new Date(9999), cpath); assertFalse(one.equals(two1)); assertTrue(two1.equals(two1)); }
@TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "hashCode", args = {} ) public void testHashCode() { Timestamp one = new Timestamp(now, cpath); Timestamp two = new Timestamp(now, cpath); Timestamp three = new Timestamp(now, new MyCertPath(new byte[] { 10, 20, 30 })); Timestamp four = null; assertTrue(one.hashCode() == two.hashCode()); assertTrue(one.hashCode() != three.hashCode()); assertTrue(two.hashCode() != three.hashCode()); try { four.hashCode(); fail("NullPointerException expected"); } catch (NullPointerException e) { // expected } }
protected Object[] getData() { URL url; CodeSigner[] signers = null; CertPath cpath = TestCertUtils.getCertPath(); Date now = new Date(); Timestamp ts = new Timestamp(now, cpath); try { url = new URL("http://localhost"); signers = new CodeSigner[] { new CodeSigner(cpath, ts) }; } catch (Exception ex) { throw new Error(ex); } Certificate[] x509chain = new Certificate[] { TestCertUtils.rootCA }; Object[] data = new Object[] { new CodeSource(url, (Certificate[])null), new CodeSource(url, new Certificate[0]), new CodeSource(url, signers), new CodeSource(null, x509chain), }; return data; }
public static void main(String[] args) throws Exception { // Create a certpath consisting of one certificate File f = new File(System.getProperty("test.src", "."), "cert_file"); FileInputStream fis = new FileInputStream(f); CertificateFactory cf = CertificateFactory.getInstance("X.509"); Certificate c = cf.generateCertificate(fis); fis.close(); CertPath cp = cf.generateCertPath(Collections.singletonList(c)); // Create a code signer CodeSigner cs = new CodeSigner(cp, new Timestamp(new Date(), cp)); // Serialize the code signer ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(byteOut); out.writeObject(cs); out.close(); // Deserialize the code signer byte[] data = byteOut.toByteArray(); CodeSigner cs2 = (CodeSigner) new ObjectInputStream( new ByteArrayInputStream(data)).readObject(); // Test for equality if (!cs.equals(cs2) || cs.hashCode() != cs2.hashCode()) { throw new Exception("CodeSigner serialization test FAILED"); } }
/** * Create a new {@code AlgorithmChecker} with the * given {@code TrustAnchor}, {@code AlgorithmConstraints}, * {@code Timestamp}, and {@code String} variant. * * @param anchor the trust anchor selected to validate the target * certificate * @param constraints the algorithm constraints (or null) * @param pkixdate The date specified by the PKIXParameters date. If the * PKIXParameters is null, the current date is used. This * should be null when jar files are being checked. * @param jarTimestamp Timestamp passed for JAR timestamp constraint * checking. Set to null if not applicable. * @param variant is the Validator variants of the operation. A null value * passed will set it to Validator.GENERIC. */ public AlgorithmChecker(TrustAnchor anchor, AlgorithmConstraints constraints, Date pkixdate, Timestamp jarTimestamp, String variant) { if (anchor != null) { if (anchor.getTrustedCert() != null) { this.trustedPubKey = anchor.getTrustedCert().getPublicKey(); // Check for anchor certificate restrictions trustedMatch = checkFingerprint(anchor.getTrustedCert()); if (trustedMatch && debug != null) { debug.println("trustedMatch = true"); } } else { this.trustedPubKey = anchor.getCAPublicKey(); } } else { this.trustedPubKey = null; if (debug != null) { debug.println("TrustAnchor is null, trustedMatch is false."); } } this.prevPubKey = this.trustedPubKey; this.constraints = (constraints == null ? certPathDefaultConstraints : constraints); // If we are checking jar files, set pkixdate the same as the timestamp // for certificate checking this.pkixdate = (jarTimestamp != null ? jarTimestamp.getTimestamp() : pkixdate); this.jarTimestamp = jarTimestamp; this.variant = (variant == null ? Validator.VAR_GENERIC : variant); }
public PKIXExtendedParameters(PKIXBuilderParameters params, Timestamp timestamp, String variant) throws InvalidAlgorithmParameterException { super(params.getTrustAnchors(), null); p = params; jarTimestamp = timestamp; this.variant = variant; }
public ConstraintsParameters(X509Certificate c, boolean match, Date pkixdate, Timestamp jarTime, String variant) { cert = c; trustedMatch = match; pkixDate = pkixdate; jarTimestamp = jarTime; this.variant = (variant == null ? Validator.VAR_GENERIC : variant); algorithm = null; algParams = null; publicKey = null; }
public static void main( String[] args ) throws IOException { if ( args.length == 0 ) { printUsage(); return; } Timestamp timestamp = getTimestamp( new File( args[0] ) ); if ( timestamp == null ) { System.out.println( "No timestamp found" ); } else { System.out.println( "timestamp = " + timestamp.getTimestamp() ); } }
/** * Create a new code signer with the specified information. * @param domainName Domain Name to represent the certificate * @param notBefore The date by which the certificate starts being valid. Cannot be null. * @param validity The number of days the certificate is valid after notBefore. * @return A code signer with the properties passed through its parameters. */ public static CodeSigner getOneCodeSigner(String domainName, Date notBefore, int validity) throws Exception { X509Certificate jarEntryCert = createCert(domainName, notBefore, validity); ArrayList<X509Certificate> certs = new ArrayList<X509Certificate>(1); certs.add(jarEntryCert); CertificateFactory cf = CertificateFactory.getInstance("X.509"); CertPath certPath = cf.generateCertPath(certs); Timestamp certTimestamp = new Timestamp(jarEntryCert.getNotBefore(), certPath); return new CodeSigner(certPath, certTimestamp); }
/** * @param obj Obj. * @return True is obj is a known simple type array. */ private static boolean knownArray(Object obj) { return obj instanceof String[] || obj instanceof boolean[] || obj instanceof byte[] || obj instanceof char[] || obj instanceof int[] || obj instanceof long[] || obj instanceof short[] || obj instanceof Timestamp[] || obj instanceof double[] || obj instanceof float[] || obj instanceof UUID[] || obj instanceof BigDecimal[]; }
@TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "getSignerCertPath", args = {} ) public void testGetSignerCertPath() { assertSame(new Timestamp(now, cpath).getSignerCertPath(), cpath); }
@TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "getTimestamp", args = {} ) public void testGetTimestamp() { Timestamp t = new Timestamp(now, cpath); assertEquals(now, t.getTimestamp()); assertNotSame(now, t.getTimestamp()); }
@TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "toString", args = {} ) public void testToString() { try { String tt = new Timestamp(now, cpath).toString(); } catch (Exception e) { fail("Unexpected exception"); } }
/** * must throw NPE if signerCertPath is null */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "NPE case", method = "CodeSigner", args = {java.security.cert.CertPath.class, java.security.Timestamp.class} ) public void testCodeSigner_00() { try { new CodeSigner(null, ts); fail("must not accept null"); } catch (NullPointerException ex) { /* it's ok */ } }
/** * timestamp can be null */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "Null parameter timestamp checking", method = "CodeSigner", args = {java.security.cert.CertPath.class, java.security.Timestamp.class} ) public final void testCodeSigner_01() { try { CodeSigner cs = new CodeSigner(cpath, null); assertNotNull(cs); } catch (Exception e) { fail("Unexpected exception"); } }
/** * Not null parameters */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", method = "CodeSigner", args = {java.security.cert.CertPath.class, java.security.Timestamp.class} ) public final void testCodeSigner_02() { try { CodeSigner cs = new CodeSigner(cpath, ts); assertNotNull(cs); } catch (Exception e) { fail("Unexpected exception"); } }
/** * @see com.intel.drl.test.SerializationTest#getData() */ protected Object[] getData() { CertPath cpath = TestCertUtils.getCertPath(); Timestamp ts = new Timestamp(new Date(1146633204309L), cpath); return new Object[] { new CodeSigner(cpath, ts), new CodeSigner(cpath, null) }; }
@SuppressWarnings({ "deprecation", "unused" }) @FXML private void loadKitapBilgisi2P(ActionEvent event) throws SQLException { ObservableList<String> issueData=FXCollections.observableArrayList(); oduncVer=false; PreparedStatement ps=null; ResultSet rs=null; String bookID=kitapIdJ.getText(); String sorgu="SELECT * FROM ISSUE WHERE BOOK_ID=?"; ps=conn.prepareStatement(sorgu); ps.setString(1, bookID); rs=ps.executeQuery(); while(rs.next()) { String kid=bookID; String mid=rs.getString("MEMBER_ID"); java.sql.Timestamp kissueTime=rs.getTimestamp("ISSUE_TIME"); int renewCount=rs.getInt("RENEW_COUNT"); issueData.add("-�D�N� VER�LME B�LG�LER�-"); issueData.add("�d�n� Verme Tarihi ve Saati: "+kissueTime.toString()); issueData.add("Uzatma Say�s�: "+renewCount); issueData.add("-K�TAP B�LG�LER�-"); String bookSorgu="SELECT * FROM BOOK WHERE ID=?"; PreparedStatement ps1=null; ResultSet rs1=null; ps1=conn.prepareStatement(bookSorgu); ps1.setString(1, kid); rs1=ps1.executeQuery(); while(rs1.next()) { issueData.add("Kitap Ad� :"+rs1.getString("TITLE")); issueData.add("Kitap ID :"+rs1.getString("ID")); issueData.add("Kitap Yazar� :"+rs1.getString("AUTHOR")); issueData.add("Kitap YAYINCISI :"+rs1.getString("PUBLISHER")); } issueData.add("-�YE B�LG�LER�-"); String memberSorgu="SELECT * FROM MEMBER WHERE ID=?"; PreparedStatement ps2=null; ResultSet rs2=null; ps2=conn.prepareStatement(memberSorgu); ps2.setString(1, mid); rs2=ps2.executeQuery(); while(rs2.next()) { issueData.add("�ye Ad� :"+rs2.getString("NAME")); issueData.add("�ye ID :"+rs2.getString("ID")); issueData.add("�ye Telefon :"+rs2.getString("MOBILE")); issueData.add("�ye E-Mail :"+rs2.getString("MAIL")); } oduncVer=true; } if(oduncVer==false) { Alert alert1=new Alert(Alert.AlertType.INFORMATION); alert1.setTitle("KITAP BULUNAMADI"); alert1.setHeaderText(null); alert1.setContentText("Bu kitap hen�z �d�n� verilmedi..."); alert1.showAndWait(); } issueDataList.getItems().setAll(issueData); }