UserProfileServlet.java revision 386650a8957e131311273ee84a4a4113ad5e3fe2
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: UserProfileServlet.java,v 1.3 2008/06/25 05:41:09 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.authentication.AuthContext;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sample program that show user profile.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class UserProfileServlet extends SampleBase {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get query parameters
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgname = request.getParameter("orgname");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (orgname == null || orgname.length() == 0) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String username = request.getParameter("username");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String password = request.getParameter("password");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get the output stream
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster out.println("Value for user name and password are required.");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster out.println("<br><h3>Username:</h3> " + username);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Authenticate the user and obtain SSO Token
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster AuthContext lc = authenticate(orgname, username, password, out);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Obtain the SSO Token
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster out.println("<br><h3>SSOToken:</h3> " + token.getTokenID());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (Iterator i = attrs.keySet().iterator(); i.hasNext(); ) {