当前位置: 首页>>代码示例>>Java>>正文


Java JMXPrincipal类代码示例

本文整理汇总了Java中javax.management.remote.JMXPrincipal的典型用法代码示例。如果您正苦于以下问题:Java JMXPrincipal类的具体用法?Java JMXPrincipal怎么用?Java JMXPrincipal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JMXPrincipal类属于javax.management.remote包,在下文中一共展示了JMXPrincipal类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addNotificationListener

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
@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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:NotificationAccessControllerTest.java

示例2: removeNotificationListener

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
@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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:NotificationAccessControllerTest.java

示例3: fetchNotification

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
@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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:NotificationAccessControllerTest.java

示例4: setUp

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
@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();
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:23,代码来源:UsersServletTest.java

示例5: setUp

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
@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();
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:23,代码来源:UsersServletTest.java

示例6: addNotificationListener

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
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();
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:17,代码来源:NotificationAccessControllerTest.java

示例7: removeNotificationListener

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
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();
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:17,代码来源:NotificationAccessControllerTest.java

示例8: fetchNotification

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
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();
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:18,代码来源:NotificationAccessControllerTest.java

示例9: getJaasCertificateCallbackHandler

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
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);
            }
         }
      }
   };
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:TextFileCertificateLoginModuleTest.java

示例10: getSubjectUser

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:28,代码来源:JMXUtils.java

示例11: getUserIdentity

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
@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;
    }

}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:19,代码来源:OVXLoginService.java

示例12: authenticate

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:wso2,项目名称:carbon-kernel,代码行数:21,代码来源:CarbonJMXAuthenticator.java

示例13: testAuthenticationSuccess

import javax.management.remote.JMXPrincipal; //导入依赖的package包/类
/**
 * 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));

}
 
开发者ID:wso2,项目名称:andes,代码行数:20,代码来源:RMIPasswordAuthenticatorTest.java


注:本文中的javax.management.remote.JMXPrincipal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。