/** * This provides command line access to this JAAS module. * * @param args command line arguments * * @throws Exception if an error occurs */ public static void main(final String[] args) throws Exception { String name = "ldaptive"; if (args.length > 0) { name = args[0]; } final LoginContext lc = new LoginContext(name, new TextCallbackHandler()); lc.login(); System.out.println("Authentication/Authorization succeeded"); final Set<Principal> principals = lc.getSubject().getPrincipals(); System.out.println("Subject Principal(s): "); for (Principal p : principals) { System.out.println(" " + p); } lc.logout(); } }
/** * This provides command line access to this JAAS module. * * @param args command line arguments * * @throws Exception if an error occurs */ public static void main(final String[] args) throws Exception { String name = "ldaptive"; if (args.length > 0) { name = args[0]; } final LoginContext lc = new LoginContext(name, new TextCallbackHandler()); lc.login(); System.out.println("Authentication/Authorization succeeded"); final Set<Principal> principals = lc.getSubject().getPrincipals(); System.out.println("Subject Principal(s): "); for (Principal p : principals) { System.out.println(" " + p); } lc.logout(); } }
/** * This provides command line access to this JAAS module. * * @param args command line arguments * * @throws Exception if an error occurs */ public static void main(final String[] args) throws Exception { String name = "ldaptive-dn"; if (args.length > 0) { name = args[0]; } final LoginContext lc = new LoginContext(name, new TextCallbackHandler()); lc.login(); final Set<Principal> principals = lc.getSubject().getPrincipals(); System.out.println("Subject Principal(s): "); for (Principal p : principals) { System.out.println(" " + p.getName()); } lc.logout(); } }
/** * This provides command line access to this JAAS module. * * @param args command line arguments * * @throws Exception if an error occurs */ public static void main(final String[] args) throws Exception { String name = "ldaptive"; if (args.length > 0) { name = args[0]; } final LoginContext lc = new LoginContext(name, new TextCallbackHandler()); lc.login(); System.out.println("Authentication/Authorization succeeded"); final Set<Principal> principals = lc.getSubject().getPrincipals(); System.out.println("Subject Principal(s): "); for (Principal p : principals) { System.out.println(" " + p); } lc.logout(); } }
try { String loginAppName = "GetLoginNameUnix"; // If the application is run on NT rather than Unix, use this name loginAppName = "GetLoginNameNT"; // Create login context LoginContext lc = new LoginContext(loginAppName, new com.sun.security.auth.callback.TextCallbackHandler()); // Retrieve the information on the logged-in user lc.login(); // Get the authenticated subject Subject subject = lc.getSubject(); // Get the subject principals Principal principals[] = (Principal[])subject.getPrincipals().toArray(new Principal[0]); for (int i=0; i<principals.length; i++) { if (principals[i] instanceof com.sun.security.auth.NTUserPrincipal || principals[i] instanceof com.sun.security.auth.UnixPrincipal) { String loggedInUserName = principals[i].getName(); } } } catch (LoginException e) { // Login failed }
/** * This provides command line access to this JAAS module. * * @param args command line arguments * * @throws Exception if an error occurs */ public static void main(final String[] args) throws Exception { String name = "ldaptive-role"; if (args.length > 0) { name = args[0]; } final LoginContext lc = new LoginContext(name, new TextCallbackHandler()); lc.login(); final Set<Principal> principals = lc.getSubject().getPrincipals(); System.out.println("Subject Principal(s): "); for (Principal p : principals) { System.out.println(" " + p.getName()); } lc.logout(); } }
/** * This provides command line access to this JAAS module. * * @param args command line arguments * * @throws Exception if an error occurs */ public static void main(final String[] args) throws Exception { String name = "ldaptive-dn"; if (args.length > 0) { name = args[0]; } final LoginContext lc = new LoginContext(name, new TextCallbackHandler()); lc.login(); final Set<Principal> principals = lc.getSubject().getPrincipals(); System.out.println("Subject Principal(s): "); for (Principal p : principals) { System.out.println(" " + p.getName()); } lc.logout(); } }
/** * This provides command line access to this JAAS module. * * @param args command line arguments * * @throws Exception if an error occurs */ public static void main(final String[] args) throws Exception { String name = "ldaptive-role"; if (args.length > 0) { name = args[0]; } final LoginContext lc = new LoginContext(name, new TextCallbackHandler()); lc.login(); final Set<Principal> principals = lc.getSubject().getPrincipals(); System.out.println("Subject Principal(s): "); for (Principal p : principals) { System.out.println(" " + p.getName()); } lc.logout(); } }
/** * This provides command line access to this JAAS module. * * @param args command line arguments * * @throws Exception if an error occurs */ public static void main(final String[] args) throws Exception { String name = "ldaptive-dn"; if (args.length > 0) { name = args[0]; } final LoginContext lc = new LoginContext(name, new TextCallbackHandler()); lc.login(); final Set<Principal> principals = lc.getSubject().getPrincipals(); System.out.println("Subject Principal(s): "); for (Principal p : principals) { System.out.println(" " + p.getName()); } lc.logout(); } }
/** * This provides command line access to this JAAS module. * * @param args command line arguments * * @throws Exception if an error occurs */ public static void main(final String[] args) throws Exception { String name = "ldaptive-role"; if (args.length > 0) { name = args[0]; } final LoginContext lc = new LoginContext(name, new TextCallbackHandler()); lc.login(); final Set<Principal> principals = lc.getSubject().getPrincipals(); System.out.println("Subject Principal(s): "); for (Principal p : principals) { System.out.println(" " + p.getName()); } lc.logout(); } }
LoginContext lc; try { lc = new LoginContext(JGSS_LOGIN_MOUDLE, new TextCallbackHandler()); lc.login(); return Subject.doAs(lc.getSubject(),
LoginContext lc = null; try { lc = new LoginContext(loginModule, new TextCallbackHandler()); } catch (LoginException le) { throw new XWSSecurityException("Cannot create LoginContext. ", le);
login.initialize(subject, new TextCallbackHandler(), state, options); try { if (login.login()) {
LoginContext lc = null; try { lc = new LoginContext(loginModule, new TextCallbackHandler()); } catch (LoginException le) { throw new XWSSecurityException("Cannot create LoginContext. ", le);