CommandLineSSO.java revision 386650a8957e131311273ee84a4a4113ad5e3fe2
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * The contents of this file are subject to the terms
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * of the Common Development and Distribution License
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * (the License). You may not use this file except in
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * compliance with the License.
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * You can obtain a copy of the License at
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * See the License for the specific language governing
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * permission and limitations under the License.
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * When distributing Covered Code, include this CDDL
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * Header Notice in each file and include the License file
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * If applicable, add the following below the CDDL Header,
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * with the fields enclosed by brackets [] replaced by
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * your own identifying information:
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * $Id: CommandLineSSO.java,v 1.3 2008/06/25 05:41:14 qcheng Exp $
0a99555401a033704f1f171baab6db11fb5528f2Allan Fosterimport com.sun.identity.authentication.AuthContext;
0a99555401a033704f1f171baab6db11fb5528f2Allan Fosterimport com.sun.identity.authentication.spi.AuthLoginException;
0a99555401a033704f1f171baab6db11fb5528f2Allan Fosterimport javax.security.auth.callback.NameCallback;
0a99555401a033704f1f171baab6db11fb5528f2Allan Fosterimport javax.security.auth.callback.PasswordCallback;
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * This sample demonstrates the use of retrieving user profile from the correct
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster * user credential.
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster public static void main(String args[]) throws Exception {
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster System.out.println("Organization: " + orgName);
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster SSOTokenManager manager = SSOTokenManager.getInstance();
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster if (lc.getStatus() == AuthContext.Status.SUCCESS) {
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster System.out.println("Successful authentication ...");
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster String userDN = token.getPrincipal().getName();
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster AMIdentity userIdentity = IdUtils.getIdentity(token);
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster for (Iterator i = attrs.keySet().iterator(); i.hasNext(); ) {
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster System.out.println("Authentication Failed ....... ");
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster // Creates AuthContext and submits requirements
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster private static AuthContext getAuthcontext(String orgName)
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster AuthContext.IndexType indexType = AuthContext.IndexType.MODULE_INSTANCE;
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster System.out.println("DataStore: Obtained login context");
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster NameCallback name = (NameCallback) callback[i];
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster new InputStreamReader(System.in))).readLine());
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster } else if (callback[i] instanceof PasswordCallback) {