Search in sources :

Example 6 with AuthenticatedUsers

use of org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers in project OpenAM by OpenRock.

the class SingleWildCardEvaluatorTest method setup.

@BeforeClass
public void setup() throws Exception {
    if (!migrated) {
        return;
    }
    PrivilegeManager pm = PrivilegeManager.getInstance("/", adminSubject);
    Map<String, Boolean> actions = new HashMap<String, Boolean>();
    actions.put("GET", Boolean.TRUE);
    Entitlement ent = new Entitlement(ApplicationTypeManager.URL_APPLICATION_TYPE_NAME, URL, actions);
    Privilege privilege = Privilege.getNewInstance();
    privilege.setName(PRIVILEGE_NAME);
    privilege.setEntitlement(ent);
    privilege.setSubject(new AuthenticatedUsers());
    pm.add(privilege);
    Thread.sleep(1000);
}
Also used : HashMap(java.util.HashMap) AuthenticatedUsers(org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers) BeforeClass(org.testng.annotations.BeforeClass)

Example 7 with AuthenticatedUsers

use of org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers in project OpenAM by OpenRock.

the class RestTest method setup.

@BeforeClass
public void setup() throws Exception {
    try {
        PrivilegeManager pm = PrivilegeManager.getInstance(REALM, adminSubject);
        Privilege privilege = Privilege.getNewInstance();
        privilege.setName(PRIVILEGE_NAME);
        Map<String, Boolean> actions = new HashMap<String, Boolean>();
        actions.put("GET", true);
        Entitlement entitlement = new Entitlement(RESOURCE_NAME + "/*", actions);
        privilege.setEntitlement(entitlement);
        EntitlementSubject sbj = new AuthenticatedUsers();
        privilege.setSubject(sbj);
        NumericAttributeCondition cond = new NumericAttributeCondition();
        cond.setAttributeName(ATTR_NAME);
        cond.setOperator(NumericAttributeCondition.Operator.EQUAL);
        cond.setValue(ATTR_VAL);
        privilege.setCondition(cond);
        pm.add(privilege);
        user = IdRepoUtils.createAgent(REALM, AGENT_NAME);
        SSOToken ssoToken = AuthUtils.authenticate(REALM, AGENT_NAME, AGENT_NAME);
        String userTokenId = ssoToken.getTokenID().toString();
        hashedUserTokenId = Hash.hash(userTokenId);
        userTokenIdHeader = RestServiceManager.SSOTOKEN_SUBJECT_PREFIX + RestServiceManager.SUBJECT_DELIMITER + userTokenId;
        String cookieValue = userTokenId;
        if (Boolean.parseBoolean(SystemProperties.get(Constants.AM_COOKIE_ENCODE, "false"))) {
            cookieValue = URLEncoder.encode(userTokenId, "UTF-8");
        }
        cookie = new Cookie(SystemProperties.get(Constants.AM_COOKIE_NAME), cookieValue);
        String serverURL = SystemProperties.getServerInstanceName();
        decisionClient = Client.create().resource(serverURL + "/ws/1/entitlement/decision");
        decisionsClient = Client.create().resource(serverURL + "/ws/1/entitlement/decisions");
        entitlementClient = Client.create().resource(serverURL + "/ws/1/entitlement/entitlement");
        entitlementsClient = Client.create().resource(serverURL + "/ws/1/entitlement/entitlements");
    } catch (Exception e) {
        UnittestLog.logError("RestTest.setup() failed:", e);
        throw e;
    }
}
Also used : Cookie(javax.ws.rs.core.Cookie) SSOToken(com.iplanet.sso.SSOToken) NumericAttributeCondition(com.sun.identity.entitlement.NumericAttributeCondition) HashMap(java.util.HashMap) AuthenticatedUsers(org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers) PrivilegeManager(com.sun.identity.entitlement.PrivilegeManager) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) EntitlementSubject(com.sun.identity.entitlement.EntitlementSubject) Privilege(com.sun.identity.entitlement.Privilege) JSONEntitlement(com.sun.identity.entitlement.JSONEntitlement) Entitlement(com.sun.identity.entitlement.Entitlement) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with AuthenticatedUsers

use of org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers in project OpenAM by OpenRock.

the class ListenerRestTest method setup.

