Monday, March 17, 2008

Print login module info

private void print() {

System.out.println(">>> -------------------------------------------------- = ");
System.out.println(">>> EXOMAN MyLoginModule.print() subject = " + subject);
System.out.println(">>> EXOMAN MyLoginModule.print() callbackHandler = " + callbackHandler);
System.out.println(">>> EXOMAN MyLoginModule.print() sharedState = " + sharedState);
System.out.println(">>> EXOMAN MyLoginModule.print() options = " + options);

if (subject != null) {
System.out.println(">>> EXOMAN MyLoginModule.print() subject.getClass() = " + subject.getClass());

// print private credentials
System.out.println(">>> EXOMAN MyLoginModule.print() subject.getPrivateCredentials() = " + subject.getPrivateCredentials());
Set priv = subject.getPrivateCredentials();
System.out.println(">>> EXOMAN MyLoginModule.print() priv = " + priv);
if (priv != null && !priv.isEmpty()) {
Iterator privIt = priv.iterator();
while (privIt.hasNext()) {
Object elem = privIt.next();
System.out.println(">>> EXOMAN MyLoginModule.print() elem.getClass() = " + elem.getClass());
}
}

// print public credentials
System.out.println(">>> EXOMAN MyLoginModule.print() subject.getPublicCredentials() = " + subject.getPublicCredentials());
Set pub = subject.getPublicCredentials();
System.out.println(">>> EXOMAN MyLoginModule.print() pub = " + pub);
if (pub != null && !pub.isEmpty()) {
Iterator pubIt = pub.iterator();
while (pubIt.hasNext()) {
Object elem = pubIt.next();
System.out.println(">>> EXOMAN MyLoginModule.print() elem.getClass() = " + elem.getClass());
}
}

// print principals
Set principals = subject.getPrincipals();
if (principals != null && !principals.isEmpty()) {
System.out.println(">>> EXOMAN MyLoginModule.print() principals = " + principals);
Iterator principalsIter = principals.iterator();
while (principalsIter.hasNext()) {
Principal elem = principalsIter.next();
System.out.println(">>> EXOMAN MyLoginModule.print() elem = " + elem);
System.out.println(">>> EXOMAN MyLoginModule.print() elem.getName() = " + elem.getName());
}
}
}

// print shared state
Iterator i = sharedState.keySet().iterator();
while (i.hasNext()) {
Object o = i.next();
System.out.println(">>> EXOMAN MyLoginModule.print() o = " + o);
System.out.println(">>> EXOMAN MyLoginModule.print() sharedState.get(o) = " + sharedState.get(o));
}

// print options
if (options != null && !options.isEmpty()) {
Iterator keyOpt = options.keySet().iterator();
while (keyOpt.hasNext()) {
Object opt = keyOpt.next();
System.out.println(">>> EXOMAN MyLoginModule.print() keyOpt = " + opt);
System.out.println(">>> EXOMAN MyLoginModule.print() options.get(keyOpt) = " + options.get(opt));
}
}

}

2 comments:

Владимир Долженко said...

да откроет пишущий для себя log4j. аминь.

Alexey Zavizionov said...

Я открыл log4j до этого :)