Přeskočit na hlavní obsah

Příspěvky

Solution to failing Configuration.getConfiguration() in Java

Sometimes the calling javax.security.auth.login.Configuration.getConfiguration() fails with SecurityException in our tests (both Oracle and IBM). A quick solution (without touching JDK installation or configuring java.security.auth.login.config system property) is simple. Just create an empty file .java.login.config in your user home directory (more info in ConfigFile JavaDoc ). Thats it! touch ~/.java.login.config Just to make the picture complete, here is the stack trace we see on IBM JDK: Exception in thread "main" java.lang.SecurityException: Unable to locate a login configuration at com.ibm.security.auth.login.ConfigFile.<init>(ConfigFile.java:125) at java.lang.J9VMInternals.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1681) at javax.security.auth.login.Configuration$2.run(Configuration.java:263) at javax.security.auth.login.Configuration$2.run(Configuration.java:255) at java.security.AccessController.doPrivileged(Acces...

jOpenSpace 2014

The best pure Czech not-only-Java conference jOpenSpace is over for this year and I'd like to write few words about it. First of all, big thanks goes to Honza @novoj Novotný as the main organizer. This awesome event under his supervision become not only interesting from the technical PoV, but also very socializing (We were a nice Java family). Next thanks goes to all sponsors, who made jOpenSpace comfortable and cheap as a hell: Red Hat Vendavo MoroSystems FG Forrest Kerio ABRA FlexiBee Friday We started the conference with a free day! The main program for Friday was a trip to Slovakia - to climb the Velka Javorina. Rainy weather was very demanding. Nevertheless, no one gave up! Hotel sauna was a nice end of a day and it was already fulfilled with interesting Java topics. Saturday Few of us started the day with a nice 9km run. The weather was beautiful and hills around colorful. First lightning talks started after the breakfast and continued during whole day. ...

Speed-up ApacheDS LDAP server for testing

Using the ApacheDS for unit testing can be painful if you need to restart/reconfigure the server several times. IT'S SOOO SLOOOOW. The reason is simple. The default configuration creates a nice directory structure and unpacks all the schema files from JAR file to one of the created directories. Then it creates a file based JDBM partition for you. And it loads your LDIF data to it. It means many, money, many I/O operations even before the LDAP starts. Nevertheless, ApacheDS has a nice API to resolve this issue. You will need to make your hands dirty little bit, but it's worth it. Follow these 3 simple steps and it's all: Create schema partition class, which stores LDAP schema data in-memory only: sample InMemorySchemaPartition.java Create DirectoryServiceFactory implementation, which will use in-memory AvlPartitions instead of JDBM and as a schema partition it will use class from the first step: sample InMemoryDirectoryServiceFactory.java use the new Director...

Debug security in WildFly 8.x / EAP 6.x / JBoss AS7

If you try to find what are the security components doing in WildFly 8.x (or EAP 6.x + AS7) then enable TRACE log level for several categories. You can simply use JBoss CLI to configure it: cd $JBOSS_HOME/bin ./jboss-cli.sh -c << EOT /subsystem=logging/logger=org.jboss.security:add(level=ALL) /subsystem=logging/logger=org.jboss.as.security:add(level=ALL) /subsystem=logging/logger=org.picketbox:add(level=ALL) /subsystem=logging/logger=org.apache.catalina.authenticator:add(level=ALL) /subsystem=logging/logger=org.jboss.as.web.security:add(level=ALL) /subsystem=logging/logger=org.jboss.as.domain.management.security:add(level=ALL) /subsystem=logging/console-handler=CONSOLE:write-attribute(name=level, value=ALL) quit EOT If you don't use $JBOSS_HOME environment variable, just replace it with path to your application server installation.

jd-cli – Command line Java Decompiler

Kdo by neznal jd-gui Java Decompiler (z free.fr) a jeho sourozence, pluginy pro IDE – Eclipse a IntelliJ. Ale nechyběla vám také někdy možnost rychle decompilovat celý JAR nebo WAR do adresáře, případně zobrazit si decompilovanou třídu jen v konzoli bez nutnosti spouštění GUI? Jestliže ano, pak se zkuste podívat na utilitku jd-cli , která toto všechno umožňuje. Tato aplikace je jednoduchý wrapper nad nativní knihovnou pro jd-gui InelliJ plugin. Kde všude tato java aplikace běží? Windows Linux Mac OSX Kompilace Potřebujete git a Maven. git clone git@github.com:kwart/jd-cmd.git cd jd-cmd mvn clean package Rozbalte jd-cli-[version].zip (.tar.gz) někam, kam odkazuje systémová PATH proměnná ( C:\Windows nebo $HOME/bin ) - distribuce obsahuje i spouštěcí skripty (shell a batch), takže pak už jen vesele voláte jd-cli [aParametry] Příklady použití jd-cli HelloWorld.class Zobrazí dekompilovanou třídu v konzoli jd-cli --skipResources -n -g ALL app.jar Dekompiluje obsah...

Write once, run everywhere! Ale jen ocuť pocuť.

Dneska jsem zkoumal, proč nám některé testy pracují správně s Oracle Javou (1.6), ale pod IBM Javičkou padají. A výsledek mého bádání mě ohromil. Člověk by doufal, že alespoň třídy v balíku java.lang budou implementovány obdobně. A prdlajz! Náš problém má původ v rozdílné implementaci metody Class.getMethods() , která toho občas u IBM vrátí o něco více než u Oraclu. Nejsem si zatím jistý, která implementace odpovídá JLS lépe, ale do dneška jsem předpokládal, že kvůli takovýmto problémům existuje TCK. Chcete-li si problém vyzkoušet sami, zde je kód: /** * This class is a reproducer for different results returned from Oracle and IBM Class.getMethod() call. * * @author Josef Cacek */ public class GetMethodsProblemReproducer { // Public methods -------------------------------------------------------- /** * Main method. */ public static void main(String[] args) { System.out.println("Java: " + System.getProperty("java.version")...

Autorizace a jboss-web.xml v AS7

Chcete-li použít vlastní autorizační modul ve webové aplikaci nad JBoss AS7 (policy module v terminologii AS7 security domén), nezapomeňte přidat element use‑jboss‑authorization do konfiguračního souboru jboss-web.xml . Toť novinka oproti dřívějším verzím aplikačního serveru. Celý soubor WEB-INF/jboss-web.xml pak může vypadat například takto: <?xml version="1.0" encoding="UTF-8"?> <jboss-web> <security-domain>DomainWithCustomPolicyModule</security-domain> <use-jboss-authorization>true</use-jboss-authorization> </jboss-web> Update: Až to zase zapomenu, tak správná místa, kde hledate pomoc jsou: org.jboss.as.web.security.JBossWebRealm org.jboss.metadata.web.jboss.JBossWebMetaData and its subclasses org.jboss.metadata.parser.jbossweb.JBossWebMetaDataParser