提交 3f90057e 编写于 作者: Y yan

Merge

37a05a11f281b4d238e2f9e7ebb67c63f64d0e77 jdk7-b24 37a05a11f281b4d238e2f9e7ebb67c63f64d0e77 jdk7-b24
75fca0b0ab83ab1392e615910cea020f66535390 jdk7-b25 75fca0b0ab83ab1392e615910cea020f66535390 jdk7-b25
fb57027902e04ecafceae31a605e69b436c23d57 jdk7-b26 fb57027902e04ecafceae31a605e69b436c23d57 jdk7-b26
3e599d98875ddf919c8ea11cff9b3a99ba631a9b jdk7-b27
# #
# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun in the LICENSE file that accompanied this code.
#
# 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
# #
# #
......
# #
# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun in the LICENSE file that accompanied this code.
#
# 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
# #
# #
......
# #
# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun in the LICENSE file that accompanied this code.
#
# 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
# #
# #
......
# #
# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun in the LICENSE file that accompanied this code.
#
# 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
# #
# #
......
# #
#ident "@(#)mapfile-vers 1.1 07/08/14" # Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# Copyright 2006 Sun Microsystems, Inc. All rights reserved. # This code is free software; you can redistribute it and/or modify it
# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. # under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun in the LICENSE file that accompanied this code.
#
# 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
# #
# Define library interface. # Define library interface.
......
...@@ -620,9 +620,35 @@ public class ConfigFile extends javax.security.auth.login.Configuration { ...@@ -620,9 +620,35 @@ public class ConfigFile extends javax.security.auth.login.Configuration {
* start up time noticeably for the new launcher. -- DAC * start up time noticeably for the new launcher. -- DAC
*/ */
private InputStream getInputStream(URL url) throws IOException { private InputStream getInputStream(URL url) throws IOException {
if ("file".equals(url.getProtocol())) { if ("file".equalsIgnoreCase(url.getProtocol())) {
String path = url.getFile().replace('/', File.separatorChar); // Compatibility notes:
return new FileInputStream(path); //
// Code changed from
// String path = url.getFile().replace('/', File.separatorChar);
// return new FileInputStream(path);
//
// The original implementation would search for "/tmp/a%20b"
// when url is "file:///tmp/a%20b". This is incorrect. The
// current codes fix this bug and searches for "/tmp/a b".
// For compatibility reasons, when the file "/tmp/a b" does
// not exist, the file named "/tmp/a%20b" will be tried.
//
// This also means that if both file exists, the behavior of
// this method is changed, and the current codes choose the
// correct one.
try {
return url.openStream();
} catch (Exception e) {
String file = url.getPath();
if (url.getHost().length() > 0) { // For Windows UNC
file = "//" + url.getHost() + file;
}
if (debugConfig != null) {
debugConfig.println("cannot read " + url +
", try " + file);
}
return new FileInputStream(file);
}
} else { } else {
return url.openStream(); return url.openStream();
} }
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing; package com.sun.tracing;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing; package com.sun.tracing;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing; package com.sun.tracing;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing; package com.sun.tracing;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing.dtrace; package com.sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing.dtrace; package com.sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing.dtrace; package com.sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing.dtrace; package com.sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing.dtrace; package com.sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing.dtrace; package com.sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing.dtrace; package com.sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing.dtrace; package com.sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing.dtrace; package com.sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package com.sun.tracing.dtrace; package com.sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
/** /**
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
/** /**
......
...@@ -205,13 +205,33 @@ public class CookieManager extends CookieHandler ...@@ -205,13 +205,33 @@ public class CookieManager extends CookieHandler
if (cookieJar == null) if (cookieJar == null)
return Collections.unmodifiableMap(cookieMap); return Collections.unmodifiableMap(cookieMap);
boolean secureLink = "https".equalsIgnoreCase(uri.getScheme());
List<HttpCookie> cookies = new java.util.ArrayList<HttpCookie>(); List<HttpCookie> cookies = new java.util.ArrayList<HttpCookie>();
String path = uri.getPath();
if (path == null || path.isEmpty()) {
path = "/";
}
for (HttpCookie cookie : cookieJar.get(uri)) { for (HttpCookie cookie : cookieJar.get(uri)) {
// apply path-matches rule (RFC 2965 sec. 3.3.4) // apply path-matches rule (RFC 2965 sec. 3.3.4)
if (pathMatches(uri.getPath(), cookie.getPath())) { // and check for the possible "secure" tag (i.e. don't send
// 'secure' cookies over unsecure links)
if (pathMatches(path, cookie.getPath()) &&
(secureLink || !cookie.getSecure())) {
// Let's check the authorize port list if it exists
String ports = cookie.getPortlist();
if (ports != null && !ports.isEmpty()) {
int port = uri.getPort();
if (port == -1) {
port = "https".equals(uri.getScheme()) ? 443 : 80;
}
if (isInPortList(ports, port)) {
cookies.add(cookie);
}
} else {
cookies.add(cookie); cookies.add(cookie);
} }
} }
}
// apply sort rule (RFC 2965 sec. 3.3.4) // apply sort rule (RFC 2965 sec. 3.3.4)
List<String> cookieHeader = sortByPath(cookies); List<String> cookieHeader = sortByPath(cookies);
...@@ -251,9 +271,47 @@ public class CookieManager extends CookieHandler ...@@ -251,9 +271,47 @@ public class CookieManager extends CookieHandler
try { try {
List<HttpCookie> cookies = HttpCookie.parse(headerValue); List<HttpCookie> cookies = HttpCookie.parse(headerValue);
for (HttpCookie cookie : cookies) { for (HttpCookie cookie : cookies) {
if (cookie.getPath() == null) {
// If no path is specified, then by default
// the path is the directory of the page/doc
String path = uri.getPath();
if (!path.endsWith("/")) {
int i = path.lastIndexOf("/");
if (i > 0) {
path = path.substring(0, i + 1);
} else {
path = "/";
}
}
cookie.setPath(path);
}
String ports = cookie.getPortlist();
if (ports != null) {
int port = uri.getPort();
if (port == -1) {
port = "https".equals(uri.getScheme()) ? 443 : 80;
}
if (ports.isEmpty()) {
// Empty port list means this should be restricted
// to the incoming URI port
cookie.setPortlist("" + port );
if (shouldAcceptInternal(uri, cookie)) { if (shouldAcceptInternal(uri, cookie)) {
cookieJar.add(uri, cookie); cookieJar.add(uri, cookie);
} }
} else {
// Only store cookies with a port list
// IF the URI port is in that list, as per
// RFC 2965 section 3.3.2
if (isInPortList(ports, port) &&
shouldAcceptInternal(uri, cookie)) {
cookieJar.add(uri, cookie);
}
}
} else {
if (shouldAcceptInternal(uri, cookie)) {
cookieJar.add(uri, cookie);
}
}
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// invalid set-cookie header string // invalid set-cookie header string
...@@ -276,6 +334,32 @@ public class CookieManager extends CookieHandler ...@@ -276,6 +334,32 @@ public class CookieManager extends CookieHandler
} }
static private boolean isInPortList(String lst, int port) {
int i = lst.indexOf(",");
int val = -1;
while (i > 0) {
try {
val = Integer.parseInt(lst.substring(0, i));
if (val == port) {
return true;
}
} catch (NumberFormatException numberFormatException) {
}
lst = lst.substring(i+1);
i = lst.indexOf(",");
}
if (!lst.isEmpty()) {
try {
val = Integer.parseInt(lst);
if (val == port) {
return true;
}
} catch (NumberFormatException numberFormatException) {
}
}
return false;
}
/* /*
* path-matches algorithm, as defined by RFC 2965 * path-matches algorithm, as defined by RFC 2965
*/ */
......
...@@ -92,9 +92,14 @@ public final class HttpCookie implements Cloneable { ...@@ -92,9 +92,14 @@ public final class HttpCookie implements Cloneable {
// //
// date format used by Netscape's cookie draft // date formats used by Netscape's cookie draft
// as well as formats seen on various sites
// //
private final static String NETSCAPE_COOKIE_DATE_FORMAT = "EEE',' dd-MMM-yyyy HH:mm:ss 'GMT'"; private final static String[] COOKIE_DATE_FORMATS = {
"EEE',' dd-MMM-yyyy HH:mm:ss 'GMT'",
"EEE',' dd MMM yyyy HH:mm:ss 'GMT'",
"EEE MMM dd yyyy HH:mm:ss 'GMT'Z"
};
// //
// constant strings represent set-cookie header token // constant strings represent set-cookie header token
...@@ -148,6 +153,7 @@ public final class HttpCookie implements Cloneable { ...@@ -148,6 +153,7 @@ public final class HttpCookie implements Cloneable {
secure = false; secure = false;
whenCreated = System.currentTimeMillis(); whenCreated = System.currentTimeMillis();
portlist = null;
} }
...@@ -505,14 +511,14 @@ public final class HttpCookie implements Cloneable { ...@@ -505,14 +511,14 @@ public final class HttpCookie implements Cloneable {
/** /**
* Indicates to the browser whether the cookie should only be sent * Indicates whether the cookie should only be sent using a secure protocol,
* using a secure protocol, such as HTTPS or SSL. * such as HTTPS or SSL.
* *
* <p>The default value is <code>false</code>. * <p>The default value is <code>false</code>.
* *
* @param flag if <code>true</code>, sends the cookie from the browser * @param flag If <code>true</code>, the cookie can only be sent over
* to the server using only when using a secure protocol; * a secure protocol like https.
* if <code>false</code>, sent on any protocol * If <code>false</code>, it can be sent over any protocol.
* *
* @see #getSecure * @see #getSecure
* *
...@@ -526,12 +532,12 @@ public final class HttpCookie implements Cloneable { ...@@ -526,12 +532,12 @@ public final class HttpCookie implements Cloneable {
/** /**
* Returns <code>true</code> if the browser is sending cookies * Returns <code>true</code> if sending this cookie should be
* only over a secure protocol, or <code>false</code> if the * restricted to a secure protocol, or <code>false</code> if the
* browser can send cookies using any protocol. * it can be sent using any protocol.
* *
* @return <code>true</code> if the browser can use * @return <code>false</code> if the cookie can be sent over
* any standard protocol; otherwise, <code>false</code> * any standard protocol; otherwise, <code>true</code>
* *
* @see #setSecure * @see #setSecure
* *
...@@ -748,6 +754,7 @@ public final class HttpCookie implements Cloneable { ...@@ -748,6 +754,7 @@ public final class HttpCookie implements Cloneable {
* *
* @return a string form of the cookie. The string has the defined format * @return a string form of the cookie. The string has the defined format
*/ */
@Override
public String toString() { public String toString() {
if (getVersion() > 0) { if (getVersion() > 0) {
return toRFC2965HeaderString(); return toRFC2965HeaderString();
...@@ -768,6 +775,7 @@ public final class HttpCookie implements Cloneable { ...@@ -768,6 +775,7 @@ public final class HttpCookie implements Cloneable {
* @return <tt>true</tt> if 2 http cookies equal to each other; * @return <tt>true</tt> if 2 http cookies equal to each other;
* otherwise, <tt>false</tt> * otherwise, <tt>false</tt>
*/ */
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) if (obj == this)
return true; return true;
...@@ -798,6 +806,7 @@ public final class HttpCookie implements Cloneable { ...@@ -798,6 +806,7 @@ public final class HttpCookie implements Cloneable {
* *
* @return this http cookie's hash code * @return this http cookie's hash code
*/ */
@Override
public int hashCode() { public int hashCode() {
int h1 = name.toLowerCase().hashCode(); int h1 = name.toLowerCase().hashCode();
int h2 = (domain!=null) ? domain.toLowerCase().hashCode() : 0; int h2 = (domain!=null) ? domain.toLowerCase().hashCode() : 0;
...@@ -811,6 +820,7 @@ public final class HttpCookie implements Cloneable { ...@@ -811,6 +820,7 @@ public final class HttpCookie implements Cloneable {
* *
* @return a clone of this http cookie * @return a clone of this http cookie
*/ */
@Override
public Object clone() { public Object clone() {
try { try {
return super.clone(); return super.clone();
...@@ -978,7 +988,7 @@ public final class HttpCookie implements Cloneable { ...@@ -978,7 +988,7 @@ public final class HttpCookie implements Cloneable {
}); });
assignors.put("port", new CookieAttributeAssignor(){ assignors.put("port", new CookieAttributeAssignor(){
public void assign(HttpCookie cookie, String attrName, String attrValue) { public void assign(HttpCookie cookie, String attrName, String attrValue) {
if (cookie.getPortlist() == null) cookie.setPortlist(attrValue); if (cookie.getPortlist() == null) cookie.setPortlist(attrValue == null ? "" : attrValue);
} }
}); });
assignors.put("secure", new CookieAttributeAssignor(){ assignors.put("secure", new CookieAttributeAssignor(){
...@@ -1050,25 +1060,32 @@ public final class HttpCookie implements Cloneable { ...@@ -1050,25 +1060,32 @@ public final class HttpCookie implements Cloneable {
return sb.toString(); return sb.toString();
} }
private static SimpleDateFormat[] cDateFormats = null;
static {
cDateFormats = new SimpleDateFormat[COOKIE_DATE_FORMATS.length];
for (int i = 0; i < COOKIE_DATE_FORMATS.length; i++) {
cDateFormats[i] = new SimpleDateFormat(COOKIE_DATE_FORMATS[i]);
cDateFormats[i].setTimeZone(TimeZone.getTimeZone("GMT"));
}
}
/* /*
* @param dateString a date string in format of * @param dateString a date string in one of the formats
* "EEE',' dd-MMM-yyyy HH:mm:ss 'GMT'", * defined in Netscape cookie spec
* which defined in Netscape cookie spec
* *
* @return delta seconds between this cookie's creation * @return delta seconds between this cookie's creation
* time and the time specified by dateString * time and the time specified by dateString
*/ */
private long expiryDate2DeltaSeconds(String dateString) { private long expiryDate2DeltaSeconds(String dateString) {
SimpleDateFormat df = new SimpleDateFormat(NETSCAPE_COOKIE_DATE_FORMAT); for (SimpleDateFormat df : cDateFormats) {
df.setTimeZone(TimeZone.getTimeZone("GMT"));
try { try {
Date date = df.parse(dateString); Date date = df.parse(dateString);
return (date.getTime() - whenCreated) / 1000; return (date.getTime() - whenCreated) / 1000;
} catch (Exception e) { } catch (Exception e) {
return 0;
} }
} }
return 0;
}
......
/* /*
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -253,7 +253,8 @@ class Socket implements java.io.Closeable { ...@@ -253,7 +253,8 @@ class Socket implements java.io.Closeable {
* *
* @param host the name of the remote host, or <code>null</code> for the loopback address. * @param host the name of the remote host, or <code>null</code> for the loopback address.
* @param port the remote port * @param port the remote port
* @param localAddr the local address the socket is bound to * @param localAddr the local address the socket is bound to, or
* <code>null</code> for the <code>anyLocal</code> address.
* @param localPort the local port the socket is bound to, or * @param localPort the local port the socket is bound to, or
* <code>zero</code> for a system selected free port. * <code>zero</code> for a system selected free port.
* @exception IOException if an I/O error occurs when creating the socket. * @exception IOException if an I/O error occurs when creating the socket.
......
...@@ -101,13 +101,14 @@ public final class AccessControlContext { ...@@ -101,13 +101,14 @@ public final class AccessControlContext {
} }
/** /**
* Create an AccessControlContext with the given set of ProtectionDomains. * Create an AccessControlContext with the given array of ProtectionDomains.
* Context must not be null. Duplicate domains will be removed from the * Context must not be null. Duplicate domains will be removed from the
* context. * context.
* *
* @param context the ProtectionDomains associated with this context. * @param context the ProtectionDomains associated with this context.
* The non-duplicate domains are copied from the array. Subsequent * The non-duplicate domains are copied from the array. Subsequent
* changes to the array will not affect this AccessControlContext. * changes to the array will not affect this AccessControlContext.
* @throws NullPointerException if <code>context</code> is <code>null</code>
*/ */
public AccessControlContext(ProtectionDomain context[]) public AccessControlContext(ProtectionDomain context[])
{ {
...@@ -125,10 +126,12 @@ public final class AccessControlContext { ...@@ -125,10 +126,12 @@ public final class AccessControlContext {
if ((context[i] != null) && (!v.contains(context[i]))) if ((context[i] != null) && (!v.contains(context[i])))
v.add(context[i]); v.add(context[i]);
} }
if (!v.isEmpty()) {
this.context = new ProtectionDomain[v.size()]; this.context = new ProtectionDomain[v.size()];
this.context = v.toArray(this.context); this.context = v.toArray(this.context);
} }
} }
}
/** /**
* Create a new <code>AccessControlContext</code> with the given * Create a new <code>AccessControlContext</code> with the given
......
...@@ -27,12 +27,10 @@ package java.security; ...@@ -27,12 +27,10 @@ package java.security;
import java.security.*; import java.security.*;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Collections; import java.util.Collections;
import java.util.StringTokenizer;
import java.io.ObjectStreamField; import java.io.ObjectStreamField;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
...@@ -64,14 +62,8 @@ import java.io.IOException; ...@@ -64,14 +62,8 @@ import java.io.IOException;
* @see java.security.Permission * @see java.security.Permission
* @see java.security.Permissions * @see java.security.Permissions
* @see java.security.PermissionCollection * @see java.security.PermissionCollection
* @see java.lang.RuntimePermission
* @see java.security.SecurityPermission
* @see java.util.PropertyPermission
* @see java.awt.AWTPermission
* @see java.net.NetPermission
* @see java.lang.SecurityManager * @see java.lang.SecurityManager
* *
*
* @author Marianne Mueller * @author Marianne Mueller
* @author Roland Schemers * @author Roland Schemers
*/ */
...@@ -95,7 +87,6 @@ implements java.io.Serializable ...@@ -95,7 +87,6 @@ implements java.io.Serializable
* initialize a BasicPermission object. Common to all constructors. * initialize a BasicPermission object. Common to all constructors.
* *
*/ */
private void init(String name) private void init(String name)
{ {
if (name == null) if (name == null)
...@@ -213,8 +204,8 @@ implements java.io.Serializable ...@@ -213,8 +204,8 @@ implements java.io.Serializable
* and has the same name as this object. * and has the same name as this object.
* <P> * <P>
* @param obj the object we are testing for equality with this object. * @param obj the object we are testing for equality with this object.
* @return true if <i>obj</i> is a BasicPermission, and has the same name * @return true if <i>obj</i>'s class is the same as this object's class
* as this BasicPermission object, false otherwise. * and has the same name as this BasicPermission object, false otherwise.
*/ */
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) if (obj == this)
...@@ -237,7 +228,6 @@ implements java.io.Serializable ...@@ -237,7 +228,6 @@ implements java.io.Serializable
* *
* @return a hash code value for this object. * @return a hash code value for this object.
*/ */
public int hashCode() { public int hashCode() {
return this.getName().hashCode(); return this.getName().hashCode();
} }
...@@ -266,7 +256,6 @@ implements java.io.Serializable ...@@ -266,7 +256,6 @@ implements java.io.Serializable
* @return a new PermissionCollection object suitable for * @return a new PermissionCollection object suitable for
* storing BasicPermissions. * storing BasicPermissions.
*/ */
public PermissionCollection newPermissionCollection() { public PermissionCollection newPermissionCollection() {
return new BasicPermissionCollection(this.getClass()); return new BasicPermissionCollection(this.getClass());
} }
......
...@@ -188,7 +188,6 @@ public class IdentityHashMap<K,V> ...@@ -188,7 +188,6 @@ public class IdentityHashMap<K,V>
/** /**
* Use NULL_KEY for key if it is null. * Use NULL_KEY for key if it is null.
*/ */
private static Object maskNull(Object key) { private static Object maskNull(Object key) {
return (key == null ? NULL_KEY : key); return (key == null ? NULL_KEY : key);
} }
...@@ -378,8 +377,8 @@ public class IdentityHashMap<K,V> ...@@ -378,8 +377,8 @@ public class IdentityHashMap<K,V>
*/ */
public boolean containsValue(Object value) { public boolean containsValue(Object value) {
Object[] tab = table; Object[] tab = table;
for (int i = 1; i < tab.length; i+= 2) for (int i = 1; i < tab.length; i += 2)
if (tab[i] == value) if (tab[i] == value && tab[i - 1] != null)
return true; return true;
return false; return false;
...@@ -905,7 +904,6 @@ public class IdentityHashMap<K,V> ...@@ -905,7 +904,6 @@ public class IdentityHashMap<K,V>
* view the first time this view is requested. The view is stateless, * view the first time this view is requested. The view is stateless,
* so there's no reason to create more than one. * so there's no reason to create more than one.
*/ */
private transient Set<Map.Entry<K,V>> entrySet = null; private transient Set<Map.Entry<K,V>> entrySet = null;
/** /**
......
/* /*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1021,7 +1021,7 @@ public class TreeMap<K,V> ...@@ -1021,7 +1021,7 @@ public class TreeMap<K,V>
} }
Iterator<K> descendingKeyIterator() { Iterator<K> descendingKeyIterator() {
return new DescendingKeyIterator(getFirstEntry()); return new DescendingKeyIterator(getLastEntry());
} }
static final class KeySet<E> extends AbstractSet<E> implements NavigableSet<E> { static final class KeySet<E> extends AbstractSet<E> implements NavigableSet<E> {
......
...@@ -100,6 +100,7 @@ class AndQueryExp extends QueryEval implements QueryExp { ...@@ -100,6 +100,7 @@ class AndQueryExp extends QueryEval implements QueryExp {
/** /**
* Returns a string representation of this AndQueryExp * Returns a string representation of this AndQueryExp
*/ */
@Override
public String toString() { public String toString() {
return "(" + exp1 + ") and (" + exp2 + ")"; return "(" + exp1 + ") and (" + exp2 + ")";
} }
......
...@@ -135,6 +135,7 @@ class BetweenQueryExp extends QueryEval implements QueryExp { ...@@ -135,6 +135,7 @@ class BetweenQueryExp extends QueryEval implements QueryExp {
/** /**
* Returns the string representing the object. * Returns the string representing the object.
*/ */
@Override
public String toString() { public String toString() {
return "(" + exp1 + ") between (" + exp2 + ") and (" + exp3 + ")"; return "(" + exp1 + ") between (" + exp2 + ") and (" + exp3 + ")";
} }
......
...@@ -187,11 +187,11 @@ class BinaryRelQueryExp extends QueryEval implements QueryExp { ...@@ -187,11 +187,11 @@ class BinaryRelQueryExp extends QueryEval implements QueryExp {
/** /**
* Returns the string representing the object. * Returns the string representing the object.
*/ */
@Override
public String toString() { public String toString() {
return "(" + exp1 + ") " + relOpString() + " (" + exp2 + ")"; return "(" + exp1 + ") " + relOpString() + " (" + exp2 + ")";
} }
@Override
String toQueryString() { String toQueryString() {
return exp1 + " " + relOpString() + " " + exp2; return exp1 + " " + relOpString() + " " + exp2;
} }
......
...@@ -91,7 +91,6 @@ class NotQueryExp extends QueryEval implements QueryExp { ...@@ -91,7 +91,6 @@ class NotQueryExp extends QueryEval implements QueryExp {
return "not (" + exp + ")"; return "not (" + exp + ")";
} }
@Override
String toQueryString() { String toQueryString() {
return "not (" + Query.toString(exp) + ")"; return "not (" + Query.toString(exp) + ")";
} }
......
...@@ -223,8 +223,7 @@ import javax.management.QueryExp; ...@@ -223,8 +223,7 @@ import javax.management.QueryExp;
* @since 1.5 * @since 1.5
*/ */
@SuppressWarnings("serial") // don't complain serialVersionUID not constant @SuppressWarnings("serial") // don't complain serialVersionUID not constant
public class ObjectName extends ToQueryString public class ObjectName implements Comparable<ObjectName>, QueryExp {
implements Comparable<ObjectName>, QueryExp {
/** /**
* A structure recording property structure and * A structure recording property structure and
...@@ -1781,7 +1780,6 @@ public class ObjectName extends ToQueryString ...@@ -1781,7 +1780,6 @@ public class ObjectName extends ToQueryString
return getSerializedNameString(); return getSerializedNameString();
} }
@Override
String toQueryString() { String toQueryString() {
return "LIKE " + Query.value(toString()); return "LIKE " + Query.value(toString());
} }
......
...@@ -100,6 +100,7 @@ class OrQueryExp extends QueryEval implements QueryExp { ...@@ -100,6 +100,7 @@ class OrQueryExp extends QueryEval implements QueryExp {
/** /**
* Returns a string representation of this OrQueryExp * Returns a string representation of this OrQueryExp
*/ */
@Override
public String toString() { public String toString() {
return "(" + exp1 + ") or (" + exp2 + ")"; return "(" + exp1 + ") or (" + exp2 + ")";
} }
......
...@@ -979,8 +979,18 @@ package javax.management; ...@@ -979,8 +979,18 @@ package javax.management;
if (query == null) if (query == null)
return null; return null;
if (query instanceof ToQueryString) // This is ugly. At one stage we had a non-public class called
return ((ToQueryString) query).toQueryString(); // ToQueryString with the toQueryString() method, and every class
// mentioned here inherited from that class. But that interfered
// with serialization of custom subclasses of e.g. QueryEval. Even
// though we could make it work by adding a public constructor to this
// non-public class, that seemed fragile because according to the
// serialization spec it shouldn't work. If only non-public interfaces
// could have non-public methods.
if (query instanceof ObjectName)
return ((ObjectName) query).toQueryString();
if (query instanceof QueryEval)
return ((QueryEval) query).toQueryString();
return query.toString(); return query.toString();
} }
......
...@@ -25,20 +25,15 @@ ...@@ -25,20 +25,15 @@
package javax.management; package javax.management;
// java import // java import
import java.io.Serializable; import java.io.Serializable;
// RI import
import javax.management.MBeanServer;
/** /**
* Allows a query to be performed in the context of a specific MBean server. * Allows a query to be performed in the context of a specific MBean server.
* *
* @since 1.5 * @since 1.5
*/ */
public abstract class QueryEval extends ToQueryString implements Serializable { public abstract class QueryEval implements Serializable {
/* Serial version */ /* Serial version */
private static final long serialVersionUID = 2675899265640874796L; private static final long serialVersionUID = 2675899265640874796L;
...@@ -80,4 +75,10 @@ public abstract class QueryEval extends ToQueryString implements Serializable { ...@@ -80,4 +75,10 @@ public abstract class QueryEval extends ToQueryString implements Serializable {
public static MBeanServer getMBeanServer() { public static MBeanServer getMBeanServer() {
return server.get(); return server.get();
} }
// Subclasses in this package can override this method to return a different
// string.
String toQueryString() {
return toString();
}
} }
/* /*
* Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -134,6 +134,7 @@ public class SSLContext { ...@@ -134,6 +134,7 @@ public class SSLContext {
* @exception NoSuchAlgorithmException if no Provider supports a * @exception NoSuchAlgorithmException if no Provider supports a
* TrustManagerFactorySpi implementation for the * TrustManagerFactorySpi implementation for the
* specified protocol. * specified protocol.
* @exception NullPointerException if protocol is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
...@@ -175,6 +176,7 @@ public class SSLContext { ...@@ -175,6 +176,7 @@ public class SSLContext {
* registered in the security provider list. * registered in the security provider list.
* *
* @throws IllegalArgumentException if the provider name is null or empty. * @throws IllegalArgumentException if the provider name is null or empty.
* @throws NullPointerException if protocol is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
...@@ -210,6 +212,7 @@ public class SSLContext { ...@@ -210,6 +212,7 @@ public class SSLContext {
* from the specified Provider object. * from the specified Provider object.
* *
* @throws IllegalArgumentException if the provider name is null. * @throws IllegalArgumentException if the provider name is null.
* @throws NullPointerException if protocol is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
......
/* /*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -212,8 +212,10 @@ public abstract class SSLSocket extends Socket ...@@ -212,8 +212,10 @@ public abstract class SSLSocket extends Socket
* @param host name of the host with which to connect, or * @param host name of the host with which to connect, or
* <code>null</code> for the loopback address. * <code>null</code> for the loopback address.
* @param port number of the server's port * @param port number of the server's port
* @param clientAddress the client's host * @param clientAddress the client's address the socket is bound to, or
* @param clientPort number of the client's port * <code>null</code> for the <code>anyLocal</code> address.
* @param clientPort the client's port the socket is bound to, or
* <code>zero</code> for a system selected free port.
* @throws IOException if an I/O error occurs when creating the socket * @throws IOException if an I/O error occurs when creating the socket
* @throws SecurityException if a security manager exists and its * @throws SecurityException if a security manager exists and its
* <code>checkConnect</code> method doesn't allow the operation. * <code>checkConnect</code> method doesn't allow the operation.
...@@ -241,8 +243,10 @@ public abstract class SSLSocket extends Socket ...@@ -241,8 +243,10 @@ public abstract class SSLSocket extends Socket
* *
* @param address the server's host * @param address the server's host
* @param port its port * @param port its port
* @param clientAddress the client's host * @param clientAddress the client's address the socket is bound to, or
* @param clientPort number of the client's port * <code>null</code> for the <code>anyLocal</code> address.
* @param clientPort the client's port the socket is bound to, or
* <code>zero</code> for a system selected free port.
* @throws IOException if an I/O error occurs when creating the socket * @throws IOException if an I/O error occurs when creating the socket
* @throws SecurityException if a security manager exists and its * @throws SecurityException if a security manager exists and its
* <code>checkConnect</code> method doesn't allow the operation. * <code>checkConnect</code> method doesn't allow the operation.
......
/* /*
* Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -129,6 +129,7 @@ public class TrustManagerFactory { ...@@ -129,6 +129,7 @@ public class TrustManagerFactory {
* @exception NoSuchAlgorithmException if no Provider supports a * @exception NoSuchAlgorithmException if no Provider supports a
* TrustManagerFactorySpi implementation for the * TrustManagerFactorySpi implementation for the
* specified algorithm. * specified algorithm.
* @exception NullPointerException if algorithm is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
...@@ -171,6 +172,7 @@ public class TrustManagerFactory { ...@@ -171,6 +172,7 @@ public class TrustManagerFactory {
* registered in the security provider list. * registered in the security provider list.
* *
* @throws IllegalArgumentException if the provider name is null or empty. * @throws IllegalArgumentException if the provider name is null or empty.
* @throws NullPointerException if algorithm is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
...@@ -208,6 +210,7 @@ public class TrustManagerFactory { ...@@ -208,6 +210,7 @@ public class TrustManagerFactory {
* from the specified Provider object. * from the specified Provider object.
* *
* @throws IllegalArgumentException if the provider is null. * @throws IllegalArgumentException if the provider is null.
* @throws NullPointerException if algorithm is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
...@@ -274,6 +277,8 @@ public class TrustManagerFactory { ...@@ -274,6 +277,8 @@ public class TrustManagerFactory {
/** /**
* Returns one trust manager for each type of trust material. * Returns one trust manager for each type of trust material.
* *
* @throws IllegalStateException if the factory is not initialized.
*
* @return the trust managers * @return the trust managers
*/ */
public final TrustManager[] getTrustManagers() { public final TrustManager[] getTrustManagers() {
......
/* /*
* Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -74,6 +74,8 @@ public abstract class TrustManagerFactorySpi { ...@@ -74,6 +74,8 @@ public abstract class TrustManagerFactorySpi {
/** /**
* Returns one trust manager for each type of trust material. * Returns one trust manager for each type of trust material.
* *
* @throws IllegalStateException if the factory is not initialized.
*
* @return the trust managers * @return the trust managers
*/ */
protected abstract TrustManager[] engineGetTrustManagers(); protected abstract TrustManager[] engineGetTrustManagers();
......
/* /*
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -253,7 +253,24 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -253,7 +253,24 @@ public class KerberosTicket implements Destroyable, Refreshable,
Date endTime, Date endTime,
Date renewTill, Date renewTill,
InetAddress[] clientAddresses) { InetAddress[] clientAddresses) {
if (sessionKey == null)
throw new IllegalArgumentException("Session key for ticket"
+ " cannot be null");
init(asn1Encoding, client, server,
new KeyImpl(sessionKey, keyType), flags, authTime,
startTime, endTime, renewTill, clientAddresses);
}
private void init(byte[] asn1Encoding,
KerberosPrincipal client,
KerberosPrincipal server,
KeyImpl sessionKey,
boolean[] flags,
Date authTime,
Date startTime,
Date endTime,
Date renewTill,
InetAddress[] clientAddresses) {
if (asn1Encoding == null) if (asn1Encoding == null)
throw new IllegalArgumentException("ASN.1 encoding of ticket" throw new IllegalArgumentException("ASN.1 encoding of ticket"
+ " cannot be null"); + " cannot be null");
...@@ -269,10 +286,8 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -269,10 +286,8 @@ public class KerberosTicket implements Destroyable, Refreshable,
+ " cannot be null"); + " cannot be null");
this.server = server; this.server = server;
if (sessionKey == null) // Caller needs to make sure `sessionKey` will not be null
throw new IllegalArgumentException("Session key for ticket" this.sessionKey = sessionKey;
+ " cannot be null");
this.sessionKey = new KeyImpl(sessionKey, keyType);
if (flags != null) { if (flags != null) {
if (flags.length >= NUM_FLAGS) if (flags.length >= NUM_FLAGS)
...@@ -291,17 +306,22 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -291,17 +306,22 @@ public class KerberosTicket implements Destroyable, Refreshable,
throw new IllegalArgumentException("The renewable period " throw new IllegalArgumentException("The renewable period "
+ "end time cannot be null for renewable tickets."); + "end time cannot be null for renewable tickets.");
this.renewTill = renewTill; this.renewTill = new Date(renewTill.getTime());
} }
this.authTime = authTime; if (authTime != null) {
this.authTime = new Date(authTime.getTime());
this.startTime = (startTime != null? startTime: authTime); }
if (startTime != null) {
this.startTime = new Date(startTime.getTime());
} else {
this.startTime = this.authTime;
}
if (endTime == null) if (endTime == null)
throw new IllegalArgumentException("End time for ticket validity" throw new IllegalArgumentException("End time for ticket validity"
+ " cannot be null"); + " cannot be null");
this.endTime = endTime; this.endTime = new Date(endTime.getTime());
if (clientAddresses != null) if (clientAddresses != null)
this.clientAddresses = clientAddresses.clone(); this.clientAddresses = clientAddresses.clone();
...@@ -440,7 +460,7 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -440,7 +460,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
* or null if not set. * or null if not set.
*/ */
public final java.util.Date getAuthTime() { public final java.util.Date getAuthTime() {
return (authTime == null) ? null : new Date(authTime.getTime()); return (authTime == null) ? null : (Date)authTime.clone();
} }
/** /**
...@@ -450,7 +470,7 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -450,7 +470,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
* or null if not set. * or null if not set.
*/ */
public final java.util.Date getStartTime() { public final java.util.Date getStartTime() {
return (startTime == null) ? null : new Date(startTime.getTime()); return (startTime == null) ? null : (Date)startTime.clone();
} }
/** /**
...@@ -459,7 +479,7 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -459,7 +479,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
* @return the expiration time for this ticket's validity period. * @return the expiration time for this ticket's validity period.
*/ */
public final java.util.Date getEndTime() { public final java.util.Date getEndTime() {
return endTime; return (Date) endTime.clone();
} }
/** /**
...@@ -469,7 +489,7 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -469,7 +489,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
* @return the latest expiration time for this ticket. * @return the latest expiration time for this ticket.
*/ */
public final java.util.Date getRenewTill() { public final java.util.Date getRenewTill() {
return (renewTill == null) ? null: new Date(renewTill.getTime()); return (renewTill == null) ? null: (Date)renewTill.clone();
} }
/** /**
...@@ -745,4 +765,20 @@ public class KerberosTicket implements Destroyable, Refreshable, ...@@ -745,4 +765,20 @@ public class KerberosTicket implements Destroyable, Refreshable,
return true; return true;
} }
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();
if (sessionKey == null) {
throw new InvalidObjectException("Session key cannot be null");
}
try {
init(asn1Encoding, client, server, sessionKey,
flags, authTime, startTime, endTime,
renewTill, clientAddresses);
} catch (IllegalArgumentException iae) {
throw (InvalidObjectException)
new InvalidObjectException(iae.getMessage()).initCause(iae);
}
}
} }
...@@ -961,6 +961,7 @@ public class URLClassPath { ...@@ -961,6 +961,7 @@ public class URLClassPath {
* from a file URL that refers to a directory. * from a file URL that refers to a directory.
*/ */
private static class FileLoader extends Loader { private static class FileLoader extends Loader {
/* Canonicalized File */
private File dir; private File dir;
FileLoader(URL url) throws IOException { FileLoader(URL url) throws IOException {
...@@ -970,7 +971,7 @@ public class URLClassPath { ...@@ -970,7 +971,7 @@ public class URLClassPath {
} }
String path = url.getFile().replace('/', File.separatorChar); String path = url.getFile().replace('/', File.separatorChar);
path = ParseUtil.decode(path); path = ParseUtil.decode(path);
dir = new File(path); dir = (new File(path)).getCanonicalFile();
} }
/* /*
...@@ -997,8 +998,19 @@ public class URLClassPath { ...@@ -997,8 +998,19 @@ public class URLClassPath {
if (check) if (check)
URLClassPath.check(url); URLClassPath.check(url);
final File file =
new File(dir, name.replace('/', File.separatorChar)); final File file;
if (name.indexOf("..") != -1) {
file = (new File(dir, name.replace('/', File.separatorChar)))
.getCanonicalFile();
if ( !((file.getPath()).startsWith(dir.getPath())) ) {
/* outside of base dir */
return null;
}
} else {
file = new File(dir, name.replace('/', File.separatorChar));
}
if (file.exists()) { if (file.exists()) {
return new Resource() { return new Resource() {
public String getName() { return name; }; public String getName() { return name; };
......
...@@ -36,6 +36,7 @@ import java.util.Random; ...@@ -36,6 +36,7 @@ import java.util.Random;
import sun.net.www.HeaderParser; import sun.net.www.HeaderParser;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import static sun.net.www.protocol.http.HttpURLConnection.HTTP_CONNECT;
/** /**
...@@ -210,10 +211,38 @@ class DigestAuthentication extends AuthenticationInfo { ...@@ -210,10 +211,38 @@ class DigestAuthentication extends AuthenticationInfo {
/** /**
* Reclaculates the request-digest and returns it. * Reclaculates the request-digest and returns it.
*
* <P> Used in the common case where the requestURI is simply the
* abs_path.
*
* @param url
* the URL
*
* @param method
* the HTTP method
*
* @return the value of the HTTP header this authentication wants set * @return the value of the HTTP header this authentication wants set
*/ */
String getHeaderValue(URL url, String method) { String getHeaderValue(URL url, String method) {
return getHeaderValueImpl (url.getFile(), method); return getHeaderValueImpl(url.getFile(), method);
}
/**
* Reclaculates the request-digest and returns it.
*
* <P> Used when the requestURI is not the abs_path. The exact
* requestURI can be passed as a String.
*
* @param requestURI
* the Request-URI from the HTTP request line
*
* @param method
* the HTTP method
*
* @return the value of the HTTP header this authentication wants set
*/
String getHeaderValue(String requestURI, String method) {
return getHeaderValueImpl(requestURI, method);
} }
/** /**
...@@ -249,7 +278,16 @@ class DigestAuthentication extends AuthenticationInfo { ...@@ -249,7 +278,16 @@ class DigestAuthentication extends AuthenticationInfo {
params.setOpaque (p.findValue("opaque")); params.setOpaque (p.findValue("opaque"));
params.setQop (p.findValue("qop")); params.setQop (p.findValue("qop"));
String uri = conn.getURL().getFile(); String uri;
String method;
if (type == PROXY_AUTHENTICATION &&
conn.tunnelState() == HttpURLConnection.TunnelState.SETUP) {
uri = HttpURLConnection.connectRequestURI(conn.getURL());
method = HTTP_CONNECT;
} else {
uri = conn.getURL().getFile();
method = conn.getMethod();
}
if (params.nonce == null || authMethod == null || pw == null || realm == null) { if (params.nonce == null || authMethod == null || pw == null || realm == null) {
return false; return false;
...@@ -275,7 +313,7 @@ class DigestAuthentication extends AuthenticationInfo { ...@@ -275,7 +313,7 @@ class DigestAuthentication extends AuthenticationInfo {
params.setNewCnonce(); params.setNewCnonce();
} }
String value = getHeaderValueImpl (uri, conn.getMethod()); String value = getHeaderValueImpl (uri, method);
if (value != null) { if (value != null) {
conn.setAuthenticationProperty(getHeaderName(), value); conn.setAuthenticationProperty(getHeaderName(), value);
return true; return true;
......
...@@ -75,6 +75,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -75,6 +75,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
private static Logger logger = Logger.getLogger("sun.net.www.protocol.http.HttpURLConnection"); private static Logger logger = Logger.getLogger("sun.net.www.protocol.http.HttpURLConnection");
static String HTTP_CONNECT = "CONNECT";
static final String version; static final String version;
public static final String userAgent; public static final String userAgent;
...@@ -266,6 +268,20 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -266,6 +268,20 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
/* If we decide we want to reuse a client, we put it here */ /* If we decide we want to reuse a client, we put it here */
private HttpClient reuseClient = null; private HttpClient reuseClient = null;
/* Tunnel states */
enum TunnelState {
/* No tunnel */
NONE,
/* Setting up a tunnel */
SETUP,
/* Tunnel has been successfully setup */
TUNNELING
}
private TunnelState tunnelState = TunnelState.NONE;
/* Redefine timeouts from java.net.URLConnection as we nee -1 to mean /* Redefine timeouts from java.net.URLConnection as we nee -1 to mean
* not set. This is to ensure backward compatibility. * not set. This is to ensure backward compatibility.
*/ */
...@@ -338,7 +354,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -338,7 +354,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
* others that have been set * others that have been set
*/ */
// send any pre-emptive authentication // send any pre-emptive authentication
if (http.usingProxy) { if (http.usingProxy && tunnelState() != TunnelState.TUNNELING) {
setPreemptiveProxyAuthentication(requests); setPreemptiveProxyAuthentication(requests);
} }
if (!setRequests) { if (!setRequests) {
...@@ -1404,9 +1420,15 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -1404,9 +1420,15 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
String raw = auth.raw(); String raw = auth.raw();
if (proxyAuthentication.isAuthorizationStale (raw)) { if (proxyAuthentication.isAuthorizationStale (raw)) {
/* we can retry with the current credentials */ /* we can retry with the current credentials */
requests.set (proxyAuthentication.getHeaderName(), String value;
proxyAuthentication.getHeaderValue( if (tunnelState() == TunnelState.SETUP &&
url, method)); proxyAuthentication instanceof DigestAuthentication) {
value = ((DigestAuthentication)proxyAuthentication)
.getHeaderValue(connectRequestURI(url), HTTP_CONNECT);
} else {
value = proxyAuthentication.getHeaderValue(url, method);
}
requests.set(proxyAuthentication.getHeaderName(), value);
currentProxyCredentials = proxyAuthentication; currentProxyCredentials = proxyAuthentication;
return proxyAuthentication; return proxyAuthentication;
} else { } else {
...@@ -1418,6 +1440,24 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -1418,6 +1440,24 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
return proxyAuthentication; return proxyAuthentication;
} }
/**
* Returns the tunnel state.
*
* @return the state
*/
TunnelState tunnelState() {
return tunnelState;
}
/**
* Set the tunneling status.
*
* @param the state
*/
void setTunnelState(TunnelState tunnelState) {
this.tunnelState = tunnelState;
}
/** /**
* establish a tunnel through proxy server * establish a tunnel through proxy server
*/ */
...@@ -1437,6 +1477,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -1437,6 +1477,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
boolean inNegotiateProxy = false; boolean inNegotiateProxy = false;
try { try {
/* Actively setting up a tunnel */
setTunnelState(TunnelState.SETUP);
do { do {
if (!checkReuseConnection()) { if (!checkReuseConnection()) {
proxiedConnect(url, proxyHost, proxyPort, false); proxiedConnect(url, proxyHost, proxyPort, false);
...@@ -1450,6 +1493,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -1450,6 +1493,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
// so ProgressSource is null. // so ProgressSource is null.
http.parseHTTP(responses, null, this); http.parseHTTP(responses, null, this);
/* Log the response to the CONNECT */
logger.fine(responses.toString());
statusLine = responses.getValue(0); statusLine = responses.getValue(0);
StringTokenizer st = new StringTokenizer(statusLine); StringTokenizer st = new StringTokenizer(statusLine);
st.nextToken(); st.nextToken();
...@@ -1509,11 +1555,13 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -1509,11 +1555,13 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
} }
if (respCode == HTTP_OK) { if (respCode == HTTP_OK) {
setTunnelState(TunnelState.TUNNELING);
break; break;
} }
// we don't know how to deal with other response code // we don't know how to deal with other response code
// so disconnect and report error // so disconnect and report error
disconnectInternal(); disconnectInternal();
setTunnelState(TunnelState.NONE);
break; break;
} while (retryTunnel < maxRedirects); } while (retryTunnel < maxRedirects);
...@@ -1535,6 +1583,14 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -1535,6 +1583,14 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
responses.reset(); responses.reset();
} }
static String connectRequestURI(URL url) {
String host = url.getHost();
int port = url.getPort();
port = port != -1 ? port : url.getDefaultPort();
return host + ":" + port;
}
/** /**
* send a CONNECT request for establishing a tunnel to proxy server * send a CONNECT request for establishing a tunnel to proxy server
*/ */
...@@ -1548,8 +1604,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -1548,8 +1604,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
// otherwise, there may have 2 http methods in headers // otherwise, there may have 2 http methods in headers
if (setRequests) requests.set(0, null, null); if (setRequests) requests.set(0, null, null);
requests.prepend("CONNECT " + url.getHost() + ":" requests.prepend(HTTP_CONNECT + " " + connectRequestURI(url)
+ (port != -1 ? port : url.getDefaultPort())
+ " " + httpVersion, null); + " " + httpVersion, null);
requests.setIfNotSet("User-Agent", userAgent); requests.setIfNotSet("User-Agent", userAgent);
...@@ -1563,6 +1618,10 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -1563,6 +1618,10 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
requests.setIfNotSet("Accept", acceptString); requests.setIfNotSet("Accept", acceptString);
setPreemptiveProxyAuthentication(requests); setPreemptiveProxyAuthentication(requests);
/* Log the CONNECT request */
logger.fine(requests.toString());
http.writeRequests(requests, null); http.writeRequests(requests, null);
// remove CONNECT header // remove CONNECT header
requests.set(0, null, null); requests.set(0, null, null);
...@@ -1576,9 +1635,17 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -1576,9 +1635,17 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
= AuthenticationInfo.getProxyAuth(http.getProxyHostUsed(), = AuthenticationInfo.getProxyAuth(http.getProxyHostUsed(),
http.getProxyPortUsed()); http.getProxyPortUsed());
if (pauth != null && pauth.supportsPreemptiveAuthorization()) { if (pauth != null && pauth.supportsPreemptiveAuthorization()) {
String value;
if (tunnelState() == TunnelState.SETUP &&
pauth instanceof DigestAuthentication) {
value = ((DigestAuthentication)pauth)
.getHeaderValue(connectRequestURI(url), HTTP_CONNECT);
} else {
value = pauth.getHeaderValue(url, method);
}
// Sets "Proxy-authorization" // Sets "Proxy-authorization"
requests.set(pauth.getHeaderName(), requests.set(pauth.getHeaderName(), value);
pauth.getHeaderValue(url,method));
currentProxyCredentials = pauth; currentProxyCredentials = pauth;
} }
} }
......
...@@ -35,7 +35,6 @@ import java.util.ArrayList; ...@@ -35,7 +35,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.Comparator;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
/** /**
...@@ -89,7 +88,9 @@ public class InMemoryCookieStore implements CookieStore { ...@@ -89,7 +88,9 @@ public class InMemoryCookieStore implements CookieStore {
if (cookie.getMaxAge() != 0) { if (cookie.getMaxAge() != 0) {
cookieJar.add(cookie); cookieJar.add(cookie);
// and add it to domain index // and add it to domain index
if (cookie.getDomain() != null) {
addIndex(domainIndex, cookie.getDomain(), cookie); addIndex(domainIndex, cookie.getDomain(), cookie);
}
// add it to uri index, too // add it to uri index, too
addIndex(uriIndex, getEffectiveURI(uri), cookie); addIndex(uriIndex, getEffectiveURI(uri), cookie);
} }
...@@ -113,12 +114,13 @@ public class InMemoryCookieStore implements CookieStore { ...@@ -113,12 +114,13 @@ public class InMemoryCookieStore implements CookieStore {
} }
List<HttpCookie> cookies = new ArrayList<HttpCookie>(); List<HttpCookie> cookies = new ArrayList<HttpCookie>();
boolean secureLink = "https".equalsIgnoreCase(uri.getScheme());
lock.lock(); lock.lock();
try { try {
// check domainIndex first // check domainIndex first
getInternal(cookies, domainIndex, new DomainComparator(uri.getHost())); getInternal1(cookies, domainIndex, uri.getHost(), secureLink);
// check uriIndex then // check uriIndex then
getInternal(cookies, uriIndex, getEffectiveURI(uri)); getInternal2(cookies, uriIndex, getEffectiveURI(uri), secureLink);
} finally { } finally {
lock.unlock(); lock.unlock();
} }
...@@ -217,19 +219,96 @@ public class InMemoryCookieStore implements CookieStore { ...@@ -217,19 +219,96 @@ public class InMemoryCookieStore implements CookieStore {
/* ---------------- Private operations -------------- */ /* ---------------- Private operations -------------- */
static class DomainComparator implements Comparable<String> { /*
String host = null; * This is almost the same as HttpCookie.domainMatches except for
* one difference: It won't reject cookies when the 'H' part of the
* domain contains a dot ('.').
* I.E.: RFC 2965 section 3.3.2 says that if host is x.y.domain.com
* and the cookie domain is .domain.com, then it should be rejected.
* However that's not how the real world works. Browsers don't reject and
* some sites, like yahoo.com do actually expect these cookies to be
* passed along.
* And should be used for 'old' style cookies (aka Netscape type of cookies)
*/
private boolean netscapeDomainMatches(String domain, String host)
{
if (domain == null || host == null) {
return false;
}
public DomainComparator(String host) { // if there's no embedded dot in domain and domain is not .local
this.host = host; boolean isLocalDomain = ".local".equalsIgnoreCase(domain);
int embeddedDotInDomain = domain.indexOf('.');
if (embeddedDotInDomain == 0) {
embeddedDotInDomain = domain.indexOf('.', 1);
}
if (!isLocalDomain && (embeddedDotInDomain == -1 || embeddedDotInDomain == domain.length() - 1)) {
return false;
} }
public int compareTo(String domain) { // if the host name contains no dot and the domain name is .local
if (HttpCookie.domainMatches(domain, host)) { int firstDotInHost = host.indexOf('.');
return 0; if (firstDotInHost == -1 && isLocalDomain) {
return true;
}
int domainLength = domain.length();
int lengthDiff = host.length() - domainLength;
if (lengthDiff == 0) {
// if the host name and the domain name are just string-compare euqal
return host.equalsIgnoreCase(domain);
} else if (lengthDiff > 0) {
// need to check H & D component
String H = host.substring(0, lengthDiff);
String D = host.substring(lengthDiff);
return (D.equalsIgnoreCase(domain));
} else if (lengthDiff == -1) {
// if domain is actually .host
return (domain.charAt(0) == '.' &&
host.equalsIgnoreCase(domain.substring(1)));
}
return false;
}
private void getInternal1(List<HttpCookie> cookies, Map<String, List<HttpCookie>> cookieIndex,
String host, boolean secureLink) {
// Use a separate list to handle cookies that need to be removed so
// that there is no conflict with iterators.
ArrayList<HttpCookie> toRemove = new ArrayList<HttpCookie>();
for (Map.Entry<String, List<HttpCookie>> entry : cookieIndex.entrySet()) {
String domain = entry.getKey();
List<HttpCookie> lst = entry.getValue();
for (HttpCookie c : lst) {
if ((c.getVersion() == 0 && netscapeDomainMatches(domain, host)) ||
(c.getVersion() == 1 && HttpCookie.domainMatches(domain, host))) {
if ((cookieJar.indexOf(c) != -1)) {
// the cookie still in main cookie store
if (!c.hasExpired()) {
// don't add twice and make sure it's the proper
// security level
if ((secureLink || !c.getSecure()) &&
!cookies.contains(c)) {
cookies.add(c);
}
} else {
toRemove.add(c);
}
} else { } else {
return -1; // the cookie has beed removed from main store,
// so also remove it from domain indexed store
toRemove.add(c);
}
}
}
// Clear up the cookies that need to be removed
for (HttpCookie c : toRemove) {
lst.remove(c);
cookieJar.remove(c);
} }
toRemove.clear();
} }
} }
...@@ -237,9 +316,9 @@ public class InMemoryCookieStore implements CookieStore { ...@@ -237,9 +316,9 @@ public class InMemoryCookieStore implements CookieStore {
// @param cookieIndex the index // @param cookieIndex the index
// @param comparator the prediction to decide whether or not // @param comparator the prediction to decide whether or not
// a cookie in index should be returned // a cookie in index should be returned
private <T> void getInternal(List<HttpCookie> cookies, private <T> void getInternal2(List<HttpCookie> cookies,
Map<T, List<HttpCookie>> cookieIndex, Map<T, List<HttpCookie>> cookieIndex,
Comparable<T> comparator) Comparable<T> comparator, boolean secureLink)
{ {
for (T index : cookieIndex.keySet()) { for (T index : cookieIndex.keySet()) {
if (comparator.compareTo(index) == 0) { if (comparator.compareTo(index) == 0) {
...@@ -253,7 +332,8 @@ public class InMemoryCookieStore implements CookieStore { ...@@ -253,7 +332,8 @@ public class InMemoryCookieStore implements CookieStore {
// the cookie still in main cookie store // the cookie still in main cookie store
if (!ck.hasExpired()) { if (!ck.hasExpired()) {
// don't add twice // don't add twice
if (!cookies.contains(ck)) if ((secureLink || !ck.getSecure()) &&
!cookies.contains(ck))
cookies.add(ck); cookies.add(ck);
} else { } else {
it.remove(); it.remove();
...@@ -292,14 +372,14 @@ public class InMemoryCookieStore implements CookieStore { ...@@ -292,14 +372,14 @@ public class InMemoryCookieStore implements CookieStore {
// //
// for cookie purpose, the effective uri should only be scheme://authority // for cookie purpose, the effective uri should only be http://host
// the path will be taken into account when path-match algorithm applied // the path will be taken into account when path-match algorithm applied
// //
private URI getEffectiveURI(URI uri) { private URI getEffectiveURI(URI uri) {
URI effectiveURI = null; URI effectiveURI = null;
try { try {
effectiveURI = new URI(uri.getScheme(), effectiveURI = new URI("http",
uri.getAuthority(), uri.getHost(),
null, // path component null, // path component
null, // query component null, // query component
null // fragment component null // fragment component
......
...@@ -326,7 +326,7 @@ class UTF_8 extends Unicode ...@@ -326,7 +326,7 @@ class UTF_8 extends Unicode
case 12: case 13: case 12: case 13:
// 6 bytes, 31 bits // 6 bytes, 31 bits
if (src.remaining() < 4) if (src.remaining() < 5)
return CoderResult.UNDERFLOW; return CoderResult.UNDERFLOW;
if (!isContinuation(b2 = src.get())) if (!isContinuation(b2 = src.get()))
return CoderResult.malformedForLength(1); return CoderResult.malformedForLength(1);
......
...@@ -720,9 +720,13 @@ public final class SunPKCS11 extends AuthProvider { ...@@ -720,9 +720,13 @@ public final class SunPKCS11 extends AuthProvider {
} }
private boolean hasValidToken() { private boolean hasValidToken() {
/* Commented out to work with Solaris softtoken impl which
returns 0-value flags, e.g. both REMOVABLE_DEVICE and
TOKEN_PRESENT are false, when it can't access the token.
if (removable == false) { if (removable == false) {
return true; return true;
} }
*/
Token token = this.token; Token token = this.token;
return (token != null) && token.isValid(); return (token != null) && token.isValid();
} }
...@@ -752,7 +756,7 @@ public final class SunPKCS11 extends AuthProvider { ...@@ -752,7 +756,7 @@ public final class SunPKCS11 extends AuthProvider {
if (slotInfo == null) { if (slotInfo == null) {
slotInfo = p11.C_GetSlotInfo(slotID); slotInfo = p11.C_GetSlotInfo(slotID);
} }
if ((slotInfo.flags & CKF_TOKEN_PRESENT) == 0) { if (removable && (slotInfo.flags & CKF_TOKEN_PRESENT) == 0) {
createPoller(); createPoller();
return; return;
} }
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package sun.tracing; package sun.tracing;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package sun.tracing; package sun.tracing;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package sun.tracing; package sun.tracing;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package sun.tracing; package sun.tracing;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package sun.tracing; package sun.tracing;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package sun.tracing.dtrace; package sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package sun.tracing.dtrace; package sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package sun.tracing.dtrace; package sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package sun.tracing.dtrace; package sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
package sun.tracing.dtrace; package sun.tracing.dtrace;
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
/** /**
......
...@@ -112,6 +112,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { ...@@ -112,6 +112,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
(*env)->SetIntField(env, iaObj, ia_familyID, IPv4); (*env)->SetIntField(env, iaObj, ia_familyID, IPv4);
} else { } else {
static jclass inet6Cls = 0; static jclass inet6Cls = 0;
jint scope;
if (inet6Cls == 0) { if (inet6Cls == 0) {
jclass c = (*env)->FindClass(env, "java/net/Inet6Address"); jclass c = (*env)->FindClass(env, "java/net/Inet6Address");
CHECK_NULL_RETURN(c, NULL); CHECK_NULL_RETURN(c, NULL);
...@@ -129,7 +130,10 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { ...@@ -129,7 +130,10 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
(*env)->SetObjectField(env, iaObj, ia6_ipaddressID, ipaddress); (*env)->SetObjectField(env, iaObj, ia6_ipaddressID, ipaddress);
(*env)->SetIntField(env, iaObj, ia_familyID, IPv6); (*env)->SetIntField(env, iaObj, ia_familyID, IPv6);
(*env)->SetIntField(env, iaObj, ia6_scopeidID, getScopeID(him)); scope = getScopeID(him);
(*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
if (scope > 0)
(*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
} }
*port = ntohs(him6->sin6_port); *port = ntohs(him6->sin6_port);
} else } else
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
#include <stdlib.h> #include <stdlib.h>
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
#ifndef _JVM_SYMBOLS_H #ifndef _JVM_SYMBOLS_H
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
#include <dlfcn.h> #include <dlfcn.h>
......
/* /*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/ */
#include <windows.h> #include <windows.h>
......
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6689000
* @summary Changes in 6675606 causing regression test failures on windows-i586
*/
import com.sun.security.auth.login.*;
import java.io.*;
import java.net.URL;
public class IllegalURL {
public static void main(String[] args) throws Exception {
FileOutputStream fos = new FileOutputStream("x.conf");
fos.close();
use("file:" + System.getProperty("user.dir") + "/x.conf");
use("file:x.conf");
System.out.println("Test passed");
}
static void use(String f) throws Exception {
System.out.println("Testing " + f + "...");
System.setProperty("java.security.auth.login.config", f);
try {
new FileInputStream(new URL(f).getFile().replace('/', File.separatorChar));
} catch (Exception e) {
System.out.println("Even old implementation does not support it. Ignored.");
return;
}
new ConfigFile();
}
}
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6644726
* @summary Cookie management issues
*/
import java.net.*;
import java.util.*;
public class B6644726 {
public static void main(String[] args) throws Exception {
testCookieStore();
}
private static void testCookieStore() throws Exception {
CookieManager cm = new CookieManager();
CookieStore cs = cm.getCookieStore();
URI uri = new URI("http://www.s1.sun.com/dir/foo/doc.html");
URI suri = new URI("https://www.s1.sun.com/dir/foo/index.html");
cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
ArrayList<String> lst = new ArrayList<String>();
// Let's test the default path
lst.add("myCookie1=foo");
// Then some alternate expires format
lst.add("myCookie2=bar; path=/dir; expires=Tue, 19 Aug 2025 16:00:00 GMT");
lst.add("myCookie3=test; path=/dir; expires=Tue Aug 19 2025 16:00:00 GMT-0100");
// Then Netscape draft cookies and domains
lst.add("myCookie4=test; domain=.sun.com; path=/dir/foo");
HashMap<String, List<String>> map = new HashMap<String, List<String>>();
map.put("Set-Cookie", lst);
cm.put(uri, map);
map.clear();
lst.clear();
// Test for secure tag
lst.add("myCookie5=test; secure");
// Test for passing cookies between http and https
map.put("Set-Cookie", lst);
cm.put(suri, map);
List<HttpCookie> cookies = cs.getCookies();
// There should be 5 cookies if all dates parsed correctly
if (cookies.size() != 5) {
fail("Should have 5 cookies. Got only "+ cookies.size() + ", expires probably didn't parse correctly");
}
// Check Path for first Cookie
for (HttpCookie c : cookies) {
if (c.getName().equals("myCookie1")) {
if (!"/dir/foo/".equals(c.getPath())) {
fail("Default path for myCookie1 is " + c.getPath());
}
}
}
HashMap<String, List<String>> emptyMap = new HashMap<String, List<String>>();
// We should get 1 Cookie: MyCookie4, because of the domain
Map<String, List<String>>m = cm.get(new URI("http://www.s2.sun.com/dir/foo/doc2.html"),
emptyMap);
List<String> clst = m.get("Cookie");
if (clst.size() != 1) {
fail("We should have only 1 cookie, not " + clst.size());
} else {
if (!clst.get(0).startsWith("myCookie4")) {
fail("The cookie should be myCookie4, not " + clst.get(0));
}
}
// We should get 4 cookies for non secure URI, and 5 for the secure one
m = cm.get(suri, emptyMap);
clst = m.get("Cookie");
if (clst.size() != 5) {
fail("Cookies didn't cross from http to https. Got only " + clst.size());
}
m = cm.get(uri, emptyMap);
clst = m.get("Cookie");
if (clst.size() != 4) {
fail("We should have gotten only 4 cookies over http (non secure), got " +
clst.size());
}
if (isIn(clst, "myCookie5=")) {
// myCookie5 (the secure one) shouldn't be here
fail("Got the secure cookie over a non secure link");
}
// Let's check that empty path is treated correctly
uri = new URI("http://www.sun.com/");
lst.clear();
lst.add("myCookie6=foo");
map.clear();
map.put("Set-Cookie", lst);
cm.put(uri, map);
uri = new URI("http://www.sun.com");
m = cm.get(uri, emptyMap);
clst = m.get("Cookie");
if (clst.size() != 1) {
fail("Missing a cookie when using an empty path");
}
// And now, the other way around:
uri = new URI("http://www.sun.com");
lst.clear();
lst.add("myCookie7=foo");
map.clear();
map.put("Set-Cookie", lst);
cm.put(uri, map);
uri = new URI("http://www.sun.com/");
m = cm.get(uri, emptyMap);
clst = m.get("Cookie");
if (!isIn(clst, "myCookie7=")) {
fail("Missing a cookie when using an empty path");
}
// Let's make sure the 'Port' optional attributes is enforced
lst.clear();
lst.add("myCookie8=porttest; port");
lst.add("myCookie9=porttest; port=\"80,8000\"");
lst.add("myCookie10=porttest; port=\"8000\"");
map.clear();
map.put("Set-Cookie", lst);
uri = new URI("http://www.sun.com/");
cm.put(uri, map);
// myCookie10 should have been rejected
cookies = cs.getCookies();
for (HttpCookie c : cookies) {
if (c.getName().equals("myCookie10")) {
fail("A cookie with an invalid port list was accepted");
}
}
uri = new URI("http://www.sun.com:80/");
m = cm.get(uri, emptyMap);
clst = m.get("Cookie");
// We should find both myCookie8 and myCookie9 but not myCookie10
if (!isIn(clst, "myCookie8=") || !isIn(clst, "myCookie9=")) {
fail("Missing a cookie on port 80");
}
uri = new URI("http://www.sun.com:8000/");
m = cm.get(uri, emptyMap);
clst = m.get("Cookie");
// We should find only myCookie9
if (!isIn(clst, "myCookie9=")) {
fail("Missing a cookie on port 80");
}
if (isIn(clst, "myCookie8=")) {
fail("A cookie with an invalid port list was returned");
}
}
private static boolean isIn(List<String> lst, String cookie) {
if (lst == null || lst.isEmpty()) {
return false;
}
for (String s : lst) {
if (s.startsWith(cookie))
return true;
}
return false;
}
private static void fail(String msg) throws Exception {
throw new RuntimeException(msg);
}
}
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**
* @test
* @bug 6558853
* @summary getHostAddress() on connections using IPv6 link-local addrs should have zone id
*/
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.*;
import java.util.Enumeration;
public class B6558853 implements Runnable {
private InetAddress addr = null;
private int port = 0;
public static void main(String[] args) throws Exception {
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
Enumeration<NetworkInterface> l = NetworkInterface.getNetworkInterfaces();
InetAddress dest = null;
while (l.hasMoreElements() && dest == null) {
NetworkInterface nif = l.nextElement();
for (InterfaceAddress a : nif.getInterfaceAddresses()) {
if (a.getAddress() instanceof Inet6Address) {
Inet6Address a6 = (Inet6Address) a.getAddress();
if (a6.isLinkLocalAddress()) {
dest = a6;
}
break;
}
}
}
if (dest != null) {
B6558853 test = new B6558853(dest, port);
Thread thread = new Thread(test);
thread.start();
Socket s = ss.accept();
InetAddress a = s.getInetAddress();
OutputStream out = s.getOutputStream();
out.write(1);
out.close();
if (!(a instanceof Inet6Address) || a.getHostAddress().indexOf("%") == -1) {
// No Scope found in the address String
throw new RuntimeException("Wrong address: " + a.getHostAddress());
}
}
}
public B6558853(InetAddress a, int port) {
addr = a;
this.port = port;
}
public void run() {
try {
Socket s = new Socket(addr, port);
InputStream in = s.getInputStream();
int i = in.read();
in.close();
} catch (IOException iOException) {
}
}
}
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6631361
* @summary Test constructor when PD array is null or contains all null contexts
*/
import java.security.AccessControlContext;
import java.security.ProtectionDomain;
public class CheckCtor {
public static void main(String[] args) throws Exception {
// check that null PD array throws NPE
try {
new AccessControlContext(null);
throw new Exception("Expected NullPointerException not thrown");
} catch (Exception e) {
if (!(e instanceof NullPointerException)) {
throw new Exception("Expected NullPointerException not thrown");
}
}
// check that empty PD array equals PD array of one or more nulls
ProtectionDomain zero[] = {};
ProtectionDomain null1[] = {null};
ProtectionDomain null2[] = {null, null};
AccessControlContext accZero = new AccessControlContext(zero);
AccessControlContext accNull1 = new AccessControlContext(null1);
AccessControlContext accNull2 = new AccessControlContext(null2);
testEquals(accZero, accNull1);
testEquals(accZero, accNull2);
testEquals(accNull1, accNull2);
testEquals(accNull1, accZero);
testEquals(accNull2, accZero);
testEquals(accNull2, accNull1);
}
private static void testEquals(AccessControlContext acc1,
AccessControlContext acc2) throws Exception {
if (!acc1.equals(acc2)) {
throw new Exception("AccessControlContexts should be equal");
}
}
}
/* /*
* Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* @test * @test
* @bug 6207984 6272521 6192552 6269713 6197726 6260652 5073546 4137464 * @bug 6207984 6272521 6192552 6269713 6197726 6260652 5073546 4137464
* 4155650 4216399 4294891 6282555 6318622 6355327 6383475 6420753 * 4155650 4216399 4294891 6282555 6318622 6355327 6383475 6420753
* 6431845 4802633 6570566 6570575 6570631 6570924 * 6431845 4802633 6570566 6570575 6570631 6570924 6691185 6691215
* @summary Run many tests on many Collection and Map implementations * @summary Run many tests on many Collection and Map implementations
* @author Martin Buchholz * @author Martin Buchholz
*/ */
...@@ -155,7 +155,7 @@ public class MOAT { ...@@ -155,7 +155,7 @@ public class MOAT {
check(c.containsAll(new ArrayList<Integer>())); check(c.containsAll(new ArrayList<Integer>()));
} }
private static void testEmptyCollection(Collection<?> c) { private static <T> void testEmptyCollection(Collection<T> c) {
check(c.isEmpty()); check(c.isEmpty());
equal(c.size(), 0); equal(c.size(), 0);
equal(c.toString(),"[]"); equal(c.toString(),"[]");
...@@ -165,6 +165,23 @@ public class MOAT { ...@@ -165,6 +165,23 @@ public class MOAT {
Object[] a = new Object[1]; a[0] = Boolean.TRUE; Object[] a = new Object[1]; a[0] = Boolean.TRUE;
equal(c.toArray(a), a); equal(c.toArray(a), a);
equal(a[0], null); equal(a[0], null);
testEmptyIterator(c.iterator());
}
static <T> void testEmptyIterator(final Iterator<T> it) {
if (rnd.nextBoolean())
check(! it.hasNext());
THROWS(NoSuchElementException.class,
new Fun(){void f(){ it.next(); }});
try { it.remove(); }
catch (IllegalStateException _) { pass(); }
catch (UnsupportedOperationException _) { pass(); }
catch (Throwable t) { unexpected(t); }
if (rnd.nextBoolean())
check(! it.hasNext());
} }
private static void testEmptyList(List<?> c) { private static void testEmptyList(List<?> c) {
...@@ -173,10 +190,12 @@ public class MOAT { ...@@ -173,10 +190,12 @@ public class MOAT {
equal2(c, Collections.<Integer>emptyList()); equal2(c, Collections.<Integer>emptyList());
} }
private static void testEmptySet(Set<?> c) { private static <T> void testEmptySet(Set<T> c) {
testEmptyCollection(c); testEmptyCollection(c);
equal(c.hashCode(), 0); equal(c.hashCode(), 0);
equal2(c, Collections.<Integer>emptySet()); equal2(c, Collections.<Integer>emptySet());
if (c instanceof NavigableSet<?>)
testEmptyIterator(((NavigableSet<T>)c).descendingIterator());
} }
private static void testImmutableCollection(final Collection<Integer> c) { private static void testImmutableCollection(final Collection<Integer> c) {
...@@ -221,13 +240,20 @@ public class MOAT { ...@@ -221,13 +240,20 @@ public class MOAT {
testEmptyCollection(c); testEmptyCollection(c);
} }
private static void testEmptyMap(final Map<?,?> m) { private static <K,V> void testEmptyMap(final Map<K,V> m) {
check(m.isEmpty()); check(m.isEmpty());
equal(m.size(), 0); equal(m.size(), 0);
equal(m.toString(),"{}"); equal(m.toString(),"{}");
testEmptySet(m.keySet()); testEmptySet(m.keySet());
testEmptySet(m.entrySet()); testEmptySet(m.entrySet());
testEmptyCollection(m.values()); testEmptyCollection(m.values());
try { check(! m.containsValue(null)); }
catch (NullPointerException _) { /* OK */ }
try { check(! m.containsKey(null)); }
catch (NullPointerException _) { /* OK */ }
check(! m.containsValue(1));
check(! m.containsKey(1));
} }
private static void testImmutableMap(final Map<Integer,Integer> m) { private static void testImmutableMap(final Map<Integer,Integer> m) {
...@@ -433,8 +459,18 @@ public class MOAT { ...@@ -433,8 +459,18 @@ public class MOAT {
if (! supportsAdd(c)) return; if (! supportsAdd(c)) return;
//System.out.println("add() supported"); //System.out.println("add() supported");
if (c instanceof NavigableSet) if (c instanceof NavigableSet) {
testNavigableSet((NavigableSet<Integer>)c); System.out.println("NavigableSet tests...");
NavigableSet<Integer> ns = (NavigableSet<Integer>)c;
testNavigableSet(ns);
testNavigableSet(ns.headSet(6, false));
testNavigableSet(ns.headSet(5, true));
testNavigableSet(ns.tailSet(0, false));
testNavigableSet(ns.tailSet(1, true));
testNavigableSet(ns.subSet(0, false, 5, true));
testNavigableSet(ns.subSet(1, true, 6, false));
}
if (c instanceof Queue) if (c instanceof Queue)
testQueue((Queue<Integer>)c); testQueue((Queue<Integer>)c);
...@@ -514,8 +550,19 @@ public class MOAT { ...@@ -514,8 +550,19 @@ public class MOAT {
if (m instanceof ConcurrentMap) if (m instanceof ConcurrentMap)
testConcurrentMap((ConcurrentMap<Integer,Integer>) m); testConcurrentMap((ConcurrentMap<Integer,Integer>) m);
if (m instanceof NavigableMap) if (m instanceof NavigableMap) {
testNavigableMap((NavigableMap<Integer,Integer>) m); System.out.println("NavigableMap tests...");
NavigableMap<Integer,Integer> nm =
(NavigableMap<Integer,Integer>) m;
testNavigableMap(nm);
testNavigableMap(nm.headMap(6, false));
testNavigableMap(nm.headMap(5, true));
testNavigableMap(nm.tailMap(0, false));
testNavigableMap(nm.tailMap(1, true));
testNavigableMap(nm.subMap(1, true, 6, false));
testNavigableMap(nm.subMap(0, false, 5, true));
}
checkFunctionalInvariants(m); checkFunctionalInvariants(m);
...@@ -697,8 +744,6 @@ public class MOAT { ...@@ -697,8 +744,6 @@ public class MOAT {
private static void testNavigableMap(NavigableMap<Integer,Integer> m) private static void testNavigableMap(NavigableMap<Integer,Integer> m)
{ {
System.out.println("NavigableMap tests...");
clear(m); clear(m);
checkNavigableMapKeys(m, 1, null, null, null, null); checkNavigableMapKeys(m, 1, null, null, null, null);
...@@ -717,9 +762,11 @@ public class MOAT { ...@@ -717,9 +762,11 @@ public class MOAT {
checkNavigableMapKeys(m, 5, 3, 5, 5, null); checkNavigableMapKeys(m, 5, 3, 5, 5, null);
checkNavigableMapKeys(m, 6, 5, 5, null, null); checkNavigableMapKeys(m, 6, 5, 5, null, null);
{ for (final Iterator<Integer> it :
final Iterator<Integer> it (Iterator<Integer>[])
= m.descendingKeySet().iterator(); new Iterator<?>[] {
m.descendingKeySet().iterator(),
m.navigableKeySet().descendingIterator()}) {
equalNext(it, 5); equalNext(it, 5);
equalNext(it, 3); equalNext(it, 3);
equalNext(it, 1); equalNext(it, 1);
...@@ -742,8 +789,6 @@ public class MOAT { ...@@ -742,8 +789,6 @@ public class MOAT {
private static void testNavigableSet(NavigableSet<Integer> s) { private static void testNavigableSet(NavigableSet<Integer> s) {
System.out.println("NavigableSet tests...");
clear(s); clear(s);
checkNavigableSetKeys(s, 1, null, null, null, null); checkNavigableSetKeys(s, 1, null, null, null, null);
...@@ -762,8 +807,11 @@ public class MOAT { ...@@ -762,8 +807,11 @@ public class MOAT {
checkNavigableSetKeys(s, 5, 3, 5, 5, null); checkNavigableSetKeys(s, 5, 3, 5, 5, null);
checkNavigableSetKeys(s, 6, 5, 5, null, null); checkNavigableSetKeys(s, 6, 5, 5, null, null);
{ for (final Iterator<Integer> it :
final Iterator<Integer> it = s.descendingIterator(); (Iterator<Integer>[])
new Iterator<?>[] {
s.descendingIterator(),
s.descendingSet().iterator()}) {
equalNext(it, 5); equalNext(it, 5);
equalNext(it, 3); equalNext(it, 3);
equalNext(it, 1); equalNext(it, 1);
......
/* /*
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2006-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 6420753 6242436 * @bug 6420753 6242436 6691185
* @summary Compare NavigableMap implementations for identical behavior * @summary Compare NavigableMap implementations for identical behavior
* @author Martin Buchholz * @author Martin Buchholz
*/ */
...@@ -159,6 +159,7 @@ public class LockStep { ...@@ -159,6 +159,7 @@ public class LockStep {
Object[] a = new Object[1]; a[0] = Boolean.TRUE; Object[] a = new Object[1]; a[0] = Boolean.TRUE;
equal(c.toArray(a), a); equal(c.toArray(a), a);
equal(a[0], null); equal(a[0], null);
check(! c.iterator().hasNext());
} }
static void testEmptySet(Set<?> c) { static void testEmptySet(Set<?> c) {
...@@ -262,6 +263,16 @@ public class LockStep { ...@@ -262,6 +263,16 @@ public class LockStep {
} }
} }
static void equalIterators(final Iterator<?> it1,
final Iterator<?> it2) {
while (it1.hasNext()) {
if (maybe(2))
check(it2.hasNext());
equal(it1.next(), it2.next());
}
check(! it2.hasNext());
}
static void equalNavigableSetsLeaf(final NavigableSet s1, static void equalNavigableSetsLeaf(final NavigableSet s1,
final NavigableSet s2) { final NavigableSet s2) {
equal2(s1, s2); equal2(s1, s2);
...@@ -273,6 +284,8 @@ public class LockStep { ...@@ -273,6 +284,8 @@ public class LockStep {
equal(s1.first(), s2.first()); equal(s1.first(), s2.first());
equal(s1.last(), s2.last()); equal(s1.last(), s2.last());
} }
equalIterators(s1.iterator(), s2.iterator());
equalIterators(s1.descendingIterator(), s2.descendingIterator());
checkNavigableSet(s1); checkNavigableSet(s1);
checkNavigableSet(s2); checkNavigableSet(s2);
} }
...@@ -493,30 +506,23 @@ public class LockStep { ...@@ -493,30 +506,23 @@ public class LockStep {
static MapFrobber randomAdder(NavigableMap m) { static MapFrobber randomAdder(NavigableMap m) {
final Integer k = unusedKey(m); final Integer k = unusedKey(m);
MapFrobber f; final MapFrobber[] randomAdders = {
switch (rnd.nextInt(4)) { new MapFrobber() {void frob(NavigableMap m) {
case 0: f = new MapFrobber() {void frob(NavigableMap m) {
equal(m.put(k, k+1), null); equal(m.put(k, k+1), null);
equal(m.get(k), k+1); equal(m.get(k), k+1);
if (maybe(4)) { if (maybe(4)) {
equal(m.put(k, k+1), k+1); equal(m.put(k, k+1), k+1);
equal(m.get(k), k+1);}}}; equal(m.get(k), k+1);}}},
break; new MapFrobber() {void frob(NavigableMap m) {
case 1: f = new MapFrobber() {void frob(NavigableMap m) {
m.descendingMap().put(k, k+1); m.descendingMap().put(k, k+1);
equal(m.get(k), k+1);}}; equal(m.get(k), k+1);}},
break; new MapFrobber() {void frob(NavigableMap m) {
case 2: f = new MapFrobber() {void frob(NavigableMap m) { m.tailMap(k,true).headMap(k,true).put(k,k+1);}},
m.tailMap(k,true).headMap(k,true).put(k,k+1);}}; new MapFrobber() {void frob(NavigableMap m) {
break; m.tailMap(k,true).headMap(k,true).descendingMap().put(k,k+1);}}
case 3: f = new MapFrobber() {void frob(NavigableMap m) { };
m.tailMap(k,true).headMap(k,true).descendingMap().put(k,k+1);}};
break;
default: throw new Error();
}
final MapFrobber ff = f;
return new MapFrobber() {void frob(NavigableMap m) { return new MapFrobber() {void frob(NavigableMap m) {
ff.frob(m); randomAdders[rnd.nextInt(randomAdders.length)].frob(m);
if (maybe(2)) equal(m.get(k), k+1); if (maybe(2)) equal(m.get(k), k+1);
if (maybe(4)) { if (maybe(4)) {
equal(m.put(k, k+1), k+1); equal(m.put(k, k+1), k+1);
...@@ -525,26 +531,19 @@ public class LockStep { ...@@ -525,26 +531,19 @@ public class LockStep {
static SetFrobber randomAdder(NavigableSet s) { static SetFrobber randomAdder(NavigableSet s) {
final Integer e = unusedElt(s); final Integer e = unusedElt(s);
SetFrobber f; final SetFrobber[] randomAdders = {
switch (rnd.nextInt(4)) { new SetFrobber() {void frob(NavigableSet s) {
case 0: f = new SetFrobber() {void frob(NavigableSet s) { check(s.add(e));}},
check(s.add(e));}}; new SetFrobber() {void frob(NavigableSet s) {
break; s.descendingSet().add(e);}},
case 1: f = new SetFrobber() {void frob(NavigableSet s) { new SetFrobber() {void frob(NavigableSet s) {
s.descendingSet().add(e);}}; s.tailSet(e,true).headSet(e,true).add(e);}},
break; new SetFrobber() {void frob(NavigableSet s) {
case 2: f = new SetFrobber() {void frob(NavigableSet s) { s.descendingSet().tailSet(e,true).headSet(e,true).add(e);}}
s.tailSet(e,true).headSet(e,true).add(e);}}; };
break;
case 3: f = new SetFrobber() {void frob(NavigableSet s) {
s.descendingSet().tailSet(e,true).headSet(e,true).add(e);}};
break;
default: throw new Error();
}
final SetFrobber ff = f;
return new SetFrobber() {void frob(NavigableSet s) { return new SetFrobber() {void frob(NavigableSet s) {
if (maybe(2)) check(! s.contains(e)); if (maybe(2)) check(! s.contains(e));
ff.frob(s); randomAdders[rnd.nextInt(randomAdders.length)].frob(s);
if (maybe(2)) check(! s.add(e)); if (maybe(2)) check(! s.add(e));
if (maybe(2)) check(s.contains(e));}}; if (maybe(2)) check(s.contains(e));}};
} }
...@@ -605,26 +604,25 @@ public class LockStep { ...@@ -605,26 +604,25 @@ public class LockStep {
static MapFrobber randomRemover(NavigableMap m) { static MapFrobber randomRemover(NavigableMap m) {
final Integer k = usedKey(m); final Integer k = usedKey(m);
switch (rnd.nextInt(7)) { final MapFrobber[] randomRemovers = {
default: throw new Error(); new MapFrobber() {void frob(NavigableMap m) {
case 0: return new MapFrobber() {void frob(NavigableMap m) {
Map.Entry e = m.firstEntry(); Map.Entry e = m.firstEntry();
equal(m.pollFirstEntry(), e); equal(m.pollFirstEntry(), e);
checkUnusedKey(m, e.getKey());}}; checkUnusedKey(m, e.getKey());}},
case 1: return new MapFrobber() {void frob(NavigableMap m) { new MapFrobber() {void frob(NavigableMap m) {
Map.Entry e = m.lastEntry(); Map.Entry e = m.lastEntry();
equal(m.pollLastEntry(), e); equal(m.pollLastEntry(), e);
checkUnusedKey(m, e.getKey());}}; checkUnusedKey(m, e.getKey());}},
case 2: return new MapFrobber() {void frob(NavigableMap m) { new MapFrobber() {void frob(NavigableMap m) {
check(m.remove(k) != null); check(m.remove(k) != null);
checkUnusedKey(m, k);}}; checkUnusedKey(m, k);}},
case 3: return new MapFrobber() {void frob(NavigableMap m) { new MapFrobber() {void frob(NavigableMap m) {
m.subMap(k, true, k, true).clear(); m.subMap(k, true, k, true).clear();
checkUnusedKey(m, k);}}; checkUnusedKey(m, k);}},
case 4: return new MapFrobber() {void frob(NavigableMap m) { new MapFrobber() {void frob(NavigableMap m) {
m.descendingMap().subMap(k, true, k, true).clear(); m.descendingMap().subMap(k, true, k, true).clear();
checkUnusedKey(m, k);}}; checkUnusedKey(m, k);}},
case 5: return new MapFrobber() {void frob(NavigableMap m) { new MapFrobber() {void frob(NavigableMap m) {
final Iterator it = m.keySet().iterator(); final Iterator it = m.keySet().iterator();
while (it.hasNext()) while (it.hasNext())
if (it.next().equals(k)) { if (it.next().equals(k)) {
...@@ -633,8 +631,18 @@ public class LockStep { ...@@ -633,8 +631,18 @@ public class LockStep {
THROWS(IllegalStateException.class, THROWS(IllegalStateException.class,
new Fun(){void f(){ it.remove(); }}); new Fun(){void f(){ it.remove(); }});
} }
checkUnusedKey(m, k);}}; checkUnusedKey(m, k);}},
case 6: return new MapFrobber() {void frob(NavigableMap m) { new MapFrobber() {void frob(NavigableMap m) {
final Iterator it = m.navigableKeySet().descendingIterator();
while (it.hasNext())
if (it.next().equals(k)) {
it.remove();
if (maybe(2))
THROWS(IllegalStateException.class,
new Fun(){void f(){ it.remove(); }});
}
checkUnusedKey(m, k);}},
new MapFrobber() {void frob(NavigableMap m) {
final Iterator<Map.Entry> it = m.entrySet().iterator(); final Iterator<Map.Entry> it = m.entrySet().iterator();
while (it.hasNext()) while (it.hasNext())
if (it.next().getKey().equals(k)) { if (it.next().getKey().equals(k)) {
...@@ -642,32 +650,34 @@ public class LockStep { ...@@ -642,32 +650,34 @@ public class LockStep {
if (maybe(2)) if (maybe(2))
THROWS(IllegalStateException.class, remover(it)); THROWS(IllegalStateException.class, remover(it));
} }
checkUnusedKey(m, k);}}; checkUnusedKey(m, k);}},
} };
return randomRemovers[rnd.nextInt(randomRemovers.length)];
} }
static SetFrobber randomRemover(NavigableSet s) { static SetFrobber randomRemover(NavigableSet s) {
final Integer e = usedElt(s); final Integer e = usedElt(s);
switch (rnd.nextInt(7)) {
default: throw new Error(); final SetFrobber[] randomRemovers = {
case 0: return new SetFrobber() {void frob(NavigableSet s) { new SetFrobber() {void frob(NavigableSet s) {
Object e = s.first(); Object e = s.first();
equal(s.pollFirst(), e); equal(s.pollFirst(), e);
checkUnusedElt(s, e);}}; checkUnusedElt(s, e);}},
case 1: return new SetFrobber() {void frob(NavigableSet s) { new SetFrobber() {void frob(NavigableSet s) {
Object e = s.last(); Object e = s.last();
equal(s.pollLast(), e); equal(s.pollLast(), e);
checkUnusedElt(s, e);}}; checkUnusedElt(s, e);}},
case 2: return new SetFrobber() {void frob(NavigableSet s) { new SetFrobber() {void frob(NavigableSet s) {
check(s.remove(e)); check(s.remove(e));
checkUnusedElt(s, e);}}; checkUnusedElt(s, e);}},
case 3: return new SetFrobber() {void frob(NavigableSet s) { new SetFrobber() {void frob(NavigableSet s) {
s.subSet(e, true, e, true).clear(); s.subSet(e, true, e, true).clear();
checkUnusedElt(s, e);}}; checkUnusedElt(s, e);}},
case 4: return new SetFrobber() {void frob(NavigableSet s) { new SetFrobber() {void frob(NavigableSet s) {
s.descendingSet().subSet(e, true, e, true).clear(); s.descendingSet().subSet(e, true, e, true).clear();
checkUnusedElt(s, e);}}; checkUnusedElt(s, e);}},
case 5: return new SetFrobber() {void frob(NavigableSet s) { new SetFrobber() {void frob(NavigableSet s) {
final Iterator it = s.iterator(); final Iterator it = s.iterator();
while (it.hasNext()) while (it.hasNext())
if (it.next().equals(e)) { if (it.next().equals(e)) {
...@@ -676,8 +686,8 @@ public class LockStep { ...@@ -676,8 +686,8 @@ public class LockStep {
THROWS(IllegalStateException.class, THROWS(IllegalStateException.class,
new Fun(){void f(){ it.remove(); }}); new Fun(){void f(){ it.remove(); }});
} }
checkUnusedElt(s, e);}}; checkUnusedElt(s, e);}},
case 6: return new SetFrobber() {void frob(NavigableSet s) { new SetFrobber() {void frob(NavigableSet s) {
final Iterator it = s.descendingSet().iterator(); final Iterator it = s.descendingSet().iterator();
while (it.hasNext()) while (it.hasNext())
if (it.next().equals(e)) { if (it.next().equals(e)) {
...@@ -686,8 +696,20 @@ public class LockStep { ...@@ -686,8 +696,20 @@ public class LockStep {
THROWS(IllegalStateException.class, THROWS(IllegalStateException.class,
new Fun(){void f(){ it.remove(); }}); new Fun(){void f(){ it.remove(); }});
} }
checkUnusedElt(s, e);}}; checkUnusedElt(s, e);}},
new SetFrobber() {void frob(NavigableSet s) {
final Iterator it = s.descendingIterator();
while (it.hasNext())
if (it.next().equals(e)) {
it.remove();
if (maybe(2))
THROWS(IllegalStateException.class,
new Fun(){void f(){ it.remove(); }});
} }
checkUnusedElt(s, e);}}
};
return randomRemovers[rnd.nextInt(randomRemovers.length)];
} }
static void lockStep(NavigableMap m1, static void lockStep(NavigableMap m1,
......
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6692027
* @summary Check that custom subclasses of QueryEval can be serialized.
* @author Eamonn McManus
*/
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.management.ManagementFactory;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.QueryEval;
import javax.management.QueryExp;
public class CustomQueryTest {
public static interface CountMBean {
public int getCount();
public void increment();
}
public static class Count implements CountMBean {
private AtomicInteger count = new AtomicInteger();
public int getCount() {
return count.get();
}
public void increment() {
count.incrementAndGet();
}
}
public static final ObjectName countName;
static {
try {
countName = new ObjectName("d:type=Count");
} catch (MalformedObjectNameException e) {
throw new AssertionError(e);
}
}
/* A query that calls the increment method of the Count MBean every time
* it is evaluated. If there is no ObjectName filter, the query will be
* evaluated for every MBean in the MBean Server, so the count will be
* incremented by the number of MBeans.
*/
public static class IncrQuery extends QueryEval implements QueryExp {
public boolean apply(ObjectName name) {
try {
getMBeanServer().invoke(countName, "increment", null, null);
return true;
} catch (Throwable t) {
t.printStackTrace();
System.exit(1);
throw new AssertionError(); // not reached
}
}
}
public static void main(String[] args) throws Exception {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean(new Count(), countName);
int mbeanCount = mbs.getMBeanCount();
QueryExp query = new IncrQuery();
Set<ObjectName> names = mbs.queryNames(null, query);
assertEquals(mbeanCount, names.size());
assertEquals(mbeanCount, mbs.getAttribute(countName, "Count"));
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oout = new ObjectOutputStream(bout);
oout.writeObject(query);
oout.close();
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
ObjectInputStream oin = new ObjectInputStream(bin);
query = (QueryExp) oin.readObject();
names = mbs.queryNames(null, query);
assertEquals(mbeanCount * 2, mbs.getAttribute(countName, "Count"));
}
private static void assertEquals(Object expected, Object actual)
throws Exception {
if (!expected.equals(actual)) {
String failure = "FAILED: expected " + expected + ", got " + actual;
throw new Exception(failure);
}
}
}
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6659990
* @summary test the immutability of the Date fields in KerberosTicket class.
* @ignore Must set up KDC and setup Kerberos configuration file
*/
import java.net.InetAddress;
import java.util.Date;
import java.io.*;
import javax.security.auth.kerberos.KerberosKey;
import javax.security.auth.kerberos.KerberosPrincipal;
import javax.security.auth.kerberos.KerberosTicket;
import sun.misc.BASE64Decoder;
public class KerberosTixDateTest {
// Serialized KerberosTicket from JDK6 (encoded in BASE64)
// Note: the KerberosTicket object is created using the same values as
// the KerberosTicket 't' in main(). Deserialization should succeed
// and the deserialized object should equal to 't'.
static String serializedKerberosTix =
"rO0ABXNyACtqYXZheC5zZWN1cml0eS5hdXRoLmtlcmJlcm9zLktlcmJlcm9zVGlja2V0ZqGBbXB3" +
"w7sCAApbAAxhc24xRW5jb2Rpbmd0AAJbQkwACGF1dGhUaW1ldAAQTGphdmEvdXRpbC9EYXRlO0wA" +
"BmNsaWVudHQAMExqYXZheC9zZWN1cml0eS9hdXRoL2tlcmJlcm9zL0tlcmJlcm9zUHJpbmNpcGFs" +
"O1sAD2NsaWVudEFkZHJlc3Nlc3QAF1tMamF2YS9uZXQvSW5ldEFkZHJlc3M7TAAHZW5kVGltZXEA" +
"fgACWwAFZmxhZ3N0AAJbWkwACXJlbmV3VGlsbHEAfgACTAAGc2VydmVycQB+AANMAApzZXNzaW9u" +
"S2V5dAAmTGphdmF4L3NlY3VyaXR5L2F1dGgva2VyYmVyb3MvS2V5SW1wbDtMAAlzdGFydFRpbWVx" +
"AH4AAnhwdXIAAltCrPMX+AYIVOACAAB4cAAAAARhc24xc3IADmphdmEudXRpbC5EYXRlaGqBAUtZ" +
"dBkDAAB4cHcIAAAAAAC8YU54c3IALmphdmF4LnNlY3VyaXR5LmF1dGgua2VyYmVyb3MuS2VyYmVy" +
"b3NQcmluY2lwYWyZp31dDx4zKQMAAHhwdXEAfgAIAAAAEzARoAMCAQGhCjAIGwZjbGllbnR1cQB+" +
"AAgAAAAVGxNKTEFCUy5TRkJBWS5TVU4uQ09NeHBxAH4AC3VyAAJbWlePIDkUuF3iAgAAeHAAAAAg" +
"AAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABxAH4AC3NxAH4ADHVxAH4ACAAAABMwEaAD" +
"AgEBoQowCBsGc2VydmVydXEAfgAIAAAAFRsTSkxBQlMuU0ZCQVkuU1VOLkNPTXhzcgAkamF2YXgu" +
"c2VjdXJpdHkuYXV0aC5rZXJiZXJvcy5LZXlJbXBskoOG6DyvS9cDAAB4cHVxAH4ACAAAABUwE6AD" +
"AgEBoQwECnNlc3Npb25LZXl4cQB+AAs=";
public static void main(String[] args) throws Exception {
byte[] asn1Bytes = "asn1".getBytes();
KerberosPrincipal client = new KerberosPrincipal("client");
KerberosPrincipal server = new KerberosPrincipal("server");
byte[] keyBytes = "sessionKey".getBytes();
long originalTime = 12345678L;
Date inDate = new Date(originalTime);
boolean[] flags = new boolean[9];
flags[8] = true; // renewable
KerberosTicket t = new KerberosTicket(asn1Bytes, client, server,
keyBytes, 1 /*keyType*/, flags, inDate /*authTime*/,
inDate /*startTime*/, inDate /*endTime*/,
inDate /*renewTill*/, null /*clientAddresses*/);
inDate.setTime(0); // for testing the constructor
testDateImmutability(t, originalTime);
testS11nCompatibility(t); // S11n: Serialization
}
private static void checkTime(KerberosTicket kt, long timeValue) {
if (kt.getAuthTime().getTime() != timeValue) {
throw new RuntimeException("authTime check fails!");
}
if (kt.getStartTime().getTime() != timeValue) {
throw new RuntimeException("startTime check fails!");
}
if (kt.getEndTime().getTime() != timeValue) {
throw new RuntimeException("endTime check fails!");
}
if (kt.getRenewTill().getTime() != timeValue) {
throw new RuntimeException("renewTill check fails!");
}
}
private static void testDateImmutability(KerberosTicket t, long origTime)
throws Exception {
// test the constructor
System.out.println("Testing constructor...");
checkTime(t, origTime);
// test the getAuth/Start/EndTime() & getRenewTill() methods
System.out.println("Testing getAuth/Start/EndTime() & getRenewTill()...");
t.getAuthTime().setTime(0);
t.getStartTime().setTime(0);
t.getEndTime().setTime(0);
t.getRenewTill().setTime(0);
checkTime(t, origTime);
System.out.println("DateImmutability Test Passed");
}
private static void checkEqualsAndHashCode(byte[] bytes, KerberosTicket t)
throws IOException, ClassNotFoundException {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
KerberosTicket deserializedTicket = (KerberosTicket)
(new ObjectInputStream(bais).readObject());
if (!deserializedTicket.equals(t)) {
throw new RuntimeException("equals() check fails!");
}
if (deserializedTicket.hashCode() != t.hashCode()) {
throw new RuntimeException("hashCode() check fails!");
}
}
private static void testS11nCompatibility(KerberosTicket t)
throws Exception {
System.out.println("Testing against KerberosTicket from JDK6...");
byte[] serializedBytes =
new BASE64Decoder().decodeBuffer(serializedKerberosTix);
checkEqualsAndHashCode(serializedBytes, t);
System.out.println("Testing against KerberosTicket from current rel...");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos).writeObject(t);
checkEqualsAndHashCode(baos.toByteArray(), t);
System.out.println("S11nCompatibility Test Passed");
}
}
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6675606
* @summary javax.security.auth.login.Configuration does not recognize path with spaces
*/
import java.io.File;
import java.io.FileOutputStream;
import javax.security.auth.login.*;
import java.net.URI;
import java.security.URIParameter;
public class ConfigFileWithBlank {
public static void main(String[] args) throws Exception {
File f = new File("a b c");
FileOutputStream fos = new FileOutputStream(f);
fos.write("".getBytes());
fos.close();
System.err.println(f.toURI());
try {
Configuration.getInstance("JavaLoginConfig", new URIParameter(f.toURI()));
} finally {
f.delete();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册