6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * The contents of this file are subject to the terms
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * of the Common Development and Distribution License
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * (the License). You may not use this file except in
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * compliance with the License.
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * You can obtain a copy of the License at
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * See the License for the specific language governing
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * permission and limitations under the License.
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * When distributing Covered Code, include this CDDL
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * Header Notice in each file and include the License file
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * If applicable, add the following below the CDDL Header,
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * with the fields enclosed by brackets [] replaced by
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * your own identifying information:
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster * $Id: TokenUtils.java,v 1.3 2008/06/25 05:50:18 qcheng Exp $
6d96e3809a612651f813d4c475c6590d0c602d94Allan Fosterimport com.sun.identity.authentication.AuthContext;
6d96e3809a612651f813d4c475c6590d0c602d94Allan Fosterimport javax.security.auth.callback.NameCallback;
6d96e3809a612651f813d4c475c6590d0c602d94Allan Fosterimport javax.security.auth.callback.PasswordCallback;
6d96e3809a612651f813d4c475c6590d0c602d94Allan Fosterimport javax.security.auth.callback.UnsupportedCallbackException;
6d96e3809a612651f813d4c475c6590d0c602d94Allan Fosterimport javax.security.auth.login.LoginException;
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster public static SSOToken getToken(String orgName, String userId,
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster return getSessionToken(orgName, userId, password);
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster public static SSOToken getSessionToken(String orgName, String userId,
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster return getSessionToken(orgName,userId, password, null, -1);
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster public static SSOToken getSessionToken(String orgName, String userId,
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster //System.out.println("TokenUtils:orgName=" + orgName);
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster ac.login(AuthContext.IndexType.MODULE_INSTANCE, module);
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster ac.login(AuthContext.IndexType.LEVEL, String.valueOf(level));
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster //System.out.println("TokenUtils:calling login()");
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster //System.out.println("TokenUtils:after ac.login()");
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster // Get the information requested by the plug-ins
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster addLoginCallbackMessage(callbacks, userId, password);
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster if (ac.getStatus() == AuthContext.Status.SUCCESS) {
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster //System.out.println("Auth success");
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster } else if (ac.getStatus() == AuthContext.Status.FAILED) {
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster //System.out.println("Authentication has FAILED");
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster //SSOTokenManager.getInstance().validateToken(ac.getSSOToken());
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster //System.out.println(ac.getSSOToken().getPrincipal().getName());
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster static void addLoginCallbackMessage(Callback[] callbacks, String userId,
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster // prompt the user for a username
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster //System.out.println("userName=" + userId);
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster } else if (callbacks[i] instanceof PasswordCallback) {
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster // prompt the user for sensitive information
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster PasswordCallback pc = (PasswordCallback) callbacks[i];
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster //System.out.println("password=" + password);
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster //throw new UnsupportedCallbackException(callbacks[i],
6d96e3809a612651f813d4c475c6590d0c602d94Allan Foster //"Callback exception: " + e);