SupportsParameter.java revision 2362
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 4911081
* @summary verify that Provider.Service.supportsParameter() works
* @author Andreas Sterbenz
*/
public class SupportsParameter {
Provider p = new MyProvider();
Service s;
// none specified, always true
checkSupports(s, null, true);
checkSupports(s, dsaPublicKey, true);
checkSupports(s, dsaPrivateKey, true);
checkSupports(s, myPublicKey, true);
checkSupports(s, myPrivateKey, true);
checkSupports(s, mySecretKey, true);
// DSAPublic/PrivateKey specified as classes
checkSupports(s, dsaPublicKey, true);
checkSupports(s, dsaPrivateKey, true);
checkSupports(s, myPublicKey, false);
checkSupports(s, myPrivateKey, false);
checkSupports(s, mySecretKey, false);
checkSupports(s, dsaPublicKey, true);
checkSupports(s, dsaPrivateKey, true);
checkSupports(s, myPublicKey, false);
checkSupports(s, myPrivateKey, false);
checkSupports(s, mySecretKey, false);
// MyPublic/PrivateKey + DSAPublicKey specified as classes
checkSupports(s, dsaPublicKey, true);
checkSupports(s, dsaPrivateKey, false);
checkSupports(s, myPublicKey, true);
checkSupports(s, myPrivateKey, true);
checkSupports(s, mySecretKey, false);
// MyPublic/PrivateKey + DSAPublicKey specified as classes
checkSupports(s, dsaPublicKey, false);
checkSupports(s, dsaPrivateKey, false);
checkSupports(s, myPublicKey, false);
checkSupports(s, myPrivateKey, false);
checkSupports(s, mySecretKey, true);
checkSupports(s, secretKeySpec, true);
}
if (s.supportsParameter(key) != r) {
throw new Exception("Result mismatch");
}
}
private static class MyProvider extends Provider {
MyProvider() {
super("MyProvider", 1.0d, "MyProvider");
put("Signature.DSA SupportedKeyClasses",
"java.security.interfaces.DSAPublicKey" +
"|java.security.interfaces.DSAPrivateKey");
put("Signature.DSA3 SupportedKeyClasses",
"SupportsParameter$MyPrivateKey" +
"|SupportsParameter$MyPublicKey" +
"|java.security.interfaces.DSAPublicKey");
}
}
public byte[] getEncoded() { return null; }
}
}
}