Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b5965791dc0593874cf1272b4be68b31be52447e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * Copyright (c) 2012-2014, 2016 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.emf.cdo.server.spi.security;

import org.eclipse.emf.cdo.security.User;
import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
import org.eclipse.emf.cdo.server.security.ISecurityManager;
import org.eclipse.emf.cdo.spi.server.InternalRepository;

import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.factory.ProductCreationException;

/**
 * If the meaning of this type isn't clear, there really should be more of a description here...
 *
 * @author Eike Stepper
 * @noimplement This interface is not intended to be implemented by clients.
 * @noextend This interface is not intended to be extended by clients.
 */
public interface InternalSecurityManager extends ISecurityManager
{
  public IManagedContainer getContainer();

  public void setRepository(InternalRepository repository);

  public String getRealmPath();

  public CommitHandler[] getCommitHandlers();

  /**
   * @since 4.3
   */
  public CommitHandler2[] getCommitHandlers2();

  public void addCommitHandler(CommitHandler handler);

  public void removeCommitHandler(CommitHandler handler);

  /**
   * If the meaning of this type isn't clear, there really should be more of a description here...
   *
   * @author Eike Stepper
   */
  public interface CommitHandler
  {
    public void init(InternalSecurityManager securityManager, boolean firstTime);

    /**
     * Called <b>before</b> the commit is security checked and passed to the repository.
     *
     * @param user the committing user or <code>null</code> if this commit is
     * {@link ISecurityManager#modify(ISecurityManager.RealmOperation, boolean) triggered} by the system.
     *
     * @see CommitHandler2
     */
    public void handleCommit(InternalSecurityManager securityManager, CommitContext commitContext, User user);

    /**
     * Creates {@link CommitHandler} instances.
     *
     * @author Eike Stepper
     * @since 4.3
     */
    public static abstract class Factory extends org.eclipse.net4j.util.factory.Factory
    {
      public static final String PRODUCT_GROUP = "org.eclipse.emf.cdo.server.security.commitHandlers";

      public Factory(String type)
      {
        super(PRODUCT_GROUP, type);
      }

      public abstract CommitHandler create(String description) throws ProductCreationException;
    }
  }

  /**
   * If the meaning of this type isn't clear, there really should be more of a description here...
   *
   * @author Eike Stepper
   * @since 4.3
   */
  public interface CommitHandler2 extends CommitHandler
  {
    /**
     * Called <b>after</b> the commit has succeeded.
     */
    public void handleCommitted(InternalSecurityManager securityManager, CommitContext commitContext);

    /**
     * If the meaning of this type isn't clear, there really should be more of a description here...
     *
     * @author Eike Stepper
     */
    public static abstract class WithUser implements CommitHandler2
    {
      public void handleCommit(InternalSecurityManager securityManager, CommitContext commitContext, User user)
      {
        commitContext.setData(this, user);
      }

      public void handleCommitted(InternalSecurityManager securityManager, CommitContext commitContext)
      {
        User user = commitContext.getData(this);
        handleCommitted(securityManager, commitContext, user);
      }

      protected abstract void handleCommitted(InternalSecurityManager securityManager, CommitContext commitContext, User user);
    }
  }
}

Back to the top