⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testingservice.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
字号:
/*
 * TestingService.java
 *
 * Created on 14 August 2006, 20:41
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.globus.services.core.test.impl;

import org.globus.wsrf.security.SecurityManager;
import org.globus.gsi.jaas.JaasSubject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.security.auth.Subject;
import java.rmi.RemoteException;
import org.globus.wsrf.Resource;
import org.globus.wsrf.ResourceProperties;
import org.globus.wsrf.ResourceProperty;
import org.globus.wsrf.ResourcePropertySet;
import org.globus.wsrf.impl.ReflectionResourceProperty;
import org.globus.wsrf.impl.SimpleResourcePropertySet;
import org.globus.stubs.TestingService_instance.*;
import java.util.Properties;

/**
 *
 * @author ls97
 */
public class TestingService implements Resource, ResourceProperties {
    
    static Log logger = LogFactory.getLog(TestingService.class);
    private ResourcePropertySet propSet;
    private String type;
        
        /** Creates a new instance of PrintingService */
    public TestingService() throws RemoteException {
            
        this.propSet = new SimpleResourcePropertySet(
                        TestingQNames.RESOURCE_PROPERTIES);

        try {
            ResourceProperty typeRP = new ReflectionResourceProperty(
                            TestingQNames.RP_TYPE, "Type", this);
            this.propSet.add(typeRP);
            setType("simulation");
        } catch (Exception e) {
                throw new RuntimeException(e.getMessage());
        }
    }
    
    public void setType(String typeIn) {
        this.type=typeIn;
    }
    
    public String getType() {
        return this.type;
    }

    public DomyResponse watch(int minutes) throws RemoteException {
        logSecurityInfo("watch");
        DomyResponse response = null;
        return response;
    }

    public DomyResponse start(int minutes) throws RemoteException {
        logSecurityInfo("start");
        DomyResponse response = null;
        return response;
    }

    public DomyResponse stop(StopRequest req) throws RemoteException {
        logSecurityInfo("stop");
        DomyResponse response = null;
        return response;
    }
    
    private void logSecurityInfo(String methodName) {
        Subject subject;
        logger.info("SECURITY INFO FOR METHOD '" + methodName + "'");

        // Print out the caller
        String identity = SecurityManager.getManager().getCaller();
        logger.info("The caller is:" + identity);

        // Print out the invocation subject
        subject = JaasSubject.getCurrentSubject();
        logger.info("INVOCATION SUBJECT");
        logger.info(subject == null ? "NULL" : subject.toString());

        try {
                // Print out service subject
                logger.info("SERVICE SUBJECT");
                subject = SecurityManager.getManager().getServiceSubject();
                logger.info(subject == null ? "NULL" : subject.toString());
        } catch (Exception e) {
                logger.warn("Unable to obtain service subject");
        }

        try {
                // Print out system subject
                logger.info("SYSTEM SUBJECT");
                subject = SecurityManager.getManager().getSystemSubject();
                logger.info(subject == null ? "NULL" : subject.toString());
        } catch (Exception e) {
                logger.warn("Unable to obtain system subject");
        }
        }
    
    /* Required by interface ResourceProperties */
    public ResourcePropertySet getResourcePropertySet() {
            return this.propSet;
    }  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -