Package org.structr.common

Examples of org.structr.common.SecurityContext


  //~--- methods --------------------------------------------------------

  @Override
  public void processMessage(WebSocketMessage webSocketData) {

    final SecurityContext securityContext = getWebSocket().getSecurityContext();

    try {

      int sequenceNumber = ((Long) webSocketData.getNodeData().get("chunkId")).intValue();
      int chunkSize      = ((Long) webSocketData.getNodeData().get("chunkSize")).intValue();
      Object rawData     = webSocketData.getNodeData().get("chunk");
      int chunks         = ((Long) webSocketData.getNodeData().get("chunks")).intValue();
      String uuid        = webSocketData.getId();
      byte[] data        = null;

      if (rawData != null) {

        if (rawData instanceof String) {

          logger.log(Level.FINEST, "Raw data: {0}", rawData);

//                                      data = Base64.decodeBase64(((String)rawData).getBytes("UTF-8"));
          data = Base64.decodeBase64(((String) rawData));

          logger.log(Level.FINEST, "Decoded data: {0}", data);

        }

      }

      final File file = (File) getNode(uuid);

      if (!securityContext.isAllowed(file, Permission.write)) {

        logger.log(Level.WARNING, "No write permission for {0} on {1}", new Object[] {getWebSocket().getCurrentUser().toString(), file.toString()});
        getWebSocket().send(MessageBuilder.status().message("No write permission").code(400).build(), true);
        return;
View Full Code Here


  @Override
  public void processMessage(WebSocketMessage webSocketData) {
   

    final SecurityContext securityContext  = getWebSocket().getSecurityContext();
    final String rawType                   = (String) webSocketData.getNodeData().get("type");
    final Class type                       = SchemaHelper.getEntityClassForRawType(rawType);
    final String sortOrder                 = webSocketData.getSortOrder();
    final String sortKey                   = webSocketData.getSortKey();
    final int pageSize                     = webSocketData.getPageSize();
View Full Code Here

  @Override
  public void processMessage(final WebSocketMessage webSocketData) {

    final String pageName                 = (String) webSocketData.getNodeData().get(Page.name.dbName());
    final SecurityContext securityContext = getWebSocket().getSecurityContext();

    try {
     
      Page newPage = Page.createNewPage(securityContext, pageName);
      if (newPage != null) {
View Full Code Here

  @Override
  public void execute(Map<String, Object> attributes) throws FrameworkException {

    final String entityType = (String) attributes.get("type");
    final GraphDatabaseService graphDb = (GraphDatabaseService) arguments.get("graphDb");
    final SecurityContext superUserContext = SecurityContext.getSuperUserInstance();
    final NodeFactory nodeFactory = new NodeFactory(superUserContext);

    Class type = null;
    if (entityType != null) {
View Full Code Here

  @Override
  public void execute(final Map<String, Object> properties) throws FrameworkException {

    final GraphDatabaseService graphDb     = (GraphDatabaseService) arguments.get("graphDb");
    final SecurityContext superUserContext = SecurityContext.getSuperUserInstance();
    final NodeFactory nodeFactory          = new NodeFactory(superUserContext);

    final String type = (String)properties.get("type");
    if (StringUtils.isBlank(type)) {
      throw new FrameworkException(422, "Type must not be empty");
View Full Code Here

  @Override
  public T instantiateWithType(final Relationship relationship, final Class<T> relClass, final boolean isCreation) throws FrameworkException {

    logger.log(Level.FINEST, "Instantiate relationship with type {0}", relClass.getName());

    SecurityContext securityContext = factoryProfile.getSecurityContext();
    T newRel          = null;

    try {

      newRel = relClass.newInstance();
View Full Code Here

  @Override
  public T instantiateWithType(final Node node, final Class<T> nodeClass, boolean isCreation) throws FrameworkException {


    SecurityContext securityContext = factoryProfile.getSecurityContext();
    T newNode                       = null;

    try {
      newNode = nodeClass.newInstance();

    } catch (InstantiationException|IllegalAccessException itex) {
      newNode = null;
    }

    if (newNode == null) {
      newNode = (T)factoryDefinition.createGenericNode();
    }

    newNode.init(factoryProfile.getSecurityContext(), node, nodeClass);
    newNode.onNodeInstantiation();

    // check access
    if (isCreation || securityContext.isReadable(newNode, factoryProfile.includeDeletedAndHidden(), factoryProfile.publicOnly())) {

      return newNode;
    }

    return null;
View Full Code Here

  }

  private Result resultFromSpatialRecords(final SpatialRecordHits spatialRecordHits) throws FrameworkException {

    final int pageSize                    = factoryProfile.getPageSize();
    final SecurityContext securityContext = factoryProfile.getSecurityContext();
    final boolean includeDeletedAndHidden = factoryProfile.includeDeletedAndHidden();
    final boolean publicOnly              = factoryProfile.publicOnly();
    List<T> nodes                         = new LinkedList<>();
    int size                              = spatialRecordHits.size();
    int position                          = 0;
    int count                             = 0;
    int offset                            = 0;

    for (Node node : spatialRecordHits) {

      Node realNode = node;
      if (realNode != null) {

        // FIXME: type cast is not good here...
        T n = instantiate(realNode);

        nodes.add(n);

        // Check is done in createNodeWithType already, so we don't have to do it again
        if (n != null) {    // && isReadable(securityContext, n, includeDeletedAndHidden, publicOnly)) {

          List<T> nodesAt = (List<T>)getNodesAt(n);

          size += nodesAt.size();

          for (T nodeAt : nodesAt) {

            if (nodeAt != null && securityContext.isReadable(nodeAt, includeDeletedAndHidden, publicOnly)) {

              if (++position > offset) {

                // stop if we got enough nodes
                if (++count > pageSize) {
View Full Code Here

  @Override
  public void execute(final Map<String, Object> properties) throws FrameworkException {

    final GraphDatabaseService graphDb     = (GraphDatabaseService) arguments.get("graphDb");
    final SecurityContext superUserContext = SecurityContext.getSuperUserInstance();
    final NodeFactory nodeFactory          = new NodeFactory(superUserContext, true, false);

    if (graphDb != null) {

      final List<AbstractNode> nodes = new LinkedList<>();
View Full Code Here

    final String mode                      = (String) attributes.get("mode");
    final String entityType                = (String) attributes.get("type");
    final String relType                   = (String) attributes.get("relType");
    final GraphDatabaseService graphDb     = (GraphDatabaseService) arguments.get("graphDb");
    final SecurityContext superUserContext = SecurityContext.getSuperUserInstance();
    final NodeFactory nodeFactory          = new NodeFactory(superUserContext);
    final RelationshipFactory relFactory   = new RelationshipFactory(superUserContext);

    Class type = null;
    if (entityType != null) {
View Full Code Here

TOP

Related Classes of org.structr.common.SecurityContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.