Don't try this at home!
Domino has a refined security system, so the java.policy file can be a real PITA. So you would be tempted to write a few lines of LotusScript and run it on a scheduled agent, so on the next server restart that pain goes away. Of course you wouldn't write code like below which lacks any error handling.You also would not hide this code from your admin people who would want an impact study and your firstborn for any change they make. So instead of doing all this you wait until there is a proper configuration setting for this.
Update: Going after java.pol requires a slightly different approach:
OptionPublic
OptionDeclare
Sub Initialize
Dim s AsNewNotesSession
Dim inikey AsString
Dim secFileName AsString
Dim stream AsNotesStream
Dim policy AsString
Dim beginString AsString
Dim endString AsString
Dim permission AsString
Dim beginPos AsInteger
Dim endPos AsInteger
inikey = "NotesProgram"
beginString = "grant {"
endString = "}"
secFileName = s. Getenvironmentstring(iniKey, true)
secFileName = secFileName + "jvm/lib/security/java.policy"
permission = "permission java.security.AllPermission;"
Set stream = s. Createstream()
Call stream. Open(secFileName )
policy = stream. Readtext()
beginPos = InStr(policy,beginString )
If beginPos < 1Then
'We don't have any so we abort
Exitsub
EndIf
Dim firstCut AsString
firstCut = Mid$(policy,beginPos )
endPos = InStr(firstCut,endString )
If endPos < 1Then
'The file is borked
ExitSub
EndIf
Dim allGrant AsString
allGrant = Mid$(firstCut, 1,endPos )
'Now the check
IfInStr(allGrant,permission ) < 1Then
'We need to update the file
Call stream. Truncate()
Call stream. Writetext(Mid$(policy, 1,beginPos+ 7), EOL_NONE )
Call stream. Writetext(permission, EOL_PLATFORM )
Call stream. Writetext(Mid$(policy,beginPos+ 7), EOL_NONE )
EndIf
Call stream. Close()
EndSub
As usual YMMVOptionDeclare
Sub Initialize
Dim s AsNewNotesSession
Dim inikey AsString
Dim secFileName AsString
Dim stream AsNotesStream
Dim policy AsString
Dim beginString AsString
Dim endString AsString
Dim permission AsString
Dim beginPos AsInteger
Dim endPos AsInteger
inikey = "NotesProgram"
beginString = "grant {"
endString = "}"
secFileName = s. Getenvironmentstring(iniKey, true)
secFileName = secFileName + "jvm/lib/security/java.policy"
permission = "permission java.security.AllPermission;"
Set stream = s. Createstream()
Call stream. Open(secFileName )
policy = stream. Readtext()
beginPos = InStr(policy,beginString )
If beginPos < 1Then
'We don't have any so we abort
Exitsub
EndIf
Dim firstCut AsString
firstCut = Mid$(policy,beginPos )
endPos = InStr(firstCut,endString )
If endPos < 1Then
'The file is borked
ExitSub
EndIf
Dim allGrant AsString
allGrant = Mid$(firstCut, 1,endPos )
'Now the check
IfInStr(allGrant,permission ) < 1Then
'We need to update the file
Call stream. Truncate()
Call stream. Writetext(Mid$(policy, 1,beginPos+ 7), EOL_NONE )
Call stream. Writetext(permission, EOL_PLATFORM )
Call stream. Writetext(Mid$(policy,beginPos+ 7), EOL_NONE )
EndIf
Call stream. Close()
EndSub
Update: Going after java.pol requires a slightly different approach:
OptionPublic
OptionDeclare
Sub Initialize
Dim s AsNewNotesSession
Dim inikey AsString
Dim secFileName AsString
Dim stream AsNotesStream
Dim policy AsString
Dim beginString AsString
Dim endString AsString
Dim permission AsString
Dim beginPos AsInteger
Dim endPos AsInteger
inikey = "NotesProgram"
beginString = "grant {"
endString = "}"
secFileName = s. Getenvironmentstring(iniKey, true)
secFileName = secFileName + "jvm/lib/security/java.pol"
permission = "permission java.security.AllPermission;"
Set stream = s. Createstream()
'Open or create the file
Call stream. Open(secFileName )
'A new file would be IsEOS
If stream. IseosThen
Call stream. Writetext(beginString, EOL_PLATFORM )
Call stream. Writetext(permission, EOL_PLATFORM )
Call stream. Writetext(endString, EOL_PLATFORM )
Call stream. Close()
ExitSub
EndIf
'Read the entire file in one go
policy = stream. Readtext()
beginPos = InStr(policy,beginString )
If beginPos < 1Then
'We don't have any general grant statement, so we need to add it
Call stream. Writetext("", EOL_PLATFORM )'One new line
Call stream. Writetext(beginString, EOL_PLATFORM )
Call stream. Writetext(permission, EOL_PLATFORM )
Call stream. Writetext(endString, EOL_PLATFORM )
Call stream. Close()
Exitsub
EndIf
Dim firstCut AsString
firstCut = Mid$(policy,beginPos )
endPos = InStr(firstCut,endString )
If endPos < 1Then
'The file is borked, we won't touch it!
ExitSub
EndIf
Dim allGrant AsString
allGrant = Mid$(firstCut, 1,endPos )
'Now the check
IfInStr(allGrant,permission ) < 1Then
'We need to update the file
Call stream. Truncate()
Call stream. Writetext(Mid$(policy, 1,beginPos+ 7), EOL_NONE )
Call stream. Writetext(permission, EOL_PLATFORM )
Call stream. Writetext(Mid$(policy,beginPos+ 7), EOL_NONE )
EndIf
Call stream. Close()
EndSub
OptionDeclare
Sub Initialize
Dim s AsNewNotesSession
Dim inikey AsString
Dim secFileName AsString
Dim stream AsNotesStream
Dim policy AsString
Dim beginString AsString
Dim endString AsString
Dim permission AsString
Dim beginPos AsInteger
Dim endPos AsInteger
inikey = "NotesProgram"
beginString = "grant {"
endString = "}"
secFileName = s. Getenvironmentstring(iniKey, true)
secFileName = secFileName + "jvm/lib/security/java.pol"
permission = "permission java.security.AllPermission;"
Set stream = s. Createstream()
'Open or create the file
Call stream. Open(secFileName )
'A new file would be IsEOS
If stream. IseosThen
Call stream. Writetext(beginString, EOL_PLATFORM )
Call stream. Writetext(permission, EOL_PLATFORM )
Call stream. Writetext(endString, EOL_PLATFORM )
Call stream. Close()
ExitSub
EndIf
'Read the entire file in one go
policy = stream. Readtext()
beginPos = InStr(policy,beginString )
If beginPos < 1Then
'We don't have any general grant statement, so we need to add it
Call stream. Writetext("", EOL_PLATFORM )'One new line
Call stream. Writetext(beginString, EOL_PLATFORM )
Call stream. Writetext(permission, EOL_PLATFORM )
Call stream. Writetext(endString, EOL_PLATFORM )
Call stream. Close()
Exitsub
EndIf
Dim firstCut AsString
firstCut = Mid$(policy,beginPos )
endPos = InStr(firstCut,endString )
If endPos < 1Then
'The file is borked, we won't touch it!
ExitSub
EndIf
Dim allGrant AsString
allGrant = Mid$(firstCut, 1,endPos )
'Now the check
IfInStr(allGrant,permission ) < 1Then
'We need to update the file
Call stream. Truncate()
Call stream. Writetext(Mid$(policy, 1,beginPos+ 7), EOL_NONE )
Call stream. Writetext(permission, EOL_PLATFORM )
Call stream. Writetext(Mid$(policy,beginPos+ 7), EOL_NONE )
EndIf
Call stream. Close()
EndSub
Posted by Stephan H Wissel on 21 May 2013 | Comments (10) | categories: XPages