/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2009 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: PolicyEvaluatorTest.java,v 1.1 2009/08/19 05:41:02 veiming Exp $
*/
/**
*
* @author dennis
*/
public class PolicyEvaluatorTest {
userSSOToken = login();
false, true);
false, true);
false, true);
false, true);
}
try {
} catch (Exception e) {
//ignore
}
adminToken, "/");
}
@Test
throw new Exception("testIsAllowed" +
"http://www.sun.com:8080/private evaluation failed");
}
//negative test
throw new Exception("testIsAllowed" +
"http://www.sun.com:8080/public evaluation failed");
}
}
@Test
throw new Exception("testResourceSelf: " +
"http://www.sun.com:8080/private evaluation failed");
}
throw new Exception("testResourceSelf: " +
"http://www.sun.com:8080/private evaluation failed");
}
}
@Test
throw new Exception("testResourceSubTree: failed");
}
}
/* private SimulationEvaluator createSimulator(
javax.security.auth.Subject subject
) throws Exception {
SimulationEvaluator eval = new SimulationEvaluator(
subject, "iPlanetAMWebAgentService");
eval.setResource("http://www.sun.com:8080/private");
eval.setSubject(subject);
Set<String> policyNames = new HashSet<String>();
policyNames.add(POLICY_NAME1);
policyNames.add(POLICY_NAME2);
policyNames.add(POLICY_NAME3);
eval.setPolicies(policyNames);
return eval;
}
@Test
public void testSimulationSelf() throws Exception {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(
AdminTokenAction.getInstance());
javax.security.auth.Subject subject = createSubject(adminToken);
SimulationEvaluator eval = createSimulator(subject);
eval.evaluate(false);
List<SimulatedResult> details = eval.getSimulatedResults();
for (SimulatedResult r : details) {
String policyName = r.getPrivilegeName();
if (policyName.equals(POLICY_NAME1)) {
if (!r.isApplicable()) {
throw new Exception("testSimulationSelf: failed");
}
} else if (policyName.equals(POLICY_NAME2)) {
if (!r.isApplicable()) {
throw new Exception("testSimulationSelf: failed");
}
} else if (policyName.equals(POLICY_NAME3)) {
if (r.isApplicable()) {
throw new Exception("testSimulationSelf: failed");
}
}
}
List<Entitlement> results = eval.getEntitlements();
for (Entitlement ent : results) {
String res = ent.getResourceName();
if (!res.equals("http://www.sun.com:8080/private")) {
throw new Exception(
"testSimulationSelf: failed, resource name is incorrect.");
}
Map<String, Boolean> actionValues = ent.getActionValues();
validateActionValues(actionValues, "GET", Boolean.TRUE);
validateActionValues(actionValues, "POST", Boolean.FALSE);
}
if (!eval.getMatchedSubjectTypeNames(POLICY_NAME4).isEmpty()) {
throw new Exception("testSimulationSelf: subject match");
}
if (!eval.getMatchedConditionTypeNames(POLICY_NAME4).isEmpty()) {
throw new Exception("testSimulationSelf: condition match");
}
}
*/
private void validateActionValues(
) throws Exception {
throw new Exception(
}
}
/*
@Test
public void testSimulationSubTree() throws Exception {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(
AdminTokenAction.getInstance());
javax.security.auth.Subject subject = createSubject(adminToken);
SimulationEvaluator eval = createSimulator(subject);
eval.evaluate(true);
List<SimulatedResult> details = eval.getSimulatedResults();
for (SimulatedResult r : details) {
System.out.println(r.getEntitlement().getResourceName());
}
List<Entitlement> results = eval.getEntitlements();
for (Entitlement ent : results) {
String res = ent.getResourceName();
if (res.equals(URL_RESOURCE1)) {
Map<String, Boolean> actionValues = ent.getActionValues();
validateActionValues(actionValues, "GET", Boolean.TRUE);
validateActionValues(actionValues, "POST", Boolean.FALSE);
} else if (res.equals(URL_RESOURCE2)) {
Map<String, Boolean> actionValues = ent.getActionValues();
validateActionValues(actionValues, "GET", Boolean.TRUE);
}
}
}*/
{
}
{
}
}
}
}
}
return subject;
}
throws PolicyException{
return subject;
}
throws PolicyException {
return cond;
}
throws IdRepoException, SSOException {
adminToken, "/");
}
throws IdRepoException, SSOException {
adminToken, "/");
}
}
throws Exception {
// get information requested from module
while (lc.hasMoreRequirements()) {
}
}
}
if (callbacks[i] instanceof NameCallback) {
} else if (callbacks[i] instanceof PasswordCallback) {
}
}
}
}