@BeforeClass
public void setup() throws Exception {
    try {
        agent = IdRepoUtils.createAgent(REALM, AGENT_NAME);
        SSOToken ssoToken = AuthUtils.authenticate(REALM, AGENT_NAME, AGENT_NAME);
        String userTokenId = ssoToken.getTokenID().toString();
        hashedTokenId = Hash.hash(userTokenId);
        tokenIdHeader = RestServiceManager.SSOTOKEN_SUBJECT_PREFIX + RestServiceManager.SUBJECT_DELIMITER + userTokenId;
        String cookieValue = userTokenId;
        if (Boolean.parseBoolean(SystemProperties.get(Constants.AM_COOKIE_ENCODE, "false"))) {
            cookieValue = URLEncoder.encode(userTokenId, "UTF-8");
        }
        cookie = new Cookie(SystemProperties.get(Constants.AM_COOKIE_NAME), cookieValue);
        PrivilegeManager pm = PrivilegeManager.getInstance(REALM, adminSubject);
        Privilege privilege = Privilege.getNewInstance();
        privilege.setName(PRIVILEGE_NAME);
        Map<String, Boolean> actions = new HashMap<String, Boolean>();
        actions.put("GET", true);
        Entitlement entitlement = new Entitlement(RESOURCE_NAME + "/*", actions);
        privilege.setEntitlement(entitlement);
        EntitlementSubject sbj = new AuthenticatedUsers();
        privilege.setSubject(sbj);
        pm.add(privilege);
        listenerClient = Client.create().resource(SystemProperties.getServerInstanceName() + "/ws/1/entitlement/listener");
        ENC_NOTIFICATION_URL = ESAPI.encoder().encodeForURL(NOTIFICATION_URL);
    } catch (Exception e) {
        UnittestLog.logError("ListenerRestTest.setup() failed:", e);
        throw e;
    }
}
Also used : Cookie(javax.ws.rs.core.Cookie) EntitlementSubject(com.sun.identity.entitlement.EntitlementSubject) SSOToken(com.iplanet.sso.SSOToken) HashMap(java.util.HashMap) AuthenticatedUsers(org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers) PrivilegeManager(com.sun.identity.entitlement.PrivilegeManager) Privilege(com.sun.identity.entitlement.Privilege) Entitlement(com.sun.identity.entitlement.Entitlement) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) EncodingException(org.owasp.esapi.errors.EncodingException) MalformedURLException(java.net.MalformedURLException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with AuthenticatedUsers

use of org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers in project OpenAM by OpenRock.

the class PrivilegeRestTest method setup.

@BeforeClass
public void setup() throws Exception {
    PrivilegeManager pm = PrivilegeManager.getInstance("/", adminSubject);
    Privilege privilege = Privilege.getNewInstance();
    privilege.setName(PRIVILEGE_NAME);
    privilege.setDescription("desciption");
    Map<String, Boolean> actions = new HashMap<String, Boolean>();
    actions.put("GET", true);
    Entitlement entitlement = new Entitlement(RESOURCE_NAME + "/*", actions);
    privilege.setEntitlement(entitlement);
    EntitlementSubject sbj = new AuthenticatedUsers();
    privilege.setSubject(sbj);
    pm.add(privilege);
    String tokenId = adminToken.getTokenID().toString();
    hashedTokenId = Hash.hash(tokenId);
    tokenIdHeader = RestServiceManager.SSOTOKEN_SUBJECT_PREFIX + RestServiceManager.SUBJECT_DELIMITER + tokenId;
    String cookieValue = tokenId;
    if (Boolean.parseBoolean(SystemProperties.get(Constants.AM_COOKIE_ENCODE, "false"))) {
        cookieValue = URLEncoder.encode(tokenId, "UTF-8");
    }
    cookie = new Cookie(SystemProperties.get(Constants.AM_COOKIE_NAME), cookieValue);
    webClient = Client.create().resource(SystemProperties.getServerInstanceName() + "/ws/1/entitlement/privilege");
}
Also used : EntitlementSubject(com.sun.identity.entitlement.EntitlementSubject) Cookie(javax.ws.rs.core.Cookie) HashMap(java.util.HashMap) AuthenticatedUsers(org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers) PrivilegeManager(com.sun.identity.entitlement.PrivilegeManager) Privilege(com.sun.identity.entitlement.Privilege) Entitlement(com.sun.identity.entitlement.Entitlement) BeforeClass(org.testng.annotations.BeforeClass)

Example 10 with AuthenticatedUsers

use of org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers in project OpenAM by OpenRock.

the class RestPermissionTest method createPrivilege.

private void createPrivilege() throws EntitlementException {
    PrivilegeManager pm = PrivilegeManager.getInstance("/", adminSubject);
    Privilege privilege = Privilege.getNewInstance();
    privilege.setName(PRIVILEGE_NAME);
    privilege.setDescription("desciption");
    Map<String, Boolean> actions = new HashMap<String, Boolean>();
    actions.put("GET", true);
    Entitlement entitlement = new Entitlement(RESOURCE_NAME + "/*", actions);
    privilege.setEntitlement(entitlement);
    EntitlementSubject sbj = new AuthenticatedUsers();
    privilege.setSubject(sbj);
    pm.add(privilege);
}
Also used : EntitlementSubject(com.sun.identity.entitlement.EntitlementSubject) HashMap(java.util.HashMap) AuthenticatedUsers(org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers) PrivilegeManager(com.sun.identity.entitlement.PrivilegeManager) Privilege(com.sun.identity.entitlement.Privilege) DelegationPrivilege(com.sun.identity.delegation.DelegationPrivilege) Entitlement(com.sun.identity.entitlement.Entitlement)

Aggregations

AuthenticatedUsers (org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers)10 HashMap (java.util.HashMap)9 Privilege (com.sun.identity.entitlement.Privilege)7 Entitlement (com.sun.identity.entitlement.Entitlement)6 BeforeClass (org.testng.annotations.BeforeClass)6 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)5 PrivilegeManager (com.sun.identity.entitlement.PrivilegeManager)5 SSOToken (com.iplanet.sso.SSOToken)4 Cookie (javax.ws.rs.core.Cookie)4 JSONEntitlement (com.sun.identity.entitlement.JSONEntitlement)2 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)2 SSOException (com.iplanet.sso.SSOException)1 DelegationPrivilege (com.sun.identity.delegation.DelegationPrivilege)1 EntitlementException (com.sun.identity.entitlement.EntitlementException)1 NumericAttributeCondition (com.sun.identity.entitlement.NumericAttributeCondition)1 OpenSSOPrivilege (com.sun.identity.entitlement.opensso.OpenSSOPrivilege)1 SMSException (com.sun.identity.sm.SMSException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 HashSet (java.util.HashSet)1