/*
* 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 4892365
* @summary Ensure the crypto permission check on cipher algorithms
* with restricted parameter values are correctly enforced.
* @author Valerie Peng
*/
public class RC2PermCheck {
// skip this test for unlimited jurisdiction policy files
return;
}
// Currently, RC2 is the only algorithm whose parameter values
// are restricted
int numOfTests = 6;
boolean result = true;
// test set#1: init with no parameter supplied
for (int i = 0; i < numOfTests; i++) {
try {
switch (i) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
}
result = false;
continue;
}
}
// test set#2: init with parameter within limit
numOfTests = 4;
for (int i = 0; i < numOfTests; i++) {
try {
switch (i) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
}
result = false;
}
}
// test set#3: init with parameter over limit
for (int i = 0; i < numOfTests; i++) {
try {
switch (i) {
case 0:
result = false;
break;
case 1:
result = false;
break;
case 2:
result = false;
break;
case 3:
result = false;
break;
}
} catch (InvalidAlgorithmParameterException iape) {
// expected exception thrown; proceed to next test
continue;
}
}
if (result) {
} else {
throw new Exception("One or more test failed!");
}
}
}