/*
* 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 5037004
* @summary Frivolous ClassCastExceptions thrown by SubjectCodeSource.implies
*
* Note: if you want to see the java.security.debug output,
* you can not simply set the system property.
* you must run this test by hand and pass -Djava.security.debug=...
*/
public class Comparator {
new UnixPrincipal("1") };
new X500Principal("cn=2"),
new NTUserPrincipal("2") };
new UnixPrincipal("1"),
new X500Principal("cn=2"),
new NTUserPrincipal("2") };
new UnixPrincipal("1"),
new NTUserPrincipal("4") };
new UnixPrincipal("1"),
new X500Principal("cn=2"),
new NTUserPrincipal("2"),
new X500Principal("cn=x500") };
new UnixPrincipal("1"),
new NTUserPrincipal("4"),
new X500Principal("cn=x500") };
new SolarisPrincipal("bad") };
}
return true;
}
return false;
}
}
}
return true;
}
return false;
}
}
}
return false;
}
}
int testnum = 1;
// in case we run standalone
policyDir = ".";
}
// do principal-only tests
"=" +
"Comparator.Principal.Policy");
// do comparator-only tests
"=" +
"Comparator.Comparator.Policy");
policy = new PolicyFile();
// combined principal/comparator tests
"=" +
"Comparator.Combined.Policy");
policy = new PolicyFile();
}
// this principal is not in policy - should not match any policy grants
}
testnum++;
// this principal is not in policy - should not match any policy grants
}
testnum++;
// this principal is not in policy - should not match any policy grants
}
testnum++;
return testnum;
}
// security check against one principal should pass
}
testnum++;
// should not match BAR grant entry in policy
}
testnum++;
// security check against two principals should pass
}
testnum++;
// should not match FOOBAR grant entry in policy
}
testnum++;
// should not match FOOBAR grant entry in policy
}
testnum++;
return testnum;
}
// security check against one comparator should pass
}
testnum++;
// should not match BAR grant entry in policy
}
testnum++;
// security check against two comparators should pass for FOO
}
testnum++;
// security check against two comparators should pass for BAR
}
testnum++;
// security check should fail against FOOBAR
}
testnum++;
return testnum;
}
// security check against principal followed by comparator should pass
}
testnum++;
// should not match BAR grant entry in policy
}
testnum++;
// security check against comparator followed by principal should pass
}
testnum++;
// should not match FOO grant entry in policy
}
testnum++;
// security check against principal-principal-comparator should pass
}
testnum++;
// should not match WORLD grant entry in policy
}
testnum++;
// security check against principal-principal-comparator should pass
}
testnum++;
// should not match HELLO grant entry in policy
}
testnum++;
return testnum;
}
}