String ticketId = initiateAuthentication(attributes, null, null, false);
String redirectURL = initiateAuthentication(attributes, "http: String ticketId = redirectURL.substring(redirectURL.lastIndexOf("id=")+3);
    public String directNonInteractiveAuthentication(String[] attributes, String username, String password)    throws RemoteException {    	   	    	// Basic parameter check.    	if (username == null)    		throw new RemoteException("User name cannot be NULL");    	if (password == null)    		throw new RemoteException("Password cannot be NULL");    	    	try {    		// Create session and check the client identity.        	String ticketId = initiateAuthentication(attributes, null, null, false);    		Session session = sessionStore.getSessionLogin(ticketId);    		validateClient(ctx.getUserPrincipal(), session);    		// Is the client allowed to do direct authentication at all?    		if (!session.getWebService().allowDirectAuthentication()) {    			log.warning("Web service '"+ctx.getUserPrincipal()+"' not allowed to use direct authentication");    			throw new RemoteException("Web service '"+ctx.getUserPrincipal()+"' not allowed to use direct authentication");    		}    		    		// Create credentials and do authentication.    		if (session.authenticateUser(new Credentials(username, password)))    			return session.getID();    		else    			return null;    	} catch (BackendException e) {    		log.severe("BackendException caught and re-thrown as RemoteException");    		throw new RemoteException("BackendException caught and re-thrown as RemoteException");    	} catch (SessionException e) {    		log.severe("SessionException caught and re-thrown as RemoteException");    		throw new RemoteException("SessionException caught and re-thrown as RemoteException");    	}	}