use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class OpenSSOCoreTokenStore method searchTokens.
/**
*
* @param subject
* @param queryString
* @return JSON array of tokens matching the queryString
* @throws CoreTokenException
*/
public JSONArray searchTokens(Subject subject, String queryString) throws CoreTokenException {
try {
SSOToken token = SubjectUtils.getSSOToken(subject);
if (token == null) {
throw new CoreTokenException(216, null, 401);
}
JSONArray results = new JSONArray();
if (SMSEntry.checkIfEntryExists(SERVICE_DN, token)) {
String filter = createSearchFilter(queryString);
Set<String> dns = SMSEntry.search(token, SERVICE_DN, filter, 0, 0, false, false);
for (String dn : dns) {
if (!LDAPUtils.dnEquals(SERVICE_DN, dn)) {
results.put(LDAPUtils.rdnValueFromDn(dn));
}
}
}
return results;
} catch (SMSException ex) {
CoreTokenUtils.debug.error("OpenSSOCoreTokenStore.searchToken", ex);
throw new CoreTokenException(215, ex);
}
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class LogManagerUtil method logEndRecords.
/**
* Log a LogRecord indicating the end of logging to all opened files
*/
public static void logEndRecords() {
if (lmgr != null) {
try {
SSOToken ssot = getLoggingSSOToken();
LogMessageProviderBase provider = (LogMessageProviderBase) MessageProviderFactory.getProvider("Logging");
String[] s = new String[1];
Enumeration e = lmgr.getLoggerNames();
com.sun.identity.log.LogRecord lr = null;
while (e.hasMoreElements()) {
String logger = (String) e.nextElement();
if (logger.length() != 0 && !logger.equals("global")) {
Logger result = (Logger) Logger.getLogger(logger);
s[0] = logger;
lr = provider.createLogRecord(LogConstants.END_LOG_NAME, s, ssot);
result.log(lr, ssot);
result.flush();
}
}
} catch (IOException ioex) {
// can't do much here
}
}
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class Logger method extractInfoFromLogFor.
static void extractInfoFromLogFor(ILogRecord rec) throws SSOException {
Object logFor = rec.getLogFor();
Object cred = (logFor instanceof Subject) ? getPrivateCred((Subject) logFor) : logFor;
if (!(cred instanceof SSOToken)) {
return;
}
SSOToken ssoToken = (SSOToken) cred;
rec.addLogInfo(LogConstants.LOGIN_ID_SID, ssoToken.getTokenID().toString());
String ctxID = ssoToken.getProperty(Constants.AM_CTX_ID);
if ((ctxID != null) && (ctxID.length() > 0)) {
rec.addLogInfo(LogConstants.CONTEXT_ID, ctxID);
}
resolveHostName(rec, ssoToken);
String clientDomain = ssoToken.getProperty("Organization");
if (clientDomain == null || clientDomain.length() == 0) {
clientDomain = ssoToken.getProperty("cdomain");
}
rec.addLogInfo(LogConstants.DOMAIN, clientDomain);
rec.addLogInfo(LogConstants.LOGIN_ID, ssoToken.getPrincipal().getName());
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/*
* these are the compulsory fields ... to be logged even if there are
* exceptions while getting domain, loginid, ipaddr, hostname
*/
rec.addLogInfo(LogConstants.TIME, sdf.format(date));
if (rec instanceof java.util.logging.LogRecord) {
java.util.logging.LogRecord jLogRecord = (java.util.logging.LogRecord) rec;
rec.addLogInfo(LogConstants.DATA, jLogRecord.getMessage());
rec.addLogInfo(LogConstants.LOG_LEVEL, jLogRecord.getLevel().toString());
}
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class LogManager method logIt.
private void logIt(Logger logger, String[] msg, String msgName) {
try {
LogMessageProviderBase provider = (LogMessageProviderBase) MessageProviderFactory.getProvider("Logging");
SSOToken ssot = LogManagerUtil.getLoggingSSOToken();
com.sun.identity.log.LogRecord lr = provider.createLogRecord(msgName, msg, ssot);
logger.log(lr, ssot);
logger.flush();
} catch (IOException ioex) {
Debug.error("LogManager.logIt:could not log to " + logger.getName() + ": " + ioex.getMessage());
}
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class IndexTreeServiceImpl method createAndPopulateTree.
/**
* Populates a new instance of a index rule tree with policy path indexes retrieved from the associated realm.
*
* @param realm
* The realm for which policy path indexes are to be read from.
* @return A newly created tree populated with rules configured against the realm.
* @throws EntitlementException
* When an error occurs reading policy data.
*/
private IndexRuleTree createAndPopulateTree(String realm) throws EntitlementException {
IndexRuleTree indexTree = null;
String baseDN = String.format(REALM_DN_TEMPLATE, dnMapper.orgNameToDN(realm));
SSOToken token = AccessController.doPrivileged(adminAction);
if (smDAO.checkIfEntryExists(baseDN, token)) {
indexTree = new SimpleReferenceTree();
try {
Set<String> excludes = Collections.emptySet();
// Carry out search.
Iterator<SMSDataEntry> i = smDAO.search(token, baseDN, SEARCH_FILTER, 0, 0, false, false, excludes);
while (i.hasNext()) {
SMSDataEntry e = i.next();
// Suppressed warning as unchecked assignment is valid.
@SuppressWarnings("unchecked") Set<String> policyPathIndexes = e.getAttributeValues(INDEX_PATH_ATT);
indexTree.addIndexRules(policyPathIndexes);
}
} catch (SMSException smsE) {
throw new EntitlementException(52, new Object[] { baseDN }, smsE);
}
if (DEBUG.messageEnabled()) {
DEBUG.message(String.format("Index rule tree created for '%s'.", realm));
}
}
return indexTree;
}
Aggregations