/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6468285
* @summary keytool ability to backdate self-signed certificates to compensate for clock skew
*/
public class StartDateTest {
// Part 1: Test function
run("-keystore jks -storetype jks -storepass changeit -keypass changeit -alias me " +
"-genkeypair -dname CN=Haha -startdate +1y");
throw new Exception("Function check #1 fails");
}
run("-keystore jks -storetype jks -storepass changeit -keypass changeit -alias me " +
"-selfcert -startdate +1m");
throw new Exception("Function check #2 fails");
}
// Part 2: Test format
m.setAccessible(true);
null, //NOW!
"+1m+1d",
"+1y-1m+1d",
"+3H",
"+1M",
"-5M",
"+011d",
"+22S",
"+500S",
"2001/01/01",
"15:15:15",
"2001/01/01 11:11:11",
}) {
try {
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Failed at " + s);
}
}
"", // empty
"+3",
"+3m+",
"+3m+3",
"1m", // no sign
"+0x011d", // hex number
"+1m1d", // no sign for the 2nd sub value
"m",
"+1h", // h is not H
"-1m1d",
"-m",
"x",
"+1m +1d",
"2007/07",
"01:01",
"+01:01:01", // what's this?
"1:01:01",
"12pm",
"2007/07/07 12:12:12", // extra blank between
"2001/01/01-11:11:11",
"2007-07-07", // non-standard date delim
"2007/7/7", // no padding
"07/07/07", // year's length not 4
"1:1:1",
}) {
boolean failed = false;
try {
} catch (Exception e) {
failed = true;
}
}
}
}
}
return cert.getNotBefore();
}
}