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

下面列出了怎么用javax.management.remote.JMXPrincipal的API类实例代码及写法,或者点击链接到github查看源代码。

@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
@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();
}
 
源代码18 项目: jdk1.8-source-analysis   文件: FileLoginModule.java
/**
 * Attempt authentication
 *
 * @param usePasswdFromSharedState a flag to tell this method whether
 *          to retrieve the password from the sharedState.
 */
@SuppressWarnings("unchecked")  // sharedState used as Map<String,Object>
private void attemptAuthentication(boolean usePasswdFromSharedState)
    throws LoginException {

    // get the username and password
    getUsernamePassword(usePasswdFromSharedState);

    String localPassword;

    // userCredentials is initialized in login()
    if (((localPassword = userCredentials.getProperty(username)) == null) ||
        (! localPassword.equals(new String(password)))) {

        // username not found or passwords do not match
        if (logger.debugOn()) {
            logger.debug("login", "Invalid username or password");
        }
        throw new FailedLoginException("Invalid username or password");
    }

    // Save the username and password in the shared state
    // only if authentication succeeded
    if (storePass &&
        !sharedState.containsKey(USERNAME_KEY) &&
        !sharedState.containsKey(PASSWORD_KEY)) {
        sharedState.put(USERNAME_KEY, username);
        sharedState.put(PASSWORD_KEY, password);
    }

    // Create a new user principal
    user = new JMXPrincipal(username);

    if (logger.debugOn()) {
        logger.debug("login",
            "User '" + username + "' successfully validated");
    }
}
 
源代码19 项目: dragonwell8_jdk   文件: FileLoginModule.java
/**
 * Attempt authentication
 *
 * @param usePasswdFromSharedState a flag to tell this method whether
 *          to retrieve the password from the sharedState.
 */
@SuppressWarnings("unchecked")  // sharedState used as Map<String,Object>
private void attemptAuthentication(boolean usePasswdFromSharedState)
    throws LoginException {

    // get the username and password
    getUsernamePassword(usePasswdFromSharedState);

    String localPassword;

    // userCredentials is initialized in login()
    if (((localPassword = userCredentials.getProperty(username)) == null) ||
        (! localPassword.equals(new String(password)))) {

        // username not found or passwords do not match
        if (logger.debugOn()) {
            logger.debug("login", "Invalid username or password");
        }
        throw new FailedLoginException("Invalid username or password");
    }

    // Save the username and password in the shared state
    // only if authentication succeeded
    if (storePass &&
        !sharedState.containsKey(USERNAME_KEY) &&
        !sharedState.containsKey(PASSWORD_KEY)) {
        sharedState.put(USERNAME_KEY, username);
        sharedState.put(PASSWORD_KEY, password);
    }

    // Create a new user principal
    user = new JMXPrincipal(username);

    if (logger.debugOn()) {
        logger.debug("login",
            "User '" + username + "' successfully validated");
    }
}
 
源代码20 项目: dragonwell8_jdk   文件: SimpleStandard.java
/**
 * Check that the principal contained in the Subject is of
 * type JMXPrincipal and refers to the "monitorRole" identity.
 */
private void checkSubject() {
    AccessControlContext acc = AccessController.getContext();
    Subject subject = Subject.getSubject(acc);
    Set principals = subject.getPrincipals();
    Principal principal = (Principal) principals.iterator().next();
    if (!(principal instanceof JMXPrincipal))
        throw new SecurityException("Authenticated subject contains " +
                                    "invalid principal type = " +
                                    principal.getClass().getName());
    String identity = principal.getName();
    if (!identity.equals("monitorRole"))
        throw new SecurityException("Authenticated subject contains " +
                                    "invalid principal name = " + identity);
}
 
源代码21 项目: dragonwell8_jdk   文件: SimpleStandard.java
/**
 * Check that the principal contained in the Subject is of
 * type JMXPrincipal and refers to the principalName identity.
 */
private void checkSubject(String op) {
    AccessControlContext acc = AccessController.getContext();
    Subject subject = Subject.getSubject(acc);
    Set principals = subject.getPrincipals();
    Principal principal = (Principal) principals.iterator().next();
    if (!(principal instanceof JMXPrincipal))
        throw new SecurityException(op+": Authenticated subject contains " +
                                    "invalid principal type = " +
                                    principal.getClass().getName());
    String identity = principal.getName();
    if (!identity.equals(principalName))
        throw new SecurityException(op+": Authenticated subject contains " +
                                    "invalid principal name = " + identity);
}
 
源代码22 项目: dragonwell8_jdk   文件: NonJMXPrincipalsTest.java
public Subject authenticate(Object credentials) {
    final String[] aCredentials = (String[]) credentials;
    final String username = (String) aCredentials[0];
    final Subject subject = new Subject();
    subject.getPrincipals().add(new JMXPrincipal("dummy"));
    subject.getPrincipals().add(new OtherPrincipal(username));
    return subject;
}
 
@Override
public Subject authenticate(Object credentials) {
    String role = ((String[]) credentials)[0];
    echo("\nCreate principal with name = " + role);
    return new Subject(true,
                       Collections.singleton(new JMXPrincipal(role)),
                       Collections.EMPTY_SET,
                       Collections.EMPTY_SET);
}
 
