Friday, January 6, 2012

Weblogic auto login with boot properties file

Weblogic requires JVM property -Dweblogic.system.BootIdentityFile to locate boot.properties file
How a Server Uses a Boot Identity File at Startup
http://docs.oracle.com/cd/E14571_01/web.1111/e13708/overview.htm#START132


# create boot properties file
${DOMAIN_HOME}/bin/createBootProperties.sh

#use boot.properties from AdminServer dir - this is necessary for weblogic.Admin to run without password
JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.system.BootIdentityFile=${DOMAIN_HOME}/servers/${SERVER_NAME}/security/boot.properties"

# add trust key store
SSL_ARGS="${JAVA_OPTIONS} -Dweblogic.security.SSL.trustedCAKeyStore=/weblogic/weblogic10.3/wlserver_10.3/server/lib/DemoTrust.jks -Dweblogic.security.SSL
.ignoreHostnameVerification=true"

# check if admin server is not already running
echo "Checking if admin server is not already running..."
${JAVA_HOME}/bin/java ${SSL_ARGS} weblogic.Admin -url t3s://localhost:7001 PING



Without JVM property attempt to call Weblogic without password returns following error

WebLogic server requires a valid username and password for the command that you are trying to execute. Please try again


Password and username can be encrypted by weblogic.security.Encrypt which is using domain key /app/domains/base_domain/security/SerializedSystemIni.dat
http://docs.oracle.com/cd/E21764_01/web.1111/e13749/utils.htm#ADMRF142
http://docs.oracle.com/cd/E13222_01/wls/docs92/admin_ref/utils.html#wp1209592

#!/bin/bash

WL_HOME=/app/weblogic122/wlserver_12.1
DOMAIN_HOME=/app/domains/base_domain

. $WL_HOME/server/bin/setWLSEnv.sh

BOOT_PROPERTIES_DIR=$DOMAIN_HOME/servers/AdminServer/security
BOOT_PROPERTIES_FILE=$BOOT_PROPERTIES_DIR/boot.properties

mkdir -p $BOOT_PROPERTIES_DIR

printf "username=" > $BOOT_PROPERTIES_FILE
java -Dweblogic.RootDirectory=/app/domains/base_domain weblogic.security.Encrypt weblogic >> $BOOT_PROPERTIES_FILE
printf "password=" >> $BOOT_PROPERTIES_FILE
java -Dweblogic.RootDirectory=/app/domains/base_domain weblogic.security.Encrypt weblogic123 >> $BOOT_PROPERTIES_FILE


[dave@dave java]$ more /app/domains/base_domain/servers/AdminServer/security/boot.properties 
username={AES}DG3YOrSwfkK0YrxUM+4cMf+wF91eYhhHpF4wFbsydp0=
password={AES}pkaZZGMqSWQwFEMJSj+FO0aY9LatGJTkz4CZ0Un5v64=




Domain Configuration Files
http://docs.oracle.com/cd/E14571_01/web.1111/e13716/config_files.htm#i1091725
servers/server-name/security
This directory holds security-related files that can be or must be different for each Oracle WebLogic Server instance. The file boot.properties is an example of a file that resides here because it can differ from one server to the next. This directory also maintains files related to SSL keys.

1 comment:

  1. Hi,

    I am trying the same thing but it wont recognize the boot.properties file:

    java -Dweblogic.system.BootIdentityFile=/opt/Oracle/Middleware/weblogic12c/user_projects/domains/mydomain/servers/myserver/security/boot.properties -Dweblogic.RootDirectory=/opt/Oracle/Middleware/weblogic12c/user_projects/domains/mydomain/servers/myserver weblogic.Admin -adminurl t3://192.168.1.10:7001 FORCESHUTDOWN myserver

    WebLogic server requires a valid username and password for the command that you are trying to execute. Please try again

    Any clues why?

    ReplyDelete