for (int i = 0; i < requestedAttributes.length; i++) messageLogger.logInfo("Requested attribute: " + requestedAttributes[i]);
    public static Map getUserAttributes(final String serviceTicketId, final String servicePrincipal)    throws IllegalInputException, UnknownTicketException,    InoperableStateException, AuthorizationException {        // Sanity checks.        if (!ready)            throw new InoperableStateException(NOT_READY);        if (serviceTicketId == null || serviceTicketId.equals(""))            throw new IllegalInputException("Service ticket ID must be a non-empty string.");        if (servicePrincipal == null || servicePrincipal.equals(""))            throw new IllegalInputException("Service principal must be a non-empty string.");        // Look up and return the requested attributes.        HashMap filteredAttributes = new HashMap();        try {            String userorg = null;            userorg = store.getTicketUserorg(serviceTicketId,                                             MoriaTicketType.SERVICE_TICKET);            if (userorg == null) {                throw new AuthorizationException("Userorg is not set for ticket");            }            /* check userorg */            if (!authzManager.allowUserorg(servicePrincipal, userorg)) {                accessLogger.logService(AccessStatusType.ACCESS_DENIED_USERORG, servicePrincipal, serviceTicketId, null);                messageLogger.logWarn(CAUGHT_DENIED_USERORG + ", userorg (" + userorg + ") tried to access service (" + servicePrincipal + ")", serviceTicketId);                throw new AuthorizationException("Access to the requested service is denied for " + userorg + ".");                            }                        // Get the originally requested attributes and all cached values.            MoriaAuthnAttempt authenticationAttempt = store.getAuthnAttempt(serviceTicketId, false, servicePrincipal);            String[] requestedAttributes = authenticationAttempt.getRequestedAttributes();            for (int i = 0; i < requestedAttributes.length; i++)                messageLogger.logInfo("Requested attribute: " + requestedAttributes[i]);            final Map cachedAttributes = authenticationAttempt.getTransientAttributes();            messageLogger.logInfo("Returned attributes: " + cachedAttributes.toString());            // Filter cached attributes; only those requested are to be            // returned.            for (int i = 0; i < requestedAttributes.length; i++)                if (cachedAttributes.containsKey(requestedAttributes[i]))                    filteredAttributes.put(requestedAttributes[i], cachedAttributes.get(requestedAttributes[i]));            messageLogger.logInfo("Filtered attributes: " + filteredAttributes.toString());            // the service principal is unknown          } catch (UnknownServicePrincipalException e) {                      accessLogger.logService(AccessStatusType.GET_USER_ATTRIBUTES_DENIED_INVALID_PRINCIPAL, servicePrincipal, serviceTicketId, null);            messageLogger.logInfo("UnknownServicePrincipalException caught", e);            throw new AuthorizationException("Unknown service principal: " + servicePrincipal);        } catch (NonExistentTicketException e) {            // Ticket did not exist in the store.            accessLogger.logService(AccessStatusType.NONEXISTENT_SERVICE_TICKET, servicePrincipal, serviceTicketId, null);            messageLogger.logWarn(CAUGHT_NONEXISTENT_TICKET + ", service (" + servicePrincipal + ") tried to fetch attributes to late", serviceTicketId, e);            throw new UnknownTicketException(NONEXISTENT_TICKET);        } catch (InvalidTicketException e) {            // The ticket was found, but was invalid.            accessLogger.logService(AccessStatusType.INVALID_SERVICE_TICKET, servicePrincipal, serviceTicketId, null);            messageLogger.logWarn(CAUGHT_INVALID_TICKET + ", service (" + servicePrincipal + ") tried to fetch attributes to late", serviceTicketId, e);            throw new UnknownTicketException(NONEXISTENT_TICKET);        } catch (MoriaStoreException e) {            // Unable to access the store.            messageLogger.logCritical(CAUGHT_STORE, serviceTicketId, e);            throw new InoperableStateException(STORE_DOWN);        }        // Return the filtered attributes only.        accessLogger.logService(AccessStatusType.SUCCESSFUL_GET_ATTRIBUTES, servicePrincipal, serviceTicketId, null);        return filteredAttributes;    }