Package com.adobe.cq.testing.client
Class SecurityClient
- java.lang.Object
-
- org.apache.sling.testing.clients.AbstractSlingClient
-
- org.apache.sling.testing.clients.SlingClient
-
- com.adobe.cq.testing.client.CQClient
-
- com.adobe.cq.testing.client.SecurityClient
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.http.client.HttpClient
- Direct Known Subclasses:
CQSecurityClient
public class SecurityClient extends CQClient
Client for managing authorizables, such as users or groups
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adobe.cq.testing.client.CQClient
CQClient.Builder, CQClient.InternalBuilder<T extends CQClient>
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
ADMIN_URL
protected static String
LOGIN_URL
-
Fields inherited from class com.adobe.cq.testing.client.CQClient
LOG, STATISTICS_ROOT, wcmCommands
-
-
Constructor Summary
Constructors Constructor Description SecurityClient(URI serverUrl, String user, String password)
SecurityClient(org.apache.http.impl.client.CloseableHttpClient http, org.apache.sling.testing.clients.SlingClientConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Group
createGroup(String groupId, int... expectedStatus)
Creates a new group.Group
createGroup(String groupId, Group[] assignedGroups, int... expectedStatus)
Creates a new group and assigns him to a list of givenAuthorizable
s.Group
createGroup(String groupId, String intermediatePath, int... expectedStatus)
Creates a new group.Group
createGroup(String groupId, String intermediatePath, String givenName, String aboutMe, Group[] assignedGroups, int... expectedStatus)
Creates a new group and assigns him to a list of givenAuthorizable
s.User
createUser(String userId, int... expectedStatus)
Creates a new user with password the same as userId.User
createUser(String userId, String intermediatePath, int... expectedStatus)
Creates a new user with password the same as userId in a defined root path.<T extends Group>
UsercreateUser(String userId, String password, String intermediatePath, Map<String,String> profileMap, boolean waitForIndexing, T[] assignedGroups, int... expectedStatus)
Deprecated.waitForIndexing is not used anymore and it's ignored.<T extends Group>
UsercreateUser(String userId, String password, String intermediatePath, Map<String,String> profileMap, T[] assignedGroups, int... expectedStatus)
Creates a new user with aProfile
and assigns him to a list of givenAuthorizable
s.<T extends Group>
UsercreateUser(String userId, String password, T[] assignedGroups, int... expectedStatus)
Creates a new user and assigns him to a list of givenAuthorizable
s.void
deleteAuthorizables(Authorizable[] authorizables, int... expectedStatus)
Delete a list of authorizables.String
getAdminUrl()
URL for Security AdminString
getLoginTokenCookie(int... expectedStatus)
Get the login token cookie to authenticate future requests.String
getLoginUrl()
Get the login pageAuthorizableManager
getManager()
GetAuthorizableManager
to get and createAuthorizable
s: User / Groups-
Methods inherited from class com.adobe.cq.testing.client.CQClient
copyLanguages, copyPage, createPage, createPageWithRetry, createVersion, deletePage, deletePageWithRetry, getAuthorSitesPage, lockPage, movePage, movePage, pageExists, pageExistsWithRetry, pageExistsWithRetry, resetPageStatistics, restoreTree, restoreVersion, rolloutPage, searchAndReplaceInPages, searchInPages, setPageProperties, setPageProperty, setPagePropertyImage, unlockPage, uploadFileCQStyle
-
Methods inherited from class org.apache.sling.testing.clients.SlingClient
createFolder, createNode, createNodeRecursive, deletePath, doGetJson, endImpersonation, exists, getJsonNode, getJsonNode, getNodeNameFromPath, getParentPath, getUser, getUUId, getUUID, impersonate, importContent, importContent, importJson, move, setPropertiesString, setPropertyString, setPropertyStringArray, upload, waitExists, waitUntilExists
-
Methods inherited from class org.apache.sling.testing.clients.AbstractSlingClient
adaptTo, addValue, close, doDelete, doGet, doGet, doGet, doHead, doPatch, doPost, doPost, doPut, doRawRequest, doRequest, doStreamGet, doStreamPost, doStreamRequest, execute, execute, execute, execute, execute, execute, execute, execute, getClientId, getConnectionManager, getCookieStore, getCredentialsProvider, getParams, getPassword, getPath, getPath, getUrl, getUrl, getUrl, getValue, getValues, hasValue
-
-
-
-
Field Detail
-
LOGIN_URL
protected static final String LOGIN_URL
- See Also:
- Constant Field Values
-
ADMIN_URL
protected static final String ADMIN_URL
- See Also:
- Constant Field Values
-
-
Method Detail
-
getLoginUrl
public String getLoginUrl()
Get the login page- Returns:
- the login url
-
getAdminUrl
public String getAdminUrl()
URL for Security Admin- Returns:
- the admin url
-
getManager
public AuthorizableManager getManager()
GetAuthorizableManager
to get and createAuthorizable
s: User / Groups- Returns:
AuthorizableManager
-
deleteAuthorizables
public void deleteAuthorizables(Authorizable[] authorizables, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
Delete a list of authorizables.- Parameters:
authorizables
-Authorizable
expectedStatus
- list of allowed HTTP Status to be returned- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failed
-
createUser
public User createUser(String userId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
Creates a new user with password the same as userId.- Parameters:
userId
- the user ID for the new user.expectedStatus
- list of allowed HTTP Status to be returned- Returns:
User
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failedInterruptedException
- to mark this method as "waiting"
-
createUser
public User createUser(String userId, String intermediatePath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
Creates a new user with password the same as userId in a defined root path.- Parameters:
userId
- the user ID for the new user.intermediatePath
- the root path user will be created.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
User
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
createUser
public <T extends Group> User createUser(String userId, String password, T[] assignedGroups, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
Creates a new user and assigns him to a list of givenAuthorizable
s.- Type Parameters:
T
- group type- Parameters:
userId
- the user ID for the new user.password
- the password to be assigned.assignedGroups
- groups the user will be assigned to asGroup
-Array.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
User
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
createUser
public <T extends Group> User createUser(String userId, String password, String intermediatePath, Map<String,String> profileMap, T[] assignedGroups, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
Creates a new user with aProfile
and assigns him to a list of givenAuthorizable
s.- Type Parameters:
T
- group type- Parameters:
userId
- the user ID for the new user.password
- the password to be assigned.intermediatePath
- the root path user will be created.profileMap
- profile properties to be set for the new user.assignedGroups
- groups the user will be assigned to asAuthorizable
-Array.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
User
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/ response cycleInterruptedException
- to mark this method as "waiting"
-
createUser
@Deprecated public <T extends Group> User createUser(String userId, String password, String intermediatePath, Map<String,String> profileMap, boolean waitForIndexing, T[] assignedGroups, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
Deprecated.waitForIndexing is not used anymore and it's ignored. UsecreateGroup(String, String, String, String, Group[], int...)
.Creates a new user with aProfile
and assigns him to a list of givenAuthorizable
s.- Type Parameters:
T
- group type- Parameters:
userId
- the user ID for the new user.password
- the password to be assigned.intermediatePath
- the root path user will be created.profileMap
- profile properties to be set for the new user.waitForIndexing
- whether or not to wait for indexing to be completed after creating the userassignedGroups
- groups the user will be assigned to asAuthorizable
-Array.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
User
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/ response cycleInterruptedException
- to mark this method as "waiting"
-
createGroup
public Group createGroup(String groupId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
Creates a new group.- Parameters:
groupId
- the group ID for the new group.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
createGroup
public Group createGroup(String groupId, String intermediatePath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
Creates a new group.- Parameters:
groupId
- the group ID for the new group.intermediatePath
- the root path user will be created.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
createGroup
public Group createGroup(String groupId, Group[] assignedGroups, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
Creates a new group and assigns him to a list of givenAuthorizable
s.- Parameters:
groupId
- the group ID for the new group.assignedGroups
- groups the user will be assigned to asAuthorizable
-Array.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
createGroup
public Group createGroup(String groupId, String intermediatePath, String givenName, String aboutMe, Group[] assignedGroups, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
Creates a new group and assigns him to a list of givenAuthorizable
s.- Parameters:
groupId
- the group ID for the new group.intermediatePath
- the root path user will be created.givenName
- the name of the group.aboutMe
- description of the group.assignedGroups
- groups the user will be assigned toexpectedStatus
- list of allowed HTTP Status to be returned.- Returns:
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
getLoginTokenCookie
public String getLoginTokenCookie(int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
Get the login token cookie to authenticate future requests.- Parameters:
expectedStatus
- list of allowed HTTP Status to be returned. If not set, http status 302 (REDIRECT (to the requested resource)) is assumed.- Returns:
- the login-token cookie to be used for further requests.
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycle
-
-