use of com.sun.identity.security.DecodeAction in project OpenAM by OpenRock.
the class AMCrypt method decryptPasswords.
public static Map decryptPasswords(Map attributes, ServiceSchema serviceSchema) {
if (serviceSchema == null || attributes == null) {
return attributes;
}
Iterator iter = attributes.keySet().iterator();
while (iter.hasNext()) {
String attributeName = (String) (iter.next());
AttributeSchema as = serviceSchema.getAttributeSchema(attributeName);
if (as != null && (as.getSyntax().equals(AttributeSchema.Syntax.PASSWORD) || as.getSyntax().equals(AttributeSchema.Syntax.ENCRYPTED_PASSWORD))) {
Set valueSet = (Set) (attributes.get(attributeName));
if (valueSet != null) {
HashSet tmpValueSet = new HashSet(valueSet);
valueSet.clear();
Iterator valIter = tmpValueSet.iterator();
while (valIter.hasNext()) {
String value = (String) valIter.next();
if (value != null) {
value = (String) AccessController.doPrivileged(new DecodeAction(value));
}
valueSet.add(value);
}
}
}
}
return attributes;
}
use of com.sun.identity.security.DecodeAction in project OpenAM by OpenRock.
the class AMCrypt method decryptPasswords.
public static Set decryptPasswords(Set values, String attributeName, ServiceSchema serviceSchema) {
if (values == null || values.isEmpty()) {
return values;
}
AttributeSchema as = serviceSchema.getAttributeSchema(attributeName);
if (as == null || (!as.getSyntax().equals(AttributeSchema.Syntax.PASSWORD) && !as.getSyntax().equals(AttributeSchema.Syntax.ENCRYPTED_PASSWORD))) {
return values;
}
HashSet result = new HashSet();
Iterator iter = values.iterator();
while (iter.hasNext()) {
String value = (String) iter.next();
if (value != null) {
value = (String) AccessController.doPrivileged(new DecodeAction(value));
}
result.add(value);
}
return result;
}
use of com.sun.identity.security.DecodeAction in project OpenAM by OpenRock.
the class SessionService method decrypt.
/**
* This method is used to decrypt the InternalSession object, after
* obtaining from HttpSession.
*
* @param strEncrypted Object to be decrypted
*/
private InternalSession decrypt(String strEncrypted) {
if (strEncrypted == null)
return null;
String strDecrypted;
byte[] byteDecrypted = null;
ByteArrayInputStream byteIn;
ObjectInputStream objInStream;
Object tempObject = null;
try {
// decrypt string
strDecrypted = AccessController.doPrivileged(new DecodeAction(strEncrypted, Crypt.getHardcodedKeyEncryptor()));
// convert string to byte
byteDecrypted = Base64.decode(strDecrypted);
// convert byte to object using streams
byteIn = new ByteArrayInputStream(byteDecrypted);
objInStream = new ObjectInputStream(byteIn);
tempObject = objInStream.readObject();
} catch (Exception e) {
sessionDebug.message("Error in decrypting the Internal Session object" + e.getMessage());
return null;
}
if (tempObject == null) {
return null;
}
return (InternalSession) tempObject;
}
use of com.sun.identity.security.DecodeAction in project OpenAM by OpenRock.
the class AuthXMLUtils method getDeSerializedSubject.
/**
* Deserializes Subject.
*
* @param subjectSerialized Serialized Subject.
* @throws Exception
*/
public static Subject getDeSerializedSubject(String subjectSerialized) throws Exception {
// decrypt and then decode
String decStr = (String) AccessController.doPrivileged(new DecodeAction(subjectSerialized));
byte[] sSerialized = Base64.decode(decStr);
if (sSerialized == null)
return null;
byte[] byteDecrypted;
ByteArrayInputStream byteIn;
ObjectInputStream objInStream = null;
Object tempObject = null;
try {
byteDecrypted = sSerialized;
//convert byte to object using streams
byteIn = new ByteArrayInputStream(byteDecrypted);
objInStream = new ObjectInputStream(byteIn);
tempObject = objInStream.readObject();
} catch (Exception e) {
debug.message("Exception Message in decrypt: ", e);
}
if (tempObject == null)
return null;
Subject subjectObj = (Subject) tempObject;
if (debug.messageEnabled()) {
debug.message("returning temp" + subjectObj);
}
return subjectObj;
}
use of com.sun.identity.security.DecodeAction in project OpenAM by OpenRock.
the class FSSAMLTrustedPartnersViewBeanBase method setValues.
protected void setValues(Map map) {
Map values = correctCaseOfAttributeNames(map);
for (Iterator iter = values.keySet().iterator(); iter.hasNext(); ) {
String attr = (String) iter.next();
if (attr.equals(SAMLConstants.AUTH_PASSWORD)) {
String pwd = (String) AccessController.doPrivileged(new DecodeAction((String) values.get(attr)));
propertySheetModel.setValue(SAMLConstants.AUTH_PASSWORD, pwd);
propertySheetModel.setValue(SAMLConstants.AUTH_PASSWORD + SAMLPropertyTemplate.CONFIRM_SUFFIX, pwd);
} else {
propertySheetModel.setValue(attr, values.get(attr));
}
}
}
Aggregations