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:
Option Public
Option Declare
Sub Initialize
Dim s As New NotesSession
Dim inikey As String
Dim secFileName As String
Dim stream As NotesStream
Dim policy As String
Dim beginString As String
Dim endString As String
Dim permission As String
Dim beginPos As Integer
Dim endPos As Integer
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 < 1 Then
'We don't have any so we abort
Exit sub
End If
Dim firstCut As String
firstCut = Mid$ (policy,beginPos )
endPos = InStr (firstCut,endString )
If endPos < 1 Then
'The file is borked
Exit Sub
End If
Dim allGrant As String
allGrant = Mid$ (firstCut, 1,endPos )
'Now the check
If InStr (allGrant,permission ) < 1 Then
'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 )
End If
Call stream. Close ( )
End Sub
As usual YMMVOption Declare
Sub Initialize
Dim s As New NotesSession
Dim inikey As String
Dim secFileName As String
Dim stream As NotesStream
Dim policy As String
Dim beginString As String
Dim endString As String
Dim permission As String
Dim beginPos As Integer
Dim endPos As Integer
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 < 1 Then
'We don't have any so we abort
Exit sub
End If
Dim firstCut As String
firstCut = Mid$ (policy,beginPos )
endPos = InStr (firstCut,endString )
If endPos < 1 Then
'The file is borked
Exit Sub
End If
Dim allGrant As String
allGrant = Mid$ (firstCut, 1,endPos )
'Now the check
If InStr (allGrant,permission ) < 1 Then
'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 )
End If
Call stream. Close ( )
End Sub
Update: Going after java.pol requires a slightly different approach:
Option Public
Option Declare
Sub Initialize
Dim s As New NotesSession
Dim inikey As String
Dim secFileName As String
Dim stream As NotesStream
Dim policy As String
Dim beginString As String
Dim endString As String
Dim permission As String
Dim beginPos As Integer
Dim endPos As Integer
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. Iseos Then
Call stream. Writetext (beginString, EOL_PLATFORM )
Call stream. Writetext (permission, EOL_PLATFORM )
Call stream. Writetext (endString, EOL_PLATFORM )
Call stream. Close ( )
Exit Sub
End If
'Read the entire file in one go
policy = stream. Readtext ( )
beginPos = InStr (policy,beginString )
If beginPos < 1 Then
'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 ( )
Exit sub
End If
Dim firstCut As String
firstCut = Mid$ (policy,beginPos )
endPos = InStr (firstCut,endString )
If endPos < 1 Then
'The file is borked, we won't touch it!
Exit Sub
End If
Dim allGrant As String
allGrant = Mid$ (firstCut, 1,endPos )
'Now the check
If InStr (allGrant,permission ) < 1 Then
'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 )
End If
Call stream. Close ( )
End Sub
Option Declare
Sub Initialize
Dim s As New NotesSession
Dim inikey As String
Dim secFileName As String
Dim stream As NotesStream
Dim policy As String
Dim beginString As String
Dim endString As String
Dim permission As String
Dim beginPos As Integer
Dim endPos As Integer
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. Iseos Then
Call stream. Writetext (beginString, EOL_PLATFORM )
Call stream. Writetext (permission, EOL_PLATFORM )
Call stream. Writetext (endString, EOL_PLATFORM )
Call stream. Close ( )
Exit Sub
End If
'Read the entire file in one go
policy = stream. Readtext ( )
beginPos = InStr (policy,beginString )
If beginPos < 1 Then
'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 ( )
Exit sub
End If
Dim firstCut As String
firstCut = Mid$ (policy,beginPos )
endPos = InStr (firstCut,endString )
If endPos < 1 Then
'The file is borked, we won't touch it!
Exit Sub
End If
Dim allGrant As String
allGrant = Mid$ (firstCut, 1,endPos )
'Now the check
If InStr (allGrant,permission ) < 1 Then
'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 )
End If
Call stream. Close ( )
End Sub
Posted by Stephan H Wissel on 21 May 2013 | Comments (10) | categories: XPages