Example usage for org.apache.wicket Component getSession

List of usage examples for org.apache.wicket Component getSession

Introduction

In this page you can find the example usage for org.apache.wicket Component getSession.

Prototype

public Session getSession() 

Source Link

Document

Gets the current Session object.

Usage

From source file:info.jtrac.wicket.ComponentUtils.java

License:Apache License

public static void setCurrentSpace(Component c, Space space) {
    ((JtracSession) c.getSession()).setCurrentSpace(space);
}

From source file:info.jtrac.wicket.ComponentUtils.java

License:Apache License

public static Space getCurrentSpace(Component c) {
    return ((JtracSession) c.getSession()).getCurrentSpace();
}

From source file:info.jtrac.wicket.ComponentUtils.java

License:Apache License

public static void setCurrentItemSearch(Component c, ItemSearch itemSearch) {
    ((JtracSession) c.getSession()).setItemSearch(itemSearch);
}

From source file:info.jtrac.wicket.ComponentUtils.java

License:Apache License

public static ItemSearch getCurrentItemSearch(Component c) {
    return ((JtracSession) c.getSession()).getItemSearch();
}

From source file:info.jtrac.wicket.ComponentUtils.java

License:Apache License

public static void refreshPrincipal(Component c) {
    User temp = getJtrac(c).loadUser(getPrincipal(c).getId());
    // loadUserByUsername forces hibernate eager load
    ((JtracSession) c.getSession()).setUser((User) getJtrac(c).loadUserByUsername(temp.getLoginName()));
}

From source file:org.apache.directory.fortress.web.control.SecureIndicatingAjaxButton.java

License:Apache License

public SecureIndicatingAjaxButton(Component component, String id, String objectName, String opName) {
    super(id);//from  w ww.ja v  a  2s.c  om
    this.perm = new Permission(objectName, opName);
    if (SecUtils.IS_PERM_CACHED) {
        if (!SecUtils.isFound(perm, this))
            setVisible(false);
    } else {
        boolean isAuthorized = false;
        try {
            WicketSession session = (WicketSession) component.getSession();
            isAuthorized = accessMgr.checkAccess(session.getSession(), perm);
            LOG.info("Fortress checkAccess objectName: " + objectName + " operationName: " + opName
                    + " userId: " + session.getSession().getUserId() + " result: " + isAuthorized);
        } catch (org.apache.directory.fortress.core.SecurityException se) {
            String error = "Fortress SecurityException checkAccess objectName: " + objectName
                    + " operationName: " + opName + " error=" + se;
            LOG.error(error);
        }
        if (!isAuthorized)
            setVisible(false);
    }
}

From source file:org.apache.directory.fortress.web.control.SecUtils.java

License:Apache License

/**
 * Return the fortress session that is cached within the wicket session object.
 *
 * @param component needed to get handle to wicket session.
 * @return fortress session object.//from www .  java2s  . c  o m
 */
public static Session getSession(Component component) {
    return ((WicketSession) component.getSession()).getSession();
}

From source file:org.apache.directory.fortress.web.control.SecUtils.java

License:Apache License

/**
 * Returns the fortress arbac perms that are cashed in the wicket session.
 *
 * @param component needed to get a handle on the wicket session object.
 * @return collection of fortress admin perms.
 *//*from  w w w . j  a v  a  2 s .  co  m*/
public static List<Permission> getPermissions(Component component) {
    return ((WicketSession) component.getSession()).getPermissions();
}

From source file:org.apache.directory.fortress.web.control.SecUtils.java

License:Apache License

/**
 * Retrieve RBAC session permissions from Fortress and place in the Wicket session.
 *//*from  w  w w  .j av a  2  s  .c o m*/
public static void getPermissions(Component component, AccessMgr accessMgr) {
    try {
        if (IS_PERM_CACHED) {
            WicketSession session = (WicketSession) component.getSession();
            List<Permission> permissions = accessMgr.sessionPermissions(session.getSession());
            ((WicketSession) WicketSession.get()).setPermissions(permissions);
        }
    } catch (org.apache.directory.fortress.core.SecurityException se) {
        String error = "getPermissions caught SecurityException=" + se;
        LOG.error(error);
        throw new RuntimeException(error);
    }
}

From source file:org.apache.directory.fortress.web.control.SecUtils.java

License:Apache License

/**
 * Wrapper to fortress checkAccess api./*from  ww w. j  av a  2s  .  c om*/
 *
 * @param component contains the wicket session handle.
 * @param accessMgr has the checkAccess api
 * @param objName string value
 * @param opName string value
 * @param objId string value
 * @return true if success, false otherwise.
 * @throws org.apache.directory.fortress.core.SecurityException checked exception for system errors.
 */
public static boolean checkAccess(Component component, AccessMgr accessMgr, String objName, String opName,
        String objId) throws org.apache.directory.fortress.core.SecurityException {
    WicketSession session = (WicketSession) component.getSession();
    Permission permission = new Permission(objName, opName, objId);
    return accessMgr.checkAccess(session.getSession(), permission);
}