use of com.sun.identity.security.DecodeAction in project OpenAM by OpenRock.
the class CreateServiceConfig method createSubConfig.
static void createSubConfig(SSOToken token, String dn, Node node, ServiceSchemaImpl ss, String orgdn, AMEncryption decryptObj) throws SMSException, SSOException {
// Get service id and priority
String id = XMLUtils.getNodeAttributeValue(node, SMSUtils.SERVICE_ID);
String priority = XMLUtils.getNodeAttributeValue(node, SMSUtils.PRIORITY);
// Get the attributes
Map attrs = getAttributeValuePairs(node);
if ((decryptObj != null) && (attrs != null) && !attrs.isEmpty()) {
for (Iterator i = attrs.keySet().iterator(); i.hasNext(); ) {
String attrName = (String) i.next();
AttributeSchemaImpl as = ss.getAttributeSchema(attrName);
AttributeSchema.Syntax syntax = as.getSyntax();
if (syntax.equals(AttributeSchema.Syntax.ENCRYPTED_PASSWORD) || syntax.equals(AttributeSchema.Syntax.PASSWORD)) {
Set values = (Set) attrs.get(attrName);
if ((values != null) && !values.isEmpty()) {
Set decoded = new HashSet(values.size() * 2);
for (Iterator j = values.iterator(); j.hasNext(); ) {
decoded.add(AccessController.doPrivileged(new DecodeAction((String) j.next(), decryptObj)));
}
attrs.put(attrName, decoded);
}
}
}
}
// Create the LDAP entry
createSubConfigEntry(token, dn, ss, id, priority, attrs, orgdn);
// Check for further sub-configuration
Iterator subConfigs = XMLUtils.getChildNodes(node, SMSUtils.SUB_CONFIG).iterator();
while (subConfigs.hasNext()) {
Node subConfigNode = (Node) subConfigs.next();
String subConfigName = XMLUtils.getNodeAttributeValue(subConfigNode, SMSUtils.NAME);
String subConfigID = XMLUtils.getNodeAttributeValue(subConfigNode, SMSUtils.SERVICE_ID);
if (subConfigID == null) {
subConfigID = subConfigName;
}
createSubConfig(token, ("ou=" + subConfigName + "," + dn), subConfigNode, ss.getSubSchema(subConfigID), orgdn, decryptObj);
}
}
use of com.sun.identity.security.DecodeAction in project OpenAM by OpenRock.
the class AttributeValidator method inheritDefaults.
/**
* This method checks if the attribute name (as given by the
* AttributeSchema) is present, and if missings adds the defaults values.
*
* @param attrs
* A map of the attributes and their values
* @return A map which is a union of the attributes provided and default
* attribute values
*/
Map inheritDefaults(Map attrs) {
Set values = (Set) attrs.get(as.getName());
if (values == null) {
// Inherit the default values
attrs.put(as.getName(), as.getDefaultValues());
} else if (as.getSyntax().equals(AttributeSchema.Syntax.PASSWORD) || as.getSyntax().equals(AttributeSchema.Syntax.ENCRYPTED_PASSWORD)) {
// Decrypt the password
Set vals = new HashSet();
for (Iterator items = values.iterator(); items.hasNext(); ) {
String tString = (String) items.next();
try {
vals.add(AccessController.doPrivileged(new DecodeAction(tString)));
} catch (Throwable e) {
debug.error("AttributeValidator: Unable to decode", e);
vals.add(tString);
}
}
attrs.put(as.getName(), vals);
}
return (attrs);
}
use of com.sun.identity.security.DecodeAction in project OpenAM by OpenRock.
the class AttributeValidator method decodeEncodedAttrs.
/**
* This method checks if attribute schema is of syntax password or
* encoded_password, if so it decrypts the password when it is stored in the
* cache.
*
* @param attrs
* a Map of the attributes and their values
* @return A map which is has replaced encrypted values with decrypted ones.
*/
Map decodeEncodedAttrs(Map attrs) {
Set values = (Set) attrs.get(as.getName());
if (values == null) {
return attrs;
}
if (as.getSyntax().equals(AttributeSchema.Syntax.PASSWORD) || as.getSyntax().equals(AttributeSchema.Syntax.ENCRYPTED_PASSWORD)) {
// Decrypt the password
Set vals = new HashSet();
for (Iterator items = values.iterator(); items.hasNext(); ) {
String tString = (String) items.next();
try {
vals.add(AccessController.doPrivileged(new DecodeAction(tString)));
} catch (Throwable e) {
debug.error("AttributeValidator: Unable to decode", e);
vals.add(tString);
}
}
attrs.put(as.getName(), vals);
}
return (attrs);
}
use of com.sun.identity.security.DecodeAction in project OpenAM by OpenRock.
the class MonitoringUtil method getMonAuthList.
protected static Map<String, String> getMonAuthList(String authFilePath) {
String classMethod = "OpenSSOMonitoringUtil.getMonAuthList: ";
if ((authFilePath == null) || ((authFilePath.trim().length() == 0))) {
debug.error(classMethod + "No authentication file specified.");
return null;
}
// prep for the "%BASE_DIR%/%SERVER_URI%/" style filepath
if (authFilePath.contains("%BASE_DIR%") || (authFilePath.contains("%SERVER_URI%"))) {
String ossoUri = SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR);
ossoUri = ossoUri.replace('\\', '/');
String baseDir = SystemProperties.get(SystemProperties.CONFIG_PATH);
baseDir = baseDir.replace('\\', '/');
if (ossoUri.startsWith("/")) {
ossoUri = ossoUri.substring(1);
}
if (!ossoUri.endsWith("/")) {
ossoUri += "/";
}
if (!baseDir.endsWith("/")) {
baseDir += "/";
}
authFilePath = authFilePath.replaceAll("%BASE_DIR%", baseDir);
authFilePath = authFilePath.replaceAll("%SERVER_URI%", ossoUri);
}
Map<String, String> hm = new HashMap<String, String>();
try {
BufferedReader frdr = new BufferedReader(new FileReader(authFilePath));
String fbuff = null;
while ((fbuff = frdr.readLine()) != null) {
if (fbuff.trim().length() > 0) {
StringTokenizer st = new StringTokenizer(fbuff);
// assume first is userid, second is password, ignore rest
if (st.countTokens() > 1) {
String userid = st.nextToken();
String passwd = st.nextToken();
String decpswd = AccessController.doPrivileged(new DecodeAction(passwd));
hm.put(userid, decpswd);
}
}
}
if (!hm.isEmpty()) {
return hm;
} else {
return null;
}
} catch (IOException e) {
debug.error(classMethod + "IOex on file " + authFilePath + ": " + e.getMessage());
} catch (RuntimeException e) {
debug.error(classMethod + "RuntimeEx on file " + authFilePath + ": ", e);
} catch (Exception e) {
debug.error(classMethod + "Exception on file " + authFilePath + ": ", e);
}
return null;
}
use of com.sun.identity.security.DecodeAction in project OpenAM by OpenRock.
the class SAMLConfigValidator method readPwdFile.
private String readPwdFile(String pfile) {
String pwdStr = null;
if (pfile != null) {
try {
FileInputStream fis = new FileInputStream(pfile);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
pwdStr = (String) AccessController.doPrivileged(new DecodeAction(br.readLine()));
fis.close();
} catch (Exception e) {
Debug.getInstance(DEBUG_NAME).error("SAMLConfigValidator.readPwdFile: " + "Exception in reading password file information", e);
}
}
return pwdStr;
}
Aggregations