AuthenticatedCommand.java revision a29d50079096351c50b4dca5a885101c62b55e57
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Portions Copyrighted 2011-2016 ForgeRock AS.
*/
/**
* This is the base class for all commands that require a user to be
* authenticated in order to execute a command.
*/
public abstract class AuthenticatedCommand extends CLICommandBase {
// One-off case of an existing properties that makes use of the -file suffix in an existing property
// => don't apply the file reference rule in this case.
private String adminPassword;
/**
* Authenticates the administrator. Dervived classes needs to
* call this method from the dervived method,
* <code>handleRequest(RequestContext rc)</code>.
* Override this method to get user name and passowrd.
*
* @param rc Request Context.
* @throws CLIException if authentication fails.
*/
throws CLIException
{
super.handleRequest(rc);
adminPassword = getPassword();
}
}
private String getPassword()
throws CLIException
{
fileName, true);
new DecodeAction(password));
if (decodedPwd != null) {
}
return password;
}
throws CLIException {
try {
InputStreamReader(p.getInputStream()));
if (s != null) {
if (idx != -1) {
"error-message-password-file-not-readonly");
}
}
}
} catch (IOException e) {
//ignore, this should not happen because we are able to
// read the file in getPassword method.
}
}
}
protected String getAdminPassword() {
return adminPassword;
}
protected String getAdminID() {
return adminID;
}
protected SSOToken getAdminSSOToken() {
return ssoToken;
}
protected void ldapLogin()
throws CLIException
{
getAdminPassword());
} else {
try {
} catch (SSOException e) {
}
}
}
protected void writeLog(
int type,
) throws CLIException {
}
/**
* Post-process any attributes specified for the module instance (either via data file or on the command line) to
* resolve any file references. Any attribute can be specified using a -file suffix on the attribute name. This
* will cause the value to be treated as a file name, and the associated file to be read in (in the platform
* default encoding) and used as the attribute value. The attribute will be renamed to remove the -file suffix
* during this process.
*
* @return the processed attributes with all file references resolved.
* @throws CLIException if a referenced file cannot be read or if an attribute is specified both normally and using
* a -file reference.
*/
protected Map<String, Set<String>> processFileAttributes(Map<String, Set<String>> attrs) throws CLIException {
if (key != null && key.endsWith(FILE_REFERENCE_SUFFIX) && !FILE_REFERENCE_SUFFIX_EXEMPT.contains(key)) {
}
}
}
}
}
}
return result;
}
}