Java 类javax.management.remote.JMXPrincipal 实例源码

项目:jdk8u-jdk    文件:NotificationAccessControllerTest.java   
@Override
public void addNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("addNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=1,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:jdk8u-jdk    文件:NotificationAccessControllerTest.java   
@Override
public void removeNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("removeNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:jdk8u-jdk    文件:NotificationAccessControllerTest.java   
@Override
public void fetchNotification(
    String connectionId,
    ObjectName name,
    Notification notification,
    Subject subject)
    throws SecurityException {
    echo("fetchNotification:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tnotification: " +  notification);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (!throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:openjdk-jdk10    文件:NotificationAccessControllerTest.java   
@Override
public void addNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("addNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=1,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:openjdk-jdk10    文件:NotificationAccessControllerTest.java   
@Override
public void removeNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("removeNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:openjdk-jdk10    文件:NotificationAccessControllerTest.java   
@Override
public void fetchNotification(
    String connectionId,
    ObjectName name,
    Notification notification,
    Subject subject)
    throws SecurityException {
    echo("fetchNotification:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tnotification: " +  notification);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (!throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:openjdk9    文件:NotificationAccessControllerTest.java   
@Override
public void addNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("addNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=1,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:openjdk9    文件:NotificationAccessControllerTest.java   
@Override
public void removeNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("removeNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:openjdk9    文件:NotificationAccessControllerTest.java   
@Override
public void fetchNotification(
    String connectionId,
    ObjectName name,
    Notification notification,
    Subject subject)
    throws SecurityException {
    echo("fetchNotification:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tnotification: " +  notification);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (!throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:jdk8u_jdk    文件:NotificationAccessControllerTest.java   
@Override
public void addNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("addNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=1,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:jdk8u_jdk    文件:NotificationAccessControllerTest.java   
@Override
public void removeNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("removeNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:jdk8u_jdk    文件:NotificationAccessControllerTest.java   
@Override
public void fetchNotification(
    String connectionId,
    ObjectName name,
    Notification notification,
    Subject subject)
    throws SecurityException {
    echo("fetchNotification:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tnotification: " +  notification);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (!throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:lookaside_java-1.8.0-openjdk    文件:NotificationAccessControllerTest.java   
@Override
public void addNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("addNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=1,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:lookaside_java-1.8.0-openjdk    文件:NotificationAccessControllerTest.java   
@Override
public void removeNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("removeNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:lookaside_java-1.8.0-openjdk    文件:NotificationAccessControllerTest.java   
@Override
public void fetchNotification(
    String connectionId,
    ObjectName name,
    Notification notification,
    Subject subject)
    throws SecurityException {
    echo("fetchNotification:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tnotification: " +  notification);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (!throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:java-docs-samples    文件:UsersServletTest.java   
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  helper.setUp();

  //  Set up some fake HTTP requests
  //  If the user isn't logged in, use this request
  when(mockRequestNotLoggedIn.getRequestURI()).thenReturn(FAKE_URL);
  when(mockRequestNotLoggedIn.getUserPrincipal()).thenReturn(null);

  //  If the user is logged in, use this request
  when(mockRequestLoggedIn.getRequestURI()).thenReturn(FAKE_URL);
  //  Most of the classes that implement Principal have been
  //  deprecated.  JMXPrincipal seems like a safe choice. 
  when(mockRequestLoggedIn.getUserPrincipal()).thenReturn(new JMXPrincipal(FAKE_NAME));

  // Set up a fake HTTP response.
  responseWriter = new StringWriter();
  when(mockResponse.getWriter()).thenReturn(new PrintWriter(responseWriter));

  servletUnderTest = new UsersServlet();
}
项目:java-docs-samples    文件:UsersServletTest.java   
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  helper.setUp();

  //  Set up some fake HTTP requests
  //  If the user isn't logged in, use this request
  when(mockRequestNotLoggedIn.getRequestURI()).thenReturn(FAKE_URL);
  when(mockRequestNotLoggedIn.getUserPrincipal()).thenReturn(null);

  //  If the user is logged in, use this request
  when(mockRequestLoggedIn.getRequestURI()).thenReturn(FAKE_URL);
  //  Most of the classes that implement Principal have been
  //  deprecated.  JMXPrincipal seems like a safe choice.
  when(mockRequestLoggedIn.getUserPrincipal()).thenReturn(new JMXPrincipal(FAKE_NAME));

  // Set up a fake HTTP response.
  responseWriter = new StringWriter();
  when(mockResponse.getWriter()).thenReturn(new PrintWriter(responseWriter));

  servletUnderTest = new UsersServlet();
}
项目:infobip-open-jdk-8    文件:NotificationAccessControllerTest.java   
public void addNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("addNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=1,type=NB")
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:infobip-open-jdk-8    文件:NotificationAccessControllerTest.java   
public void removeNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("removeNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:infobip-open-jdk-8    文件:NotificationAccessControllerTest.java   
public void fetchNotification(
    String connectionId,
    ObjectName name,
    Notification notification,
    Subject subject)
    throws SecurityException {
    echo("fetchNotification:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tnotification: " +  notification);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (!throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB") &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:jdk8u-dev-jdk    文件:NotificationAccessControllerTest.java   
@Override
public void addNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("addNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=1,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:jdk8u-dev-jdk    文件:NotificationAccessControllerTest.java   
@Override
public void removeNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("removeNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:jdk8u-dev-jdk    文件:NotificationAccessControllerTest.java   
@Override
public void fetchNotification(
    String connectionId,
    ObjectName name,
    Notification notification,
    Subject subject)
    throws SecurityException {
    echo("fetchNotification:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tnotification: " +  notification);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (!throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject != null
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:activemq-artemis    文件:TextFileCertificateLoginModuleTest.java   
private JaasCallbackHandler getJaasCertificateCallbackHandler(String user) {
   JMXPrincipal principal = new JMXPrincipal(user);
   X509Certificate cert = new StubX509Certificate(principal);
   return new JaasCallbackHandler(null, null, null) {
      @Override
      public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
         for (Callback callback : callbacks) {
            if (callback instanceof CertificateCallback) {
               CertificateCallback certCallback = (CertificateCallback) callback;
               certCallback.setCertificates(new X509Certificate[]{cert});
            } else {
               throw new UnsupportedCallbackException(callback);
            }
         }
      }
   };
}
项目:jdk7-jdk    文件:NotificationAccessControllerTest.java   
public void addNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("addNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=1,type=NB")
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:jdk7-jdk    文件:NotificationAccessControllerTest.java   
public void removeNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("removeNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:jdk7-jdk    文件:NotificationAccessControllerTest.java   
public void fetchNotification(
    String connectionId,
    ObjectName name,
    Notification notification,
    Subject subject)
    throws SecurityException {
    echo("fetchNotification:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tnotification: " +  notification);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (!throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB") &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:bagri    文件:JMXUtils.java   
/**
 * Get the current user name connected to JMX server
 * 
 * @return the current user name if any, null otherwise
 */
public static String getSubjectUser() {
       AccessControlContext ctx = AccessController.getContext();
       Subject subj = Subject.getSubject(ctx);
       String result = null;
       if (subj == null) {
        subj = LocalSubject.getSubject();
       }
       logger.trace("getSubjectUser; subject: {}", subj);
       if (subj != null) {
        Set<JMXPrincipal> sjp = subj.getPrincipals(JMXPrincipal.class);
        if (sjp != null && sjp.size() > 0) {
            result = sjp.iterator().next().getName();
        } else {
            Set<Principal> sp = subj.getPrincipals();
            if (sp != null && sp.size() > 0) {
                result = sp.iterator().next().getName();
            }
        }
       }
       logger.trace("getSubjectUser.exit; returning: {}", result);
       return result;
}
项目:openjdk-source-code-learn    文件:NotificationAccessControllerTest.java   
public void addNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("addNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=1,type=NB")
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:openjdk-source-code-learn    文件:NotificationAccessControllerTest.java   
public void removeNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("removeNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:openjdk-source-code-learn    文件:NotificationAccessControllerTest.java   
public void fetchNotification(
    String connectionId,
    ObjectName name,
    Notification notification,
    Subject subject)
    throws SecurityException {
    echo("fetchNotification:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tnotification: " +  notification);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (!throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB") &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:OLD-OpenJDK8    文件:NotificationAccessControllerTest.java   
public void addNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("addNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=1,type=NB")
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:OLD-OpenJDK8    文件:NotificationAccessControllerTest.java   
public void removeNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("removeNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:OLD-OpenJDK8    文件:NotificationAccessControllerTest.java   
public void fetchNotification(
    String connectionId,
    ObjectName name,
    Notification notification,
    Subject subject)
    throws SecurityException {
    echo("fetchNotification:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tnotification: " +  notification);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (!throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB") &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:CoVisor    文件:OVXLoginService.java   
@Override
public UserIdentity getUserIdentity() {
    // TODO: need to return the correct identity for this user.
    // Permitting specific logins for now with no passwords
    if (this.user.equals("tenant")) {
        return new DefaultUserIdentity(new Subject(), new JMXPrincipal(
                this.user), new String[] {"user"});
    } else if (this.user.equals("ui")) {
        return new DefaultUserIdentity(new Subject(), new JMXPrincipal(
                this.user), new String[] {"ui"});
    } else if (this.user.equals("admin")) {
        return new DefaultUserIdentity(new Subject(), new JMXPrincipal(
                this.user), new String[] {"user", "admin", "ui"});
    } else {
        return null;
    }

}
项目:JAVA_UNIT    文件:NotificationAccessControllerTest.java   
public void addNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("addNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=1,type=NB")
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:JAVA_UNIT    文件:NotificationAccessControllerTest.java   
public void removeNotificationListener(
    String connectionId,
    ObjectName name,
    Subject subject)
    throws SecurityException {
    echo("removeNotificationListener:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB")
            &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:JAVA_UNIT    文件:NotificationAccessControllerTest.java   
public void fetchNotification(
    String connectionId,
    ObjectName name,
    Notification notification,
    Subject subject)
    throws SecurityException {
    echo("fetchNotification:");
    echo("\tconnectionId: " +  connectionId);
    echo("\tname: " +  name);
    echo("\tnotification: " +  notification);
    echo("\tsubject: " +
         (subject == null ? null : subject.getPrincipals()));
    if (!throwException)
        if (name.getCanonicalName().equals("domain:name=2,type=NB") &&
            subject.getPrincipals().contains(new JMXPrincipal("role")))
            throw new SecurityException();
}
项目:carbon-kernel    文件:CarbonJMXAuthenticator.java   
@Override
public Subject authenticate(Object credentials) {
    if (credentials == null) {
        throw new SecurityException("Credentials required");
    }

    if (!(credentials instanceof String[])) {
        throw new SecurityException("Credentials should be String[]");
    }

    CallbackHandler callbackHandler = new CarbonJMXCallbackHandler(credentials);
    try {
        LoginContext loginContext = new LoginContext(Constants.LOGIN_MODULE_ENTRY, callbackHandler);
        loginContext.login();
        return new Subject(true, Collections.singleton(new JMXPrincipal(((String[]) credentials)[0])),
                Collections.EMPTY_SET, Collections.EMPTY_SET);
    } catch (LoginException e) {
        throw new SecurityException("Invalid credentials", e);
    }
}
项目:andes    文件:RMIPasswordAuthenticatorTest.java   
/**
 * Tests a successful authentication.  Ensures that a populated read-only subject it returned.
 */
public void testAuthenticationSuccess()
{
    final Subject expectedSubject = new Subject(true,
            Collections.singleton(new JMXPrincipal(USERNAME)),
            Collections.EMPTY_SET,
            Collections.EMPTY_SET);

    _rmipa.setAuthenticationManager(createTestAuthenticationManager(true, null));


    Subject newSubject = _rmipa.authenticate(_credentials);
    assertTrue("Subject must be readonly", newSubject.isReadOnly());
    assertTrue("Returned subject does not equal expected value",
            newSubject.equals(expectedSubject));

}