use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.
the class InstFinderStore method extractInstanceFinderValues.
private Map extractInstanceFinderValues(String key, String instanceName, ArrayList mapKeys) throws InstallException {
Map iFinderValues = new TreeMap();
StringTokenizer st = new StringTokenizer(key, STR_IS_LOOK_UP_KEY_FIELD_SEP);
int count = mapKeys.size();
if (count != st.countTokens()) {
Debug.log("InstFinderStore.extractInstanceFinderValues(): " + "Error - size of mapKeys and number of tokens are not same. " + "key = " + key + ", mapKeys = " + mapKeys.toString());
Object[] args = { instanceName };
LocalizedMessage message = LocalizedMessage.get(LOC_IS_ERR_EXTRACT_IFINDER_DATA);
throw new InstallException(message);
}
for (int i = 0; i < count; i++) {
String mapKey = (String) mapKeys.get(i);
iFinderValues.put(mapKey, st.nextElement());
}
return iFinderValues;
}
use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.
the class NetworkValidator method isLocalHost.
/**
* Checks if the host name is local
*
* @param host
* @param props
* @param state
*
* @return ValidationResult
*
*/
public ValidationResult isLocalHost(String host, Map props, IStateAccess state) {
ValidationResultStatus validRes = ValidationResultStatus.STATUS_FAILED;
LocalizedMessage returnMessage = null;
try {
if ((host != null) && (host.length() > 0)) {
StringTokenizer st = new StringTokenizer(host, ".");
String hostname = st.nextToken();
if (hostname != null) {
String localHost = InetAddress.getLocalHost().getHostName();
if (hostname.equals(localHost)) {
validRes = ValidationResultStatus.STATUS_SUCCESS;
}
}
}
} catch (Exception ex) {
Debug.log("NetworkValidator.isLocalHost(...) threw exception : " + ex);
}
if (validRes.getIntValue() == ValidationResultStatus.INT_STATUS_FAILED) {
returnMessage = LocalizedMessage.get(LOC_VA_WRN_IN_VAL_LOCAL_HOST, new Object[] { host });
}
Debug.log("NetworkValidator : Is Host : " + host + " local ? " + validRes.isSuccessful());
return new ValidationResult(validRes, null, returnMessage);
}
use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.
the class PasswordValidator method isPasswordValid.
public ValidationResult isPasswordValid(String passfileName, Map props, IStateAccess state) {
ValidationResultStatus validRes = ValidationResultStatus.STATUS_FAILED;
LocalizedMessage returnMessage = null;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(passfileName));
String line;
int lineCount = 0;
while ((line = br.readLine()) != null) {
if (lineCount == 0) {
lineCount++;
int passLen = line.length();
String minSize = (String) props.get(STR_VAL_MIN_DIGITS);
String maxSize = (String) props.get(STR_IN_MAX_DIGITS);
if ((minSize != null) && (minSize.length() > 0) && (maxSize != null) && (maxSize.length() > 0)) {
int minLen = Integer.parseInt(minSize);
int maxLen = Integer.parseInt(maxSize);
Debug.log("PasswordValidator : Password : " + " Min length = " + minLen + ", " + "Max Length = " + maxLen);
if (maxLen > minLen) {
if ((passLen >= minLen) && (passLen <= maxLen)) {
validRes = ValidationResultStatus.STATUS_SUCCESS;
} else {
Debug.log("PasswordValidator : Length of " + "password field is invalid");
}
}
} else {
// min and max not present; so if length of pass > 0
// it will be valid pass
validRes = ValidationResultStatus.STATUS_SUCCESS;
Debug.log("Password entry is valid");
}
} else {
Debug.log("PasswordValidator : Invalid password file" + " format, file had more than one line.");
validRes = ValidationResultStatus.STATUS_FAILED;
break;
}
}
} catch (Exception ex) {
Debug.log("PasswordValidator : Failed to read password with ex :", ex);
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
Debug.log("PasswordValidator : Failed to close " + "password file :", ex);
}
}
}
if (validRes.getIntValue() == ValidationResultStatus.INT_STATUS_FAILED) {
returnMessage = LocalizedMessage.get(LOC_VA_WRN_IN_VAL_PASS);
}
Debug.log("PasswordValidator : Is password valid ? " + validRes.isSuccessful());
return new ValidationResult(validRes, null, returnMessage);
}
use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.
the class InstallInteraction method processData.
/*
* Method to be process user input for interactive mode
*
* @pararm userInput User input @param state IStateAccess
*
* @return InteractionResult
*/
public InteractionResult processData(String userInput, IStateAccess state) throws InstallException {
InteractionResultStatus result = null;
InteractionResult interResult = null;
boolean isReq = getInteractionInfo().getRequiredFlag();
String procInput = preProcessUserInput(userInput, state, isReq);
if (procInput == null) {
// Invalid user input
Console.println();
Console.println(LocalizedMessage.get(LOC_IN_WRN_INVALID_USER_INPUT));
} else {
if ((!isReq) && (procInput.equals(STR_IN_EMPTY_STRING))) {
result = InteractionResultStatus.STATUS_CONTINUE;
state.put(getKey(), getNormalizedValue(procInput));
} else {
CumulativeValResult cumRes = processValidators(procInput, state, true);
Debug.log("InstallInteraction.processData: " + cumRes.getWarningMessage());
if (cumRes.getCumValResult()) {
if (cumRes.getWarningMessage() != null) {
Console.println();
Console.println();
Console.println(getWarning());
// Specific warning message
Console.println(cumRes.getWarningMessage());
Console.println();
}
result = InteractionResultStatus.STATUS_CONTINUE;
// Store the user input
state.put(getKey(), getNormalizedValue(procInput));
// Now copy the calc keys only if cum res = true
if (cumRes.getCalcKeyValPairs() != null) {
state.putData(cumRes.getCalcKeyValPairs());
}
} else {
Console.println();
Console.println();
Console.println(getError());
// Specific error message
Console.println(cumRes.getErrorMessage());
Console.println();
}
}
}
LocalizedMessage summaryDesc = null;
if ((result != null) && (result.getIntValue() == InteractionResultStatus.INT_STATUS_CONTINUE)) {
summaryDesc = LocalizedMessage.get(LOC_IN_MESS_SUMMARY_DESC_FORMAT, new Object[] { getSummaryDesc(), procInput });
interResult = new InteractionResult(result, null, summaryDesc);
}
return interResult;
}
use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.
the class InteractionsRunnerBase method runInteraction.
private InteractionResult runInteraction(UserDataInteraction interaction, int index) throws InstallException {
InteractionResult result = null;
// Set the data type for iStateAccess (common or instance data).
setStateAccessDataType(index);
String interactionKey = interaction.getKey();
if (getUserResponseHandler() != null) {
// Silent Mode
String userValue = getUserResponseHandler().getProperty(interactionKey);
if (userValue != null && userValue.trim().length() > 0) {
getUserResponseMap().put(interactionKey, userValue);
}
result = interaction.interactSilent(getStateAccess(), getUserResponseMap());
} else {
/* If there's optional-display attribute for this interaction and
* its value is false, installer just get its default value without
* displaying the interaction.
*/
if (getInstallRunInfo().isCheckDisplay() && !interaction.getInteractionInfo().isDisplay()) {
String strResult = interaction.processDefaultValFromAllSources(getStateAccess());
getStateAccess().put(interaction.getKey(), strResult);
LocalizedMessage summaryDesc = LocalizedMessage.get(InteractionConstants.LOC_IN_MESS_SUMMARY_DESC_FORMAT, new Object[] { interaction.getSummaryDesc(), strResult });
result = new InteractionResult(InteractionResultStatus.STATUS_CONTINUE, null, summaryDesc);
} else {
result = interaction.interact(getStateAccess());
}
}
return result;
}
Aggregations