源代码24 项目: dragonwell8_jdk   文件: NotificationEmissionTest.java
public Subject authenticate(Object credentials) {
    String role = ((String[]) credentials)[0];
    echo("Create principal with name = " + role);
    return new Subject(true,
                       Collections.singleton(new JMXPrincipal(role)),
                       Collections.EMPTY_SET,
                       Collections.EMPTY_SET);
}
 
源代码25 项目: TencentKona-8   文件: FileLoginModule.java
/**
 * Attempt authentication
 *
 * @param usePasswdFromSharedState a flag to tell this method whether
 *          to retrieve the password from the sharedState.
 */
@SuppressWarnings("unchecked")  // sharedState used as Map<String,Object>
private void attemptAuthentication(boolean usePasswdFromSharedState)
    throws LoginException {

    // get the username and password
    getUsernamePassword(usePasswdFromSharedState);

    String localPassword;

    // userCredentials is initialized in login()
    if (((localPassword = userCredentials.getProperty(username)) == null) ||
        (! localPassword.equals(new String(password)))) {

        // username not found or passwords do not match
        if (logger.debugOn()) {
            logger.debug("login", "Invalid username or password");
        }
        throw new FailedLoginException("Invalid username or password");
    }

    // Save the username and password in the shared state
    // only if authentication succeeded
    if (storePass &&
        !sharedState.containsKey(USERNAME_KEY) &&
        !sharedState.containsKey(PASSWORD_KEY)) {
        sharedState.put(USERNAME_KEY, username);
        sharedState.put(PASSWORD_KEY, password);
    }

    // Create a new user principal
    user = new JMXPrincipal(username);

    if (logger.debugOn()) {
        logger.debug("login",
            "User '" + username + "' successfully validated");
    }
}
 
源代码26 项目: TencentKona-8   文件: SimpleStandard.java
/**
 * Check that the principal contained in the Subject is of
 * type JMXPrincipal and refers to the "monitorRole" identity.
 */
private void checkSubject() {
    AccessControlContext acc = AccessController.getContext();
    Subject subject = Subject.getSubject(acc);
    Set principals = subject.getPrincipals();
    Principal principal = (Principal) principals.iterator().next();
    if (!(principal instanceof JMXPrincipal))
        throw new SecurityException("Authenticated subject contains " +
                                    "invalid principal type = " +
                                    principal.getClass().getName());
    String identity = principal.getName();
    if (!identity.equals("monitorRole"))
        throw new SecurityException("Authenticated subject contains " +
                                    "invalid principal name = " + identity);
}
 
源代码27 项目: TencentKona-8   文件: SimpleStandard.java
/**
 * Check that the principal contained in the Subject is of
 * type JMXPrincipal and refers to the principalName identity.
 */
private void checkSubject(String op) {
    AccessControlContext acc = AccessController.getContext();
    Subject subject = Subject.getSubject(acc);
    Set principals = subject.getPrincipals();
    Principal principal = (Principal) principals.iterator().next();
    if (!(principal instanceof JMXPrincipal))
        throw new SecurityException(op+": Authenticated subject contains " +
                                    "invalid principal type = " +
                                    principal.getClass().getName());
    String identity = principal.getName();
    if (!identity.equals(principalName))
        throw new SecurityException(op+": Authenticated subject contains " +
                                    "invalid principal name = " + identity);
}
 
源代码28 项目: TencentKona-8   文件: NonJMXPrincipalsTest.java
public Subject authenticate(Object credentials) {
    final String[] aCredentials = (String[]) credentials;
    final String username = (String) aCredentials[0];
    final Subject subject = new Subject();
    subject.getPrincipals().add(new JMXPrincipal("dummy"));
    subject.getPrincipals().add(new OtherPrincipal(username));
    return subject;
}
 
源代码29 项目: jdk8u-jdk   文件: FileLoginModule.java
/**
 * Attempt authentication
 *
 * @param usePasswdFromSharedState a flag to tell this method whether
 *          to retrieve the password from the sharedState.
 */
@SuppressWarnings("unchecked")  // sharedState used as Map<String,Object>
private void attemptAuthentication(boolean usePasswdFromSharedState)
    throws LoginException {

    // get the username and password
    getUsernamePassword(usePasswdFromSharedState);

    String localPassword;

    // userCredentials is initialized in login()
    if (((localPassword = userCredentials.getProperty(username)) == null) ||
        (! localPassword.equals(new String(password)))) {

        // username not found or passwords do not match
        if (logger.debugOn()) {
            logger.debug("login", "Invalid username or password");
        }
        throw new FailedLoginException("Invalid username or password");
    }

    // Save the username and password in the shared state
    // only if authentication succeeded
    if (storePass &&
        !sharedState.containsKey(USERNAME_KEY) &&
        !sharedState.containsKey(PASSWORD_KEY)) {
        sharedState.put(USERNAME_KEY, username);
        sharedState.put(PASSWORD_KEY, password);
    }

    // Create a new user principal
    user = new JMXPrincipal(username);

    if (logger.debugOn()) {
        logger.debug("login",
            "User '" + username + "' successfully validated");
    }
}
 
@Override
public Subject authenticate(Object credentials) {
    String role = ((String[]) credentials)[0];
    echo("\nCreate principal with name = " + role);
    return new Subject(true,
                       Collections.singleton(new JMXPrincipal(role)),
                       Collections.EMPTY_SET,
                       Collections.EMPTY_SET);
}
 
 类所在包
 同包方法