login.js revision 4928c5865824c6c1132e8cbc4dc8c00fe5fc6745
2N/A/**
2N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2N/A *
2N/A * Copyright (c) 2012-2013 ForgeRock AS. All Rights Reserved
2N/A *
2N/A * The contents of this file are subject to the terms
2N/A * of the Common Development and Distribution License
2N/A * (the License). You may not use this file except in
2N/A * compliance with the License.
2N/A *
2N/A * You can obtain a copy of the License at
2N/A * http://forgerock.org/license/CDDLv1.0.html
2N/A * See the License for the specific language governing
2N/A * permission and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL
2N/A * Header Notice in each file and include the License file
2N/A * at http://forgerock.org/license/CDDLv1.0.html
2N/A * If applicable, add the following below the CDDL Header,
2N/A * with the fields enclosed by brackets [] replaced by
2N/A * your own identifying information:
2N/A * "Portions Copyrighted [year] [name of copyright owner]"
2N/A */
2N/A
2N/A(function () {
2N/A // Get the current session's user information
2N/A var val,secCtx = request.security;
2N/A if (request.method === "read") {
2N/A if (secCtx && secCtx.username) {
2N/A val = {"authenticationId" : secCtx.username,
2N/A "authorizationId": {
2N/A "roles" : secCtx["roles"],
2N/A "component" : secCtx.component
2N/A }
2N/A };
2N/A } else if (secCtx) {
2N/A val = {"username" : secCtx.user};
2N/A } else {
2N/A throw "Invalid security context, can not retrieve user information associated with the session.";
2N/A }
2N/A } else {
2N/A throw "Unsupported operation on info login service: " + request.method;
2N/A }
2N/A return val;
2N/A}());
2N/A