カテゴリー: JAVA
LDAP ActiveDirectory 参考資料
ActiveDirectoryの入ったサーバとLDAPでSSL通信を行うためには、ドメインの証明書とサーバ証明書を入れたキーストア(keystore)を作成する
eclipse3.6 デバッグ時のTOMCAT6 でのログ出力の設定
eclipse3.6(PLEIADES)では、c:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 がcatalina.homeになっている。
workspace を c:\workspace としているが、自分の環境に合わせて設定してください。
1.アクセスログを出す場合
c:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\server.xmlの修正
アクセスログ出力の項目がコメントアウトされているので、コメントアウトを解除する。
[text]
<–
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs”
prefix=”localhost_access_log.” suffix=”.txt” pattern=”common” resolveHosts=”false”/>
–>
[/text]
↓
[text]
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs”
prefix=”localhost_access_log.” suffix=”.txt” pattern=”common” resolveHosts=”false”/>
[/text]
2.いわゆるログをログファイルに記録する場合
2.1.サーバー起動時の設定を修正する。
起動構成を開く->引数に以下を追加する。
[text]
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=”c:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\logging.properties”
[/text]
2.2.logging.properties ファイルをコピーする
c:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf に logging.properties ファイルをコピーする。
logging.properties は、TOMCAT_HOME\confにあるのを使用してください。
JAVA でファイル名を分解するクラス
JAVA でファイル名を分解するクラス
[text]
package jp.computer-system.util.file;
public class FileString
{
private String filePath = “”;
private String drive;
private String folder;
private String fileName;
private String ext;
public FileString()
{
}
public FileString(String filePath)
{
this.filePath = filePath;
String[] strs = filePath.split(“[/,\\\\]”);
if(strs.length == 0 ) return;
int six = 0;
if(!(strs[0].indexOf(“:”)==-1))
{
six=1;
drive = strs[0];
}
folder = “”;
for(int i=six;i<(strs.length – 1);i++)
{
if(folder.length()!=0)
{
folder += "/" + strs[i];
}
else
{
folder = strs[i];
}
}
fileName = strs[strs.length -1];
int ip = fileName.lastIndexOf(".");
if(ip==-1)
{
ext = "";
}
else
{
if((ip+1)==fileName.length())
{
ext = "";
}
else
{
ext = fileName.substring(ip + 1);
}
}
}
public String getDrive() {
return drive;
}
public void setDrive(String drive) {
this.drive = drive;
}
public String getFolder() {
return folder;
}
public void setFolder(String folder) {
this.folder = folder;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getExt() {
return ext;
}
public void setExt(String ext) {
this.ext = ext;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
}
[/text]
OpenLdapにLINUXユーザーアカウントを作ったけどその他の情報もLDAPに入れておきたかったので作ったSchema
/etc/openldap/schema フォルダーに ldapusers.schema を作成した。
[text]
attributetype ( 1.1.2.1.1.500.1
NAME ‘userName’
DESC ‘jp.compsys user name UTF8’
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch <—- filter の部分文字列検索するためには必要か?!
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{200} )
attributetype ( 1.1.2.1.1.500.2
NAME 'mailAddress'
DESC 'jp.compsys email address'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
attributetype ( 1.1.2.1.1.500.3
NAME 'mailAddressMobile'
DESC 'jp.compsys mobile email address'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
objectclass ( 1.1.2.1.1.100.1
NAME 'personalInfo'
DESC 'jp.compsys personal information'
SUP top AUXILIARY
MAY ( userName $ mailAddress $ mailAddressMobile ) )
[/text]
/etc/openldap/slapd.conf にldapusers.schema を追加する。修正したら slapd を再起動する。
[text]
include /etc/openldap/schema/nis.schema
include /etc/openldap/schema/openldap.schema
include /etc/openldap/schema/ppolicy.schema
include /etc/openldap/schema/collective.schema
include /etc/openldap/schema/ldapusers.schema <—–ここ
[/text]
javaで使うときは
[text]
// objectClass(必須)
Attribute attrObjClass = new BasicAttribute(“objectClass”);
attrObjClass.add(0, “top”);
attrObjClass.add(1, “account”);
attrObjClass.add(2, “posixAccount”);
attrObjClass.add(3, “personalInfo”);
attrs.put(attrObjClass);
[/text]