/** * Handles the reception of SLO responses and sending of new SLO requests. * Deletes information for handled SLO request and finally deletes the session * the original SLO request was sent to. * * @param array $message * @return void * * */ public function handleslo(array $message) { $me = $this->getCurrentMD('entityID'); $inresponseto = $message['_InResponseTo']; $req = db_get('REQ-' . $inresponseto); if ($remote = nvl($req, 'entity')) { db_del($req['type'] . '-' . $req['sessionindex'], sha1($remote)); } $sloinfo = db_get('SLO-' . $req['ID']); $success = 'urn:oasis:names:tc:SAML:2.0:status:Success'; if ($status = nvl2($message, 'samlp:Status', 'samlp:StatusCode')) { if ($status['_Value'] != $success || nvl2($status, 'samlp:StatusCode', '_Value')) { $sloinfo['success'] = false; db_put('SLO-' . $req['request '], $sloinfo); } } foreach ((array) nvl($sloinfo, 'sessions') as $session => $dummy) { foreach (array('IDP', 'SP') as $type) { $responses = db_get($type . '-' . $session, '*'); foreach ($responses as $hashedentity => $info) { if ($info['entity'] == $sloinfo['Issuer']) { db_del($type . '-' . $session, $hashedentity); continue; } $id = ID(); $info['ID'] = $id; $info['type'] = $type; debug("REQ id+", $id); db_put("REQ-{$id}", serialize($info)); $response = $this->sendLogoutRequest($info); if (!$response) { $res = false; } else { $status = $response['samlp:Status']['samlp:StatusCode']; $res = $status['_Value'] != $success || nvl2($status, 'samlp:StatusCode', '_Value'); } if (!$res && $sloinfo['success']) { $sloinfo['success'] = false; db_put('SLO-' . $req['ID'], serialize($sloinfo)); } } db_del('REQ-' . $inresponseto); } delete_corto_session($session); } db_del('SLO-' . $req['ID']); $this->sendLogoutResponse($sloinfo); }
function delete_corto_session($sessionid) { db_del($sessionid, '*'); }
public function update_att_links($table_name, $id, $form_att) { if (!is_array($form_att)) { return; } $me_id = Utils::me(); #1. set status=1 (under update) $fields = array(); $fields['status'] = 1; $where = array(); $where['table_name'] = $table_name; $where['item_id'] = $id; db_update($this->att_table_link, $fields, $where); #2. add new items or update old to status =0 foreach ($form_att as $att_id => $value) { $att_id += 0; if (!$att_id) { continue; } $where = array(); $where['table_name'] = $table_name; $where['item_id'] = $id; $where['att_id'] = $att_id; $row = db_row($att_table_link, $where); if (count($row)) { #existing link $fields = array(); $fields['status'] = 0; $where = array(); $where['id'] = $row['id']; db_update($att_table_link, $fields, $where); } else { #new link $fields = array(); $fields['att_id'] = $att_id; $fields['table_name'] = $table_name; $fields['item_id'] = $id; $fields['add_user_id'] = $me_id; db_insert($att_table_link, $fields); } } #3. remove not updated atts (i.e. user removed them) $where = array(); $where['table_name'] = $table_name; $where['item_id'] = $id; $where['status'] = 1; db_del($att_table_link, $where); }