use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class GetSupportedIdTypes method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
SSOToken adminSSOToken = getAdminSSOToken();
IOutput outputWriter = getOutputWriter();
String realm = getStringOptionValue(IArgument.REALM_NAME);
String[] params = { realm };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_GET_SUPPORTED_IDTYPES", params);
try {
AMIdentityRepository amir = new AMIdentityRepository(adminSSOToken, realm);
Set supportedIdTypes = amir.getSupportedIdTypes();
if ((supportedIdTypes != null) && !supportedIdTypes.isEmpty()) {
String msg = getResourceString("supported-type-result");
String[] arg = { "" };
for (Iterator i = supportedIdTypes.iterator(); i.hasNext(); ) {
arg[0] = ((IdType) i.next()).getName();
outputWriter.printlnMessage(MessageFormat.format(msg, (Object[]) arg));
}
} else {
outputWriter.printlnMessage(getResourceString("no-supported-idtype"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_GET_SUPPORTED_IDTYPES", params);
} catch (IdRepoException e) {
String[] args = { realm, e.getMessage() };
debugError("GetSupportedIdTypes.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_SUPPORTED_IDTYPES", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { realm, e.getMessage() };
debugError("GetSupportedIdTypes.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_SUPPORTED_IDTYPES", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class ModifyService method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
SSOToken adminSSOToken = getAdminSSOToken();
IOutput outputWriter = getOutputWriter();
String realm = getStringOptionValue(IArgument.REALM_NAME);
String idName = getStringOptionValue(ARGUMENT_ID_NAME);
String type = getStringOptionValue(ARGUMENT_ID_TYPE);
String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
IdType idType = convert2IdType(type);
String datafile = getStringOptionValue(IArgument.DATA_FILE);
List attrValues = rc.getOption(IArgument.ATTRIBUTE_VALUES);
if ((datafile == null) && (attrValues == null)) {
throw new CLIException(getResourceString("missing-attributevalues"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
}
Map attributeValues = AttributeValues.parse(getCommandManager(), datafile, attrValues);
String[] params = { realm, type, idName, serviceName };
try {
AMIdentityRepository amir = new AMIdentityRepository(adminSSOToken, realm);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_IDREPO_MODIFY_SERVICE", params);
AMIdentity amid = new AMIdentity(adminSSOToken, idName, idType, realm, null);
amid.modifyService(serviceName, attributeValues);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("idrepo-modify-service-succeed"), (Object[]) params));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_IDREPO_MODIFY_SERVICE", params);
} catch (IdRepoException e) {
String[] args = { realm, type, idName, serviceName, e.getMessage() };
debugError("ModifyService.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_IDREPO_MODIFY_SERVICE", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { realm, type, idName, serviceName, e.getMessage() };
debugError("ModifyService.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_IDREPO_MODIFY_SERVICE", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class RemoveMember method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
SSOToken adminSSOToken = getAdminSSOToken();
IOutput outputWriter = getOutputWriter();
String realm = getStringOptionValue(IArgument.REALM_NAME);
String idName = getStringOptionValue(ARGUMENT_ID_NAME);
String type = getStringOptionValue(ARGUMENT_ID_TYPE);
IdType idType = convert2IdType(type);
String memberIdName = getStringOptionValue(ARGUMENT_MEMBER_IDNAME);
String memberType = getStringOptionValue(ARGUMENT_MEMBER_IDTYPE);
IdType memberIdType = convert2IdType(memberType);
String[] params = { realm, type, idName, memberIdName, memberType };
try {
AMIdentityRepository amir = new AMIdentityRepository(adminSSOToken, realm);
Set memberOfs = memberIdType.canBeMemberOf();
if (!memberOfs.contains(idType)) {
String[] args = { type, memberType };
throw new CLIException(MessageFormat.format(getResourceString("idrepo-cannot-be-member"), (Object[]) args), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_IDREPO_REMOVE_MEMBER", params);
AMIdentity amid = new AMIdentity(adminSSOToken, idName, idType, realm, null);
AMIdentity memberAmid = new AMIdentity(adminSSOToken, memberIdName, memberIdType, realm, null);
String[] args = { memberIdName, idName };
amid.removeMember(memberAmid);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("idrepo-get-removemember-succeed"), (Object[]) args));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_IDREPO_REMOVE_MEMBER", params);
} catch (IdRepoException e) {
String[] args = { realm, type, idName, memberIdName, memberType, e.getMessage() };
debugError("RemoveMember.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_IDREPO_REMOVE_MEMBER", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { realm, type, idName, memberIdName, memberType, e.getMessage() };
debugError("RemoveMember.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_IDREPO_REMOVE_MEMBER", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class SetConfigurations method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
@Override
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
String datafile = getStringOptionValue(IArgument.DATA_FILE);
List attrValues = rc.getOption(IArgument.ATTRIBUTE_VALUES);
if ((datafile == null) && (attrValues == null)) {
throw new CLIException(getResourceString("missing-attributevalues"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
}
Map<String, Set<String>> attributeValues = AttributeValues.parse(getCommandManager(), datafile, attrValues);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_ENTITLEMENT_SVC", null);
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(EntitlementService.SERVICE_NAME, getAdminSSOToken());
validateData(attributeValues, ssm);
ServiceSchema gss = ssm.getGlobalSchema();
gss.setAttributeDefaults(attributeValues);
getOutputWriter().printlnMessage(getResourceString("set-entitlement-config-succeeded"));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_MODIFY_ENTITLEMENT_SVC", null);
} catch (SMSException e) {
String[] paramExs = { e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_MODIFY_ENTITLEMENT_SVC", paramExs);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] paramExs = { e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_MODIFY_ENTITLEMENT_SVC", paramExs);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (CLIException e) {
String[] paramExs = { e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_MODIFY_ENTITLEMENT_SVC", paramExs);
throw e;
}
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class DelegationConfig method hasPermission.
public boolean hasPermission(String realmName, String serviceName, String action, HttpServletRequest req, String viewbeanClassName) {
boolean hasPermission = false;
try {
SSOToken ssoToken = AMAuthUtils.getSSOToken(req);
hasPermission = hasPermission(realmName, serviceName, action, ssoToken, viewbeanClassName);
} catch (SSOException e) {
AMModelBase.debug.warning("AccessControlModelImpl.<init>", e);
}
return hasPermission;
}
Aggregations