forked from brianolson/go-openid
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize Identifier, Discovery and ParseXRDS start to follow the specs
- Loading branch information
Florian Duraffourg
committed
Aug 25, 2010
1 parent
153773e
commit 35c7e7b
Showing
4 changed files
with
131 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ TARG=openid | |
GOFILES=\ | ||
openid.go\ | ||
yadis.go \ | ||
xrds.go \ | ||
http.go | ||
|
||
include $(GOROOT)/src/Make.pkg | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package openid | ||
|
||
import ( | ||
"xml" | ||
"fmt" | ||
"io" | ||
"strings" | ||
) | ||
|
||
type XRDSIdentifier struct { | ||
XMLName xml.Name "Service" | ||
Type []string | ||
URI string | ||
LocalID string | ||
} | ||
type XRD struct { | ||
XMLName xml.Name "XRD" | ||
Service XRDSIdentifier | ||
} | ||
type XRDS struct { | ||
XMLName xml.Name "XRDS" | ||
XRD XRD | ||
} | ||
|
||
func (o *OpenID) ParseXRDS(r io.Reader){ | ||
XRDS := new(XRDS) | ||
err := xml.Unmarshal(r, XRDS) | ||
if err != nil { | ||
fmt.Printf(err.String()) | ||
return | ||
} | ||
XRDSI := XRDS.XRD.Service | ||
|
||
XRDSI.URI = strings.TrimSpace(XRDSI.URI) | ||
XRDSI.LocalID = strings.TrimSpace(XRDSI.LocalID) | ||
|
||
fmt.Printf("%v\n", XRDSI) | ||
|
||
if StringTableContains(XRDSI.Type,"http://specs.openid.net/auth/2.0/server") { | ||
o.OPEndPoint = XRDSI.URI | ||
fmt.Printf("OP Identifier Element found\n") | ||
} else if StringTableContains(XRDSI.Type, "http://specs.openid.net/auth/2.0/signon") { | ||
fmt.Printf("Claimed Identifier Element found\n") | ||
o.OPEndPoint = XRDSI.URI | ||
o.OPLocalIdentifier = XRDSI.LocalID | ||
} | ||
} | ||
|
||
|
||
func StringTableContains (t []string, s string) bool { | ||
for _,v := range t { | ||
if v == s { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters