Class PolicyImport
- java.lang.Object
-
- com.sun.identity.cli.CLICommandBase
-
- com.sun.identity.cli.AuthenticatedCommand
-
- org.forgerock.openam.cli.entitlement.PolicyImport
-
- All Implemented Interfaces:
CLICommand
public final class PolicyImport extends AuthenticatedCommand
Given a json file containing the policy model export, attempts to create or update policy model resources.- Since:
- 14.0.0
-
-
Field Summary
-
Fields inherited from class com.sun.identity.cli.AuthenticatedCommand
ssoToken
-
-
Constructor Summary
Constructors Constructor Description PolicyImport(org.forgerock.http.Client client)Constructs a new json resource command.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandleRequest(RequestContext request)Authenticates the administrator.voidhandleResourceRequest(RequestContext request)Handles the passed request.protected StringobjectToJsonString(Object object)Given an object, converts it to a well formatted json representation.protected org.forgerock.json.JsonValuereadJsonFile(String jsonFile)Reads in a json file.protected org.forgerock.http.protocol.ResponsesendRequest(org.forgerock.http.protocol.Request request, String endpoint)Sends the given request to the passed endpoint.protected voidwriteJsonFile(org.forgerock.json.JsonValue jsonValue, String jsonFile)Writes out json to file.-
Methods inherited from class com.sun.identity.cli.AuthenticatedCommand
getAdminID, getAdminPassword, getAdminSSOToken, ldapLogin, processFileAttributes, writeLog
-
Methods inherited from class com.sun.identity.cli.CLICommandBase
debugError, debugError, debugMessage, debugWarning, getCommandManager, getOutputWriter, getResourceString, getStringOptionValue, getStringOptionValue, isOptionSet, isVerbose, tokenize
-
-
-
-
Method Detail
-
handleResourceRequest
public void handleResourceRequest(RequestContext request) throws CLIException
Handles the passed request.- Parameters:
request- the command request- Throws:
CLIException- should some error occur
-
handleRequest
public final void handleRequest(RequestContext request) throws CLIException
Description copied from class:AuthenticatedCommandAuthenticates the administrator. Dervived classes needs to call this method from the dervived method,handleRequest(RequestContext rc). Override this method to get user name and passowrd.- Specified by:
handleRequestin interfaceCLICommand- Overrides:
handleRequestin classAuthenticatedCommand- Parameters:
request- Request Context.- Throws:
CLIException- if authentication fails.
-
sendRequest
protected final org.forgerock.http.protocol.Response sendRequest(org.forgerock.http.protocol.Request request, String endpoint) throws CLIExceptionSends the given request to the passed endpoint.- Parameters:
request- http requestendpoint- endpoint- Returns:
- http response
- Throws:
CLIException- should some error occur
-
readJsonFile
protected final org.forgerock.json.JsonValue readJsonFile(String jsonFile) throws CLIException
Reads in a json file.- Parameters:
jsonFile- the path to the json file- Returns:
- the json representation
- Throws:
CLIException- should some error occur
-
writeJsonFile
protected final void writeJsonFile(org.forgerock.json.JsonValue jsonValue, String jsonFile) throws CLIExceptionWrites out json to file.- Parameters:
jsonValue- the json to be written outjsonFile- the path to the json file- Throws:
CLIException- should some error occur
-
objectToJsonString
protected final String objectToJsonString(Object object) throws CLIException
Given an object, converts it to a well formatted json representation.- Parameters:
object- object- Returns:
- json representation
- Throws:
CLIException- should some error occur during the transformation to json
-
-