本文へジャンプ

「送信する」をクリックすることにより、お客様は developerWorks のご使用条件に同意したことになります。 ご使用条件を読む


お客様が developerWorks に初めてサインインすると、プロフィールが作成されます。プロフィールで選択した情報は公開されますが、いつでもその情報を編集できます。お客様の姓名(非表示設定にしていない限り)とディスプレイ・ネームは、投稿するコンテンツと一緒に表示されます。

送信されたすべての情報は安全です。

  • 閉じる [x]

developerWorks に初めてサインインするとプロフィールが作成されますので、その際にディスプレイ・ネームを選択する必要があります。ディスプレイ・ネームは、お客様が developerWorks に投稿するコンテンツと一緒に表示されます。

ディスプレイ・ネームは、3文字から31文字の範囲で指定し、かつ developerWorks コミュニティーでユニークである必要があります。また、プライバシー上の理由でお客様の電子メール・アドレスは使用しないでください。

「送信する」をクリックすることにより、お客様は developerWorks のご使用条件に同意したことになります。 ご使用条件を読む


送信されたすべての情報は安全です。

  • 閉じる [x]

SPL (Simplified Policy Language) 入門


記事に戻る



リスト 2. Complete policy
                
/*Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.  
 */
package org.apache.imperius.javaspl.samples.windowscomputersystem;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Map;
import org.apache.imperius.javaspl.Java_SPLPolicyRuleProvider;
import org.apache.imperius.spl.parser.exceptions.SPLException;
public class WindowsSystemManager {

public static void main(String[] args)throws IOException,SPLException{ 

WindowsComputerSystem system1=new WindowsComputerSystem();
String policyToExecute = "Java_FileSystem";	
try {
if(args.length == 1){
policyToExecute = args[0];
	}
Java_SPLPolicyRuleProvider jspl = new java_SPLPolicyRuleProvider();

String aFile = "policies/" + policyToExecute + ".spl";

StringBuffer contents = new StringBuffer();

BufferedReader input = null;

try	{

input = new BufferedReader( new FileReader(aFile) );
String line = null; 

while (( line = input.readLine()) != null){

contents.append(line);
contents.append(System.getProperty("line.separator"));

}
input.close();
}
	catch (FileNotFoundException ex)   {
	      ex.printStackTrace();
      }catch (IOException ex){
	      ex.printStackTrace();
      }
      try    {
	   	jspl.deletePolicy(policyToExecute);
	}   catch(Exception e)    { }

		    
boolean createReturn=jspl.createPolicy(policyToExecute, contents.toString());
System.out.println("Policy Created : " + policyToExecute +createReturn);
    System.out.println("");
		    
    Map objMap = new Hashtable();
	    
    objMap.put("system1", system1);
		      
    Object result = jspl.executePolicy(policyToExecute, objMap);
   System.out.println("Result is " + result);
}catch (SPLException e) {
	e.printStackTrace();
 }
}


}

      

記事に戻る