Class AuthorizableManager
- java.lang.Object
-
- com.adobe.cq.testing.client.security.AuthorizableManager
-
- Direct Known Subclasses:
CQAuthorizableManager
public class AuthorizableManager extends Object
Manager for getting and creatingAuthorizables
-
-
Field Summary
Fields Modifier and Type Field Description static StringAUTHORIZABLE_POST_PATHPOST path for Authorizablestatic StringAUTHORIZABLESstatic StringAUTHORIZABLES_PATHPath to JSON representing the authorizablesprotected SecurityClientclientThe security granite HTTP client
-
Constructor Summary
Constructors Constructor Description AuthorizableManager(T client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends SecurityClient>
Authorizablecreate(T client, Class<? extends AbstractAuthorizable> authorizableClass, String authorizableId, org.apache.sling.testing.clients.util.FormEntityBuilder formParameters, int... expectedStatus)Creates a newAuthorizable.org.apache.sling.testing.clients.SlingHttpResponsedoPost(org.apache.sling.testing.clients.util.FormEntityBuilder formParameters, int... expectedStatus)POST request to AuthorizableServlet.protected <T extends AbstractAuthorizable>
TgetAuthorizable(Class<T> authorizableClass, String authorizableId)Get an instance of any class extendingAbstractAuthorizablewith given ID.List<Authorizable>getAuthorizables(String query)Get all authorizables from Json as list ofAuthorizables.StringgetAuthorizablesJson(String query)Get all authorizables as json String.GroupgetGroup(String groupId)Get an existing group object from the id.GroupgetGroupAdministrators()Get built-in group "administrators"GroupgetGroupContributor()Get built-in group "contributor"GroupgetGroupEveryone()Get built-in group "everyone"GroupgetGroupUserAdministrators()Get built-in group "user-administrators"UsergetUser(String userId)Get an existing user object from the id.
-
-
-
Field Detail
-
AUTHORIZABLE_POST_PATH
public static final String AUTHORIZABLE_POST_PATH
POST path for Authorizable- See Also:
- Constant Field Values
-
AUTHORIZABLES_PATH
public static final String AUTHORIZABLES_PATH
Path to JSON representing the authorizables- See Also:
- Constant Field Values
-
AUTHORIZABLES
public static final String AUTHORIZABLES
- See Also:
- Constant Field Values
-
client
protected final SecurityClient client
The security granite HTTP client
-
-
Method Detail
-
getGroupAdministrators
public Group getGroupAdministrators() throws org.apache.sling.testing.clients.ClientException
Get built-in group "administrators"- Returns:
- administrators'
Group - Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
getGroupContributor
public Group getGroupContributor() throws org.apache.sling.testing.clients.ClientException
Get built-in group "contributor"- Returns:
- contributor'
Group - Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
getGroupEveryone
public Group getGroupEveryone() throws org.apache.sling.testing.clients.ClientException
Get built-in group "everyone"- Returns:
- everyone'
Group - Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
getGroupUserAdministrators
public Group getGroupUserAdministrators() throws org.apache.sling.testing.clients.ClientException
Get built-in group "user-administrators"- Returns:
- user-administrators'
Group - Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
getUser
public User getUser(String userId) throws org.apache.sling.testing.clients.ClientException
Get an existing user object from the id.- Parameters:
userId- the user ID.- Returns:
User- Throws:
org.apache.sling.testing.clients.ClientException- If something fails during request/response cycle
-
getGroup
public Group getGroup(String groupId) throws org.apache.sling.testing.clients.ClientException
Get an existing group object from the id.- Parameters:
groupId- the group ID.- Returns:
Group- Throws:
org.apache.sling.testing.clients.ClientException- If something fails during request/response cycle
-
create
public <T extends SecurityClient> Authorizable create(T client, Class<? extends AbstractAuthorizable> authorizableClass, String authorizableId, org.apache.sling.testing.clients.util.FormEntityBuilder formParameters, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
Creates a newAuthorizable.- Type Parameters:
T- client type- Parameters:
client- any class implementing theSecurityClient.authorizableClass- Authorizable class to be created.authorizableId- the ID for the new authorizable.formParameters- form parameters.expectedStatus- list of allowed HTTP Status to be returned. If not set, http status 201 (CREATED) is assumed.- Returns:
- created
Authorizable - Throws:
org.apache.sling.testing.clients.ClientException- If something fails during request/response cycle
-
getAuthorizable
protected <T extends AbstractAuthorizable> T getAuthorizable(Class<T> authorizableClass, String authorizableId) throws org.apache.sling.testing.clients.ClientException
Get an instance of any class extendingAbstractAuthorizablewith given ID. Home path for authorizable is assumed in default structure.- Type Parameters:
T- any class extendingAbstractAuthorizable- Parameters:
authorizableClass- any class extending theAbstractAuthorizableauthorizableId- the authorizable ID.- Returns:
- the client
- Throws:
org.apache.sling.testing.clients.ClientException- if client can't be instantiated
-
getAuthorizables
public List<Authorizable> getAuthorizables(String query) throws org.apache.sling.testing.clients.ClientException
Get all authorizables from Json as list ofAuthorizables.- Parameters:
query- search query for authorizables- Returns:
- authorizables as
Authorizable - Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
getAuthorizablesJson
public String getAuthorizablesJson(String query) throws org.apache.sling.testing.clients.ClientException
Get all authorizables as json String.- Parameters:
query- search query for authorizables- Returns:
- authorizables as JSON String
- Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
doPost
public org.apache.sling.testing.clients.SlingHttpResponse doPost(org.apache.sling.testing.clients.util.FormEntityBuilder formParameters, int... expectedStatus) throws org.apache.sling.testing.clients.ClientExceptionPOST request to AuthorizableServlet.- Parameters:
formParameters- form parameters.expectedStatus- list of allowed HTTP Status to be returned.- Returns:
- executed request
- Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